repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
---|---|---|---|---|---|---|
chipKIT32/chipKIT-importer | src/com/microchip/mplab/nbide/embedded/arduino/importer/PlatformFactory.java | // Path: src/com/microchip/mplab/nbide/embedded/arduino/importer/ArduinoConfig.java
// public static final String ROOT_PLATFORM_ARCH = "avr";
//
// Path: src/com/microchip/mplab/nbide/embedded/arduino/importer/ArduinoConfig.java
// public static final String ROOT_PLATFORM_VENDOR = "arduino";
//
// Path: src/com/microchip/mplab/nbide/embedded/arduino/importer/pic32/PIC32Platform.java
// public class PIC32Platform extends Platform {
//
// public PIC32Platform(Platform parent, String vendor, Path rootPath) throws IOException {
// super(parent, vendor, "pic32", rootPath );
// putValue("compiler.c.cmd", "xc32-gcc");
// putValue("compiler.c.elf.cmd", "xc32-g++");
// putValue("compiler.cpp.cmd", "xc32-g++");
// putValue("compiler.ar.cmd", "xc32-ar");
// putValue("compiler.objcopy.cmd", "xc32-objcopy");
// putValue("compiler.elf2hex.cmd", "xc32-bin2hex");
// putValue("compiler.size.cmd", "xc32-size");
// data.entrySet().forEach( e -> e.setValue( e.getValue().replaceAll(" -O2 ", " -O1 ") ) );
// }
//
// }
| import static com.microchip.mplab.nbide.embedded.arduino.importer.ArduinoConfig.ROOT_PLATFORM_ARCH;
import static com.microchip.mplab.nbide.embedded.arduino.importer.ArduinoConfig.ROOT_PLATFORM_VENDOR;
import com.microchip.mplab.nbide.embedded.arduino.importer.pic32.PIC32Platform;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger; | return platform;
}
}
return null;
}
public Platform createPlatformFromRootDirectory(Path platformRootPath) throws IOException {
Path platformFilePath = platformRootPath.resolve(PLATFORM_FILENAME);
Platform rootPlatform = createRootPlatform();
return createPlatformFromFile(rootPlatform, platformFilePath);
}
public boolean isValidPlatformRootPath(Path rootPath) {
return rootPath != null && Files.exists(rootPath.resolve(PLATFORM_FILENAME));
}
private static Platform createPlatformFromFile(Platform rootPlatform, Path platformFilePath) {
// Pattern: /home/user/.arduino15/packages/{vendor}/hardware/{architecture}/x.x.x/platform.txt
int hardwareIndex = -1;
for (int i = platformFilePath.getNameCount() - 1; i >= 0; i--) {
if ("hardware".equalsIgnoreCase(platformFilePath.getName(i).toString())) {
hardwareIndex = i;
break;
}
}
String vendor = platformFilePath.getName(hardwareIndex - 1).toString();
String architecture = platformFilePath.getName(hardwareIndex + 1).toString();
try {
// if (architecture.equalsIgnoreCase("pic32")) { | // Path: src/com/microchip/mplab/nbide/embedded/arduino/importer/ArduinoConfig.java
// public static final String ROOT_PLATFORM_ARCH = "avr";
//
// Path: src/com/microchip/mplab/nbide/embedded/arduino/importer/ArduinoConfig.java
// public static final String ROOT_PLATFORM_VENDOR = "arduino";
//
// Path: src/com/microchip/mplab/nbide/embedded/arduino/importer/pic32/PIC32Platform.java
// public class PIC32Platform extends Platform {
//
// public PIC32Platform(Platform parent, String vendor, Path rootPath) throws IOException {
// super(parent, vendor, "pic32", rootPath );
// putValue("compiler.c.cmd", "xc32-gcc");
// putValue("compiler.c.elf.cmd", "xc32-g++");
// putValue("compiler.cpp.cmd", "xc32-g++");
// putValue("compiler.ar.cmd", "xc32-ar");
// putValue("compiler.objcopy.cmd", "xc32-objcopy");
// putValue("compiler.elf2hex.cmd", "xc32-bin2hex");
// putValue("compiler.size.cmd", "xc32-size");
// data.entrySet().forEach( e -> e.setValue( e.getValue().replaceAll(" -O2 ", " -O1 ") ) );
// }
//
// }
// Path: src/com/microchip/mplab/nbide/embedded/arduino/importer/PlatformFactory.java
import static com.microchip.mplab.nbide.embedded.arduino.importer.ArduinoConfig.ROOT_PLATFORM_ARCH;
import static com.microchip.mplab.nbide.embedded.arduino.importer.ArduinoConfig.ROOT_PLATFORM_VENDOR;
import com.microchip.mplab.nbide.embedded.arduino.importer.pic32.PIC32Platform;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
return platform;
}
}
return null;
}
public Platform createPlatformFromRootDirectory(Path platformRootPath) throws IOException {
Path platformFilePath = platformRootPath.resolve(PLATFORM_FILENAME);
Platform rootPlatform = createRootPlatform();
return createPlatformFromFile(rootPlatform, platformFilePath);
}
public boolean isValidPlatformRootPath(Path rootPath) {
return rootPath != null && Files.exists(rootPath.resolve(PLATFORM_FILENAME));
}
private static Platform createPlatformFromFile(Platform rootPlatform, Path platformFilePath) {
// Pattern: /home/user/.arduino15/packages/{vendor}/hardware/{architecture}/x.x.x/platform.txt
int hardwareIndex = -1;
for (int i = platformFilePath.getNameCount() - 1; i >= 0; i--) {
if ("hardware".equalsIgnoreCase(platformFilePath.getName(i).toString())) {
hardwareIndex = i;
break;
}
}
String vendor = platformFilePath.getName(hardwareIndex - 1).toString();
String architecture = platformFilePath.getName(hardwareIndex + 1).toString();
try {
// if (architecture.equalsIgnoreCase("pic32")) { | return new PIC32Platform(rootPlatform, vendor, platformFilePath.getParent()); |
chipKIT32/chipKIT-importer | src/com/microchip/mplab/nbide/embedded/arduino/importer/BoardConfiguration.java | // Path: src/com/microchip/mplab/nbide/embedded/arduino/importer/Board.java
// public static final PathMatcher SOURCE_FILE_MATCHER = FileSystems.getDefault().getPathMatcher("glob:*.{c,cpp,S}");
| import static com.microchip.mplab.nbide.embedded.arduino.importer.Board.SOURCE_FILE_MATCHER;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.logging.Logger;
import java.util.stream.Collectors; | if (opt.isPresent()) {
Path variantPath = variantsDirPath.resolve(opt.get());
// If the path does not exist, it might just be because of the letter casing in the variant name
// so go through all directories and compare their lower-case names with lower-case variant name:
if (!Files.exists(variantPath)) {
String lowerCaseDirName = variantPath.getFileName().toString().toLowerCase();
Optional<Path> findAny = Files.list(variantsDirPath).filter(p -> p.getFileName().toString().toLowerCase().equals(lowerCaseDirName)).findAny();
if (findAny.isPresent()) {
variantPath = findAny.get();
} else {
throw new IllegalArgumentException("Did not find any variant directory for board \"" + board.getBoardId() + "\"");
}
}
return variantPath;
} else {
throw new IllegalArgumentException("Did not find any variant directory for board \"" + board.getBoardId() + "\"");
}
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
public List<Path> getCoreFilePaths() throws IOException {
Path variantPath = getVariantPath();
Path corePath = getCoreDirectoryPath();
// Find source files in variant directory:
List<Path> variantFilePaths = new ArrayList<>();
if (variantPath != null) {
variantFilePaths = Files.list(variantPath) | // Path: src/com/microchip/mplab/nbide/embedded/arduino/importer/Board.java
// public static final PathMatcher SOURCE_FILE_MATCHER = FileSystems.getDefault().getPathMatcher("glob:*.{c,cpp,S}");
// Path: src/com/microchip/mplab/nbide/embedded/arduino/importer/BoardConfiguration.java
import static com.microchip.mplab.nbide.embedded.arduino.importer.Board.SOURCE_FILE_MATCHER;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.logging.Logger;
import java.util.stream.Collectors;
if (opt.isPresent()) {
Path variantPath = variantsDirPath.resolve(opt.get());
// If the path does not exist, it might just be because of the letter casing in the variant name
// so go through all directories and compare their lower-case names with lower-case variant name:
if (!Files.exists(variantPath)) {
String lowerCaseDirName = variantPath.getFileName().toString().toLowerCase();
Optional<Path> findAny = Files.list(variantsDirPath).filter(p -> p.getFileName().toString().toLowerCase().equals(lowerCaseDirName)).findAny();
if (findAny.isPresent()) {
variantPath = findAny.get();
} else {
throw new IllegalArgumentException("Did not find any variant directory for board \"" + board.getBoardId() + "\"");
}
}
return variantPath;
} else {
throw new IllegalArgumentException("Did not find any variant directory for board \"" + board.getBoardId() + "\"");
}
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
public List<Path> getCoreFilePaths() throws IOException {
Path variantPath = getVariantPath();
Path corePath = getCoreDirectoryPath();
// Find source files in variant directory:
List<Path> variantFilePaths = new ArrayList<>();
if (variantPath != null) {
variantFilePaths = Files.list(variantPath) | .filter(filePath -> SOURCE_FILE_MATCHER.matches(filePath.getFileName())) |
chipKIT32/chipKIT-importer | src/com/microchip/mplab/nbide/embedded/arduino/importer/LibCoreBuilder.java | // Path: src/com/microchip/mplab/nbide/embedded/arduino/utils/CopyingFileVisitor.java
// public class CopyingFileVisitor implements FileVisitor<Path> {
//
// private static final Logger LOGGER = Logger.getLogger(CopyingFileVisitor.class.getName());
//
// protected final CopyOption[] options = new CopyOption[] { COPY_ATTRIBUTES, REPLACE_EXISTING };
// protected final Path source;
// protected final Path target;
// protected final PathMatcher directoryMatcher;
// protected final PathMatcher fileMatcher;
//
//
// public CopyingFileVisitor(Path source, Path target) {
// this( source, target, null, null );
// }
//
// public CopyingFileVisitor(Path source, Path target, PathMatcher fileMatcher) {
// this( source, target, fileMatcher, null );
// }
//
// public CopyingFileVisitor(Path source, Path target, PathMatcher fileMatcher, PathMatcher directoryMatcher) {
// this.source = source;
// this.target = target;
// this.directoryMatcher = directoryMatcher; // Useful for skipping directories with test code or examples
// this.fileMatcher = fileMatcher;
// }
//
// @Override
// public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
// // Skip directories that don't match the directory matcher
// if ( directoryMatcher != null && !directoryMatcher.matches(dir.getFileName()) ) {
// return SKIP_SUBTREE;
// }
//
// Path newdir = target.resolve(source.relativize(dir));
// if ( !Files.exists(newdir) ) {
// try {
// Files.copy(dir, newdir, options);
// } catch (FileAlreadyExistsException x) {
// // We're always overwriting so this exception should never occur
// } catch (IOException x) {
// LOGGER.log( Level.WARNING, "Unable to create: " + newdir, x);
// return SKIP_SUBTREE;
// }
// }
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
// copyFile(file, target.resolve(source.relativize(file)));
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
// if (exc == null) {
// // Remove the new directory if it turned out to be empty
// Path newdir = target.resolve(source.relativize(dir));
// try {
// if ( Files.list(newdir).count() == 0 ) {
// Files.delete(newdir);
// return CONTINUE;
// }
// } catch (IOException ex) {
// LOGGER.log( Level.WARNING, "Unable to delete empty directory: " + newdir, ex );
// }
//
// // Fix up modification time of directory when done
// try {
// FileTime time = Files.getLastModifiedTime(dir);
// Files.setLastModifiedTime(newdir, time);
// } catch (IOException x) {
// LOGGER.log(Level.WARNING, "Unable to copy all attributes to: " + newdir, x);
// }
// }
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult visitFileFailed(Path file, IOException exc) {
// if (exc instanceof FileSystemLoopException) {
// LOGGER.log( Level.WARNING, "Cycle detected: " + file, exc );
// } else {
// LOGGER.log( Level.WARNING, "Unable to copy: " + file, exc );
// }
// return CONTINUE;
// }
//
// protected void copyFile(Path source, Path target) {
// if ( fileMatcher != null && !fileMatcher.matches(source.getFileName()) ) {
// // Don't copy files other than don't match the file matcher
// return;
// }
//
// try {
// Files.copy(source, target, options);
// } catch (IOException x) {
// LOGGER.log( Level.WARNING, "Unable to copy: " + source, x );
// }
// }
// }
| import com.microchip.mplab.nbide.embedded.arduino.utils.CopyingFileVisitor;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer; | getMakefileContents().add( "\t" + boardConfiguration.getValue("recipe.ar.pattern", runtimeData).get() );
});
}
@Override
protected String mapSourceFilePath(Path sourceFilePath) {
if ( sourceDir != null ) {
return sourceFilePath.getFileName().toString();
} else {
return super.mapSourceFilePath(sourceFilePath);
}
}
@Override
protected String buildIncludesSection( BoardConfiguration boardConfiguration ) {
if ( sourceDir != null ) {
// StringBuilder ret = new StringBuilder();
// ret.append(" \"-I").append(sourceDir.toString()).append("\"");
// return ret.toString();
return "-I.";
} else {
return super.buildIncludesSection(boardConfiguration);
}
}
//*************************************************
//*************** PRIVATE METHODS *****************
//*************************************************
private void copySourceFiles() throws IOException { | // Path: src/com/microchip/mplab/nbide/embedded/arduino/utils/CopyingFileVisitor.java
// public class CopyingFileVisitor implements FileVisitor<Path> {
//
// private static final Logger LOGGER = Logger.getLogger(CopyingFileVisitor.class.getName());
//
// protected final CopyOption[] options = new CopyOption[] { COPY_ATTRIBUTES, REPLACE_EXISTING };
// protected final Path source;
// protected final Path target;
// protected final PathMatcher directoryMatcher;
// protected final PathMatcher fileMatcher;
//
//
// public CopyingFileVisitor(Path source, Path target) {
// this( source, target, null, null );
// }
//
// public CopyingFileVisitor(Path source, Path target, PathMatcher fileMatcher) {
// this( source, target, fileMatcher, null );
// }
//
// public CopyingFileVisitor(Path source, Path target, PathMatcher fileMatcher, PathMatcher directoryMatcher) {
// this.source = source;
// this.target = target;
// this.directoryMatcher = directoryMatcher; // Useful for skipping directories with test code or examples
// this.fileMatcher = fileMatcher;
// }
//
// @Override
// public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
// // Skip directories that don't match the directory matcher
// if ( directoryMatcher != null && !directoryMatcher.matches(dir.getFileName()) ) {
// return SKIP_SUBTREE;
// }
//
// Path newdir = target.resolve(source.relativize(dir));
// if ( !Files.exists(newdir) ) {
// try {
// Files.copy(dir, newdir, options);
// } catch (FileAlreadyExistsException x) {
// // We're always overwriting so this exception should never occur
// } catch (IOException x) {
// LOGGER.log( Level.WARNING, "Unable to create: " + newdir, x);
// return SKIP_SUBTREE;
// }
// }
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
// copyFile(file, target.resolve(source.relativize(file)));
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
// if (exc == null) {
// // Remove the new directory if it turned out to be empty
// Path newdir = target.resolve(source.relativize(dir));
// try {
// if ( Files.list(newdir).count() == 0 ) {
// Files.delete(newdir);
// return CONTINUE;
// }
// } catch (IOException ex) {
// LOGGER.log( Level.WARNING, "Unable to delete empty directory: " + newdir, ex );
// }
//
// // Fix up modification time of directory when done
// try {
// FileTime time = Files.getLastModifiedTime(dir);
// Files.setLastModifiedTime(newdir, time);
// } catch (IOException x) {
// LOGGER.log(Level.WARNING, "Unable to copy all attributes to: " + newdir, x);
// }
// }
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult visitFileFailed(Path file, IOException exc) {
// if (exc instanceof FileSystemLoopException) {
// LOGGER.log( Level.WARNING, "Cycle detected: " + file, exc );
// } else {
// LOGGER.log( Level.WARNING, "Unable to copy: " + file, exc );
// }
// return CONTINUE;
// }
//
// protected void copyFile(Path source, Path target) {
// if ( fileMatcher != null && !fileMatcher.matches(source.getFileName()) ) {
// // Don't copy files other than don't match the file matcher
// return;
// }
//
// try {
// Files.copy(source, target, options);
// } catch (IOException x) {
// LOGGER.log( Level.WARNING, "Unable to copy: " + source, x );
// }
// }
// }
// Path: src/com/microchip/mplab/nbide/embedded/arduino/importer/LibCoreBuilder.java
import com.microchip.mplab.nbide.embedded.arduino.utils.CopyingFileVisitor;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
getMakefileContents().add( "\t" + boardConfiguration.getValue("recipe.ar.pattern", runtimeData).get() );
});
}
@Override
protected String mapSourceFilePath(Path sourceFilePath) {
if ( sourceDir != null ) {
return sourceFilePath.getFileName().toString();
} else {
return super.mapSourceFilePath(sourceFilePath);
}
}
@Override
protected String buildIncludesSection( BoardConfiguration boardConfiguration ) {
if ( sourceDir != null ) {
// StringBuilder ret = new StringBuilder();
// ret.append(" \"-I").append(sourceDir.toString()).append("\"");
// return ret.toString();
return "-I.";
} else {
return super.buildIncludesSection(boardConfiguration);
}
}
//*************************************************
//*************** PRIVATE METHODS *****************
//*************************************************
private void copySourceFiles() throws IOException { | Files.walkFileTree(sourceDir, new CopyingFileVisitor(sourceDir, buildDirPath)); |
chipKIT32/chipKIT-importer | src/com/microchip/mplab/nbide/embedded/arduino/importer/ArduinoBuilderRunner.java | // Path: src/com/microchip/mplab/nbide/embedded/arduino/utils/DeletingFileVisitor.java
// public class DeletingFileVisitor extends SimpleFileVisitor<Path> {
//
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// Files.delete(file);
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// Files.delete(dir);
// return FileVisitResult.CONTINUE;
// }
//
// }
//
// Path: src/com/microchip/mplab/nbide/embedded/arduino/importer/NativeProcessRunner.java
// public static final int NO_ERROR_CODE = 0;
| import com.microchip.mplab.nbide.embedded.api.LanguageTool;
import com.microchip.mplab.nbide.embedded.arduino.utils.DeletingFileVisitor;
import static com.microchip.mplab.nbide.embedded.arduino.importer.NativeProcessRunner.NO_ERROR_CODE;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.FileVisitResult;
import static java.nio.file.FileVisitResult.CONTINUE;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import jdk.nashorn.api.scripting.ScriptObjectMirror; | }
public ArduinoConfig getArduinoPathResolver() {
return arduinoConfig;
}
public GCCToolFinder getToolFinder() {
return toolFinder;
}
public void preprocess(BoardConfiguration boardConfiguration, Path inoFilePath) {
Path tempDirPath = null;
try {
tempDirPath = Files.createTempDirectory("preprocess");
} catch (IOException ex) {
throw new RuntimeException(ex);
}
preprocess(boardConfiguration, inoFilePath, tempDirPath);
}
public void preprocess(BoardConfiguration boardConfiguration, Path inoFilePath, Path preprocessDirPath) {
try {
this.preprocessDirPath = preprocessDirPath;
if ( !Files.exists(preprocessDirPath) ) {
Files.createDirectories(preprocessDirPath);
}
// Run Arduino-Builder
int errorCode = runArduinoBuilder(boardConfiguration, inoFilePath);
| // Path: src/com/microchip/mplab/nbide/embedded/arduino/utils/DeletingFileVisitor.java
// public class DeletingFileVisitor extends SimpleFileVisitor<Path> {
//
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// Files.delete(file);
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// Files.delete(dir);
// return FileVisitResult.CONTINUE;
// }
//
// }
//
// Path: src/com/microchip/mplab/nbide/embedded/arduino/importer/NativeProcessRunner.java
// public static final int NO_ERROR_CODE = 0;
// Path: src/com/microchip/mplab/nbide/embedded/arduino/importer/ArduinoBuilderRunner.java
import com.microchip.mplab.nbide.embedded.api.LanguageTool;
import com.microchip.mplab.nbide.embedded.arduino.utils.DeletingFileVisitor;
import static com.microchip.mplab.nbide.embedded.arduino.importer.NativeProcessRunner.NO_ERROR_CODE;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.FileVisitResult;
import static java.nio.file.FileVisitResult.CONTINUE;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import jdk.nashorn.api.scripting.ScriptObjectMirror;
}
public ArduinoConfig getArduinoPathResolver() {
return arduinoConfig;
}
public GCCToolFinder getToolFinder() {
return toolFinder;
}
public void preprocess(BoardConfiguration boardConfiguration, Path inoFilePath) {
Path tempDirPath = null;
try {
tempDirPath = Files.createTempDirectory("preprocess");
} catch (IOException ex) {
throw new RuntimeException(ex);
}
preprocess(boardConfiguration, inoFilePath, tempDirPath);
}
public void preprocess(BoardConfiguration boardConfiguration, Path inoFilePath, Path preprocessDirPath) {
try {
this.preprocessDirPath = preprocessDirPath;
if ( !Files.exists(preprocessDirPath) ) {
Files.createDirectories(preprocessDirPath);
}
// Run Arduino-Builder
int errorCode = runArduinoBuilder(boardConfiguration, inoFilePath);
| if (errorCode == NO_ERROR_CODE) { |
chipKIT32/chipKIT-importer | src/com/microchip/mplab/nbide/embedded/arduino/importer/ArduinoBuilderRunner.java | // Path: src/com/microchip/mplab/nbide/embedded/arduino/utils/DeletingFileVisitor.java
// public class DeletingFileVisitor extends SimpleFileVisitor<Path> {
//
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// Files.delete(file);
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// Files.delete(dir);
// return FileVisitResult.CONTINUE;
// }
//
// }
//
// Path: src/com/microchip/mplab/nbide/embedded/arduino/importer/NativeProcessRunner.java
// public static final int NO_ERROR_CODE = 0;
| import com.microchip.mplab.nbide.embedded.api.LanguageTool;
import com.microchip.mplab.nbide.embedded.arduino.utils.DeletingFileVisitor;
import static com.microchip.mplab.nbide.embedded.arduino.importer.NativeProcessRunner.NO_ERROR_CODE;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.FileVisitResult;
import static java.nio.file.FileVisitResult.CONTINUE;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import jdk.nashorn.api.scripting.ScriptObjectMirror; | }
}
public List<Path> getMainLibraryPaths() {
return new ArrayList<>(mainLibraryPaths);
}
public List<Path> getAuxLibraryPaths() {
return new ArrayList<>(auxLibraryPaths);
}
public List<Path> getAllLibraryPaths() {
List <Path> ret = new ArrayList<>(mainLibraryPaths);
ret.addAll(auxLibraryPaths);
return ret;
}
public String getCommand() {
return nativeProcessRunner.getNativeProcessCommandString();
}
public Path getPreprocessDirPath() {
return preprocessDirPath;
}
public Path getPreprocessedSketchDirPath() {
return preprocessDirPath.resolve("sketch");
}
public void cleanup() throws IOException { | // Path: src/com/microchip/mplab/nbide/embedded/arduino/utils/DeletingFileVisitor.java
// public class DeletingFileVisitor extends SimpleFileVisitor<Path> {
//
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// Files.delete(file);
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// Files.delete(dir);
// return FileVisitResult.CONTINUE;
// }
//
// }
//
// Path: src/com/microchip/mplab/nbide/embedded/arduino/importer/NativeProcessRunner.java
// public static final int NO_ERROR_CODE = 0;
// Path: src/com/microchip/mplab/nbide/embedded/arduino/importer/ArduinoBuilderRunner.java
import com.microchip.mplab.nbide.embedded.api.LanguageTool;
import com.microchip.mplab.nbide.embedded.arduino.utils.DeletingFileVisitor;
import static com.microchip.mplab.nbide.embedded.arduino.importer.NativeProcessRunner.NO_ERROR_CODE;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.FileVisitResult;
import static java.nio.file.FileVisitResult.CONTINUE;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import jdk.nashorn.api.scripting.ScriptObjectMirror;
}
}
public List<Path> getMainLibraryPaths() {
return new ArrayList<>(mainLibraryPaths);
}
public List<Path> getAuxLibraryPaths() {
return new ArrayList<>(auxLibraryPaths);
}
public List<Path> getAllLibraryPaths() {
List <Path> ret = new ArrayList<>(mainLibraryPaths);
ret.addAll(auxLibraryPaths);
return ret;
}
public String getCommand() {
return nativeProcessRunner.getNativeProcessCommandString();
}
public Path getPreprocessDirPath() {
return preprocessDirPath;
}
public Path getPreprocessedSketchDirPath() {
return preprocessDirPath.resolve("sketch");
}
public void cleanup() throws IOException { | Files.walkFileTree(preprocessDirPath, new DeletingFileVisitor()); |
tingley/tm3 | src/main/java/com/globalsight/ling/tm3/core/AllTusDataHandle.java | // Path: src/main/java/com/globalsight/ling/tm3/core/AbstractDataHandle.java
// abstract class TuIterator implements Iterator<TM3Tu<T>> {
//
// protected Iterator<TM3Tu<T>> currentPage;
// protected long startId = 0;
//
// @Override
// public boolean hasNext() {
// if (currentPage != null && currentPage.hasNext()) {
// return true;
// }
// loadPage();
// return (currentPage != null && currentPage.hasNext());
// }
//
// /**
// * Subclasses must implement this. This method should
// * either set the currentPage member to an iterator to
// * the next page or results, or else set it to null
// * (indicating completion.)
// */
// protected abstract void loadPage();
//
// @Override
// public TM3Tu<T> next() {
// if (hasNext()) {
// return currentPage.next();
// }
// return null;
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
// }
| import java.sql.SQLException;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import com.globalsight.ling.tm3.core.AbstractDataHandle.TuIterator; | } catch (SQLException e) {
throw new TM3Exception(e);
}
}
@Override
public long getTuvCount() throws TM3Exception {
try {
return getTm().getStorageInfo().getTuStorage()
.getTuvCount(getStart(), getEnd());
} catch (SQLException e) {
throw new TM3Exception(e);
}
}
@Override
public void purgeData() throws TM3Exception {
try {
getTm().getStorageInfo().getTuStorage()
.deleteTus(getStart(), getEnd());
} catch (SQLException e) {
throw new TM3Exception(e);
}
}
@Override
public Iterator<TM3Tu<T>> iterator() throws TM3Exception {
return new AllTusIterator();
}
| // Path: src/main/java/com/globalsight/ling/tm3/core/AbstractDataHandle.java
// abstract class TuIterator implements Iterator<TM3Tu<T>> {
//
// protected Iterator<TM3Tu<T>> currentPage;
// protected long startId = 0;
//
// @Override
// public boolean hasNext() {
// if (currentPage != null && currentPage.hasNext()) {
// return true;
// }
// loadPage();
// return (currentPage != null && currentPage.hasNext());
// }
//
// /**
// * Subclasses must implement this. This method should
// * either set the currentPage member to an iterator to
// * the next page or results, or else set it to null
// * (indicating completion.)
// */
// protected abstract void loadPage();
//
// @Override
// public TM3Tu<T> next() {
// if (hasNext()) {
// return currentPage.next();
// }
// return null;
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
// }
// Path: src/main/java/com/globalsight/ling/tm3/core/AllTusDataHandle.java
import java.sql.SQLException;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import com.globalsight.ling.tm3.core.AbstractDataHandle.TuIterator;
} catch (SQLException e) {
throw new TM3Exception(e);
}
}
@Override
public long getTuvCount() throws TM3Exception {
try {
return getTm().getStorageInfo().getTuStorage()
.getTuvCount(getStart(), getEnd());
} catch (SQLException e) {
throw new TM3Exception(e);
}
}
@Override
public void purgeData() throws TM3Exception {
try {
getTm().getStorageInfo().getTuStorage()
.deleteTus(getStart(), getEnd());
} catch (SQLException e) {
throw new TM3Exception(e);
}
}
@Override
public Iterator<TM3Tu<T>> iterator() throws TM3Exception {
return new AllTusIterator();
}
| class AllTusIterator extends AbstractDataHandle<T>.TuIterator { |
tingley/tm3 | src/test/java/com/globalsight/ling/tm3/core/TM3Tests.java | // Path: src/main/java/com/globalsight/ling/tm3/core/persistence/HibernateConfig.java
// public class HibernateConfig {
//
// public static SessionFactory createSessionFactory(Properties properties) {
// Configuration cfg = extendConfiguration(new Configuration())
// .addProperties(properties);
// return cfg.buildSessionFactory();
// }
//
// public static Configuration extendConfiguration(Configuration config) {
// return config
// .addResource("com/globalsight/ling/tm3/core/persistence/xml/BaseTm.hbm.xml")
// .addResource("com/globalsight/ling/tm3/core/persistence/xml/TM3Attribute.hbm.xml")
// .addResource("com/globalsight/ling/tm3/core/persistence/xml/TM3Event.hbm.xml");
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.HashSet;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.junit.After;
import org.junit.Test;
import com.globalsight.ling.tm3.core.persistence.HibernateConfig; | }
catch (Exception e) {
currentTransaction.rollback();
throw e;
}
}
// when it's safe to assume at most one tuv per locale
private static <T extends TM3Data> TM3Tuv<T> getLocaleTuv(TM3Tu<T> tu, TM3Locale locale) {
List<TM3Tuv<T>> tuvs = tu.getLocaleTuvs(locale);
if (tuvs.size() == 0) {
return null;
} else if (tuvs.size() == 1) {
return tuvs.get(0);
} else {
throw new RuntimeException("unexpected multiple target tuvs");
}
}
public static SessionFactory setupHibernate() {
long start = System.currentTimeMillis();
Properties props = new Properties();
try {
props.load(TM3Tests.class.getResourceAsStream("/test.properties"));
}
catch (IOException e) {
throw new RuntimeException(e);
}
Configuration cfg = new Configuration().addProperties(props); | // Path: src/main/java/com/globalsight/ling/tm3/core/persistence/HibernateConfig.java
// public class HibernateConfig {
//
// public static SessionFactory createSessionFactory(Properties properties) {
// Configuration cfg = extendConfiguration(new Configuration())
// .addProperties(properties);
// return cfg.buildSessionFactory();
// }
//
// public static Configuration extendConfiguration(Configuration config) {
// return config
// .addResource("com/globalsight/ling/tm3/core/persistence/xml/BaseTm.hbm.xml")
// .addResource("com/globalsight/ling/tm3/core/persistence/xml/TM3Attribute.hbm.xml")
// .addResource("com/globalsight/ling/tm3/core/persistence/xml/TM3Event.hbm.xml");
// }
// }
// Path: src/test/java/com/globalsight/ling/tm3/core/TM3Tests.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.HashSet;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.junit.After;
import org.junit.Test;
import com.globalsight.ling.tm3.core.persistence.HibernateConfig;
}
catch (Exception e) {
currentTransaction.rollback();
throw e;
}
}
// when it's safe to assume at most one tuv per locale
private static <T extends TM3Data> TM3Tuv<T> getLocaleTuv(TM3Tu<T> tu, TM3Locale locale) {
List<TM3Tuv<T>> tuvs = tu.getLocaleTuvs(locale);
if (tuvs.size() == 0) {
return null;
} else if (tuvs.size() == 1) {
return tuvs.get(0);
} else {
throw new RuntimeException("unexpected multiple target tuvs");
}
}
public static SessionFactory setupHibernate() {
long start = System.currentTimeMillis();
Properties props = new Properties();
try {
props.load(TM3Tests.class.getResourceAsStream("/test.properties"));
}
catch (IOException e) {
throw new RuntimeException(e);
}
Configuration cfg = new Configuration().addProperties(props); | cfg = HibernateConfig.extendConfiguration(cfg); |
tingley/tm3 | src/main/java/com/globalsight/ling/tm3/core/Trigrammer.java | // Path: src/main/java/com/globalsight/ling/tm3/core/TM3Data.java
// public interface TM3Data {
//
// /**
// * Return the data as a stream of tokens. The fuzzy matching system
// * will bracket this stream with boundary tokens indicating the start
// * and end of the segment.
// *
// * @return {@link Iterable} capable of producing the token stream
// */
// public Iterable<Long> tokenize();
//
// /**
// * Compute and return the data's fingerprint.
// */
// public long getFingerprint();
//
// /**
// * Serialize this TUV data for storage. This form should be deserializable
// * by a corresponding {@link TM3DataFactory} implementation.
// */
// public String getSerializedForm();
//
// /**
// * Test object equality.
// * <p>"Equality" in this case may be as simple as a string compare,
// * or there may be more complicated logical comparisons going on.
// * <b>Warning:</b> Implementations <b>must</b> override <tt>equals()</tt>
// * or else run the risk of duplicate target TUVs being persisted in the
// * database.
// * @param o object to test for equality
// * @return true if the objects are equal; false otherwise
// */
// @Override
// public boolean equals(Object o);
// }
| import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.globalsight.ling.tm3.core.TM3Data; | package com.globalsight.ling.tm3.core;
class Trigrammer {
// Start/end of segment boundary
private static final Long BOUNDARY = -1l;
static class Trigram {
long[] fingerprints;
public Trigram(Long fp0, Long fp1, Long fp2) {
fingerprints = new long[3];
fingerprints[0] = fp0.longValue();
fingerprints[1] = fp1.longValue();
fingerprints[2] = fp2.longValue();
}
public String toString() {
return Arrays.toString(fingerprints);
}
public Long getValue() {
return fingerprints[0] + 31 *
(fingerprints[1] + 31 * fingerprints[2]);
}
}
Trigrammer() {
}
// Like everything else, this is a slapdash affair. There's lots of
// normalization I would normally use. | // Path: src/main/java/com/globalsight/ling/tm3/core/TM3Data.java
// public interface TM3Data {
//
// /**
// * Return the data as a stream of tokens. The fuzzy matching system
// * will bracket this stream with boundary tokens indicating the start
// * and end of the segment.
// *
// * @return {@link Iterable} capable of producing the token stream
// */
// public Iterable<Long> tokenize();
//
// /**
// * Compute and return the data's fingerprint.
// */
// public long getFingerprint();
//
// /**
// * Serialize this TUV data for storage. This form should be deserializable
// * by a corresponding {@link TM3DataFactory} implementation.
// */
// public String getSerializedForm();
//
// /**
// * Test object equality.
// * <p>"Equality" in this case may be as simple as a string compare,
// * or there may be more complicated logical comparisons going on.
// * <b>Warning:</b> Implementations <b>must</b> override <tt>equals()</tt>
// * or else run the risk of duplicate target TUVs being persisted in the
// * database.
// * @param o object to test for equality
// * @return true if the objects are equal; false otherwise
// */
// @Override
// public boolean equals(Object o);
// }
// Path: src/main/java/com/globalsight/ling/tm3/core/Trigrammer.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.globalsight.ling.tm3.core.TM3Data;
package com.globalsight.ling.tm3.core;
class Trigrammer {
// Start/end of segment boundary
private static final Long BOUNDARY = -1l;
static class Trigram {
long[] fingerprints;
public Trigram(Long fp0, Long fp1, Long fp2) {
fingerprints = new long[3];
fingerprints[0] = fp0.longValue();
fingerprints[1] = fp1.longValue();
fingerprints[2] = fp2.longValue();
}
public String toString() {
return Arrays.toString(fingerprints);
}
public Long getValue() {
return fingerprints[0] + 31 *
(fingerprints[1] + 31 * fingerprints[2]);
}
}
Trigrammer() {
}
// Like everything else, this is a slapdash affair. There's lots of
// normalization I would normally use. | List<Trigram> getTrigrams(TM3Data data) { |
tingley/tm3 | src/main/java/com/globalsight/ling/tm3/core/persistence/DistributedId.java | // Path: src/main/java/com/globalsight/ling/tm3/core/TM3Exception.java
// public class TM3Exception extends RuntimeException {
// public TM3Exception(String s) {
// super(s);
// }
//
// public TM3Exception(String string, Throwable root) {
// super(string, root);
// }
//
// public TM3Exception(Throwable root) {
// super(root);
// }
// }
//
// Path: src/main/java/com/globalsight/ling/tm3/core/persistence/StatementBuilder.java
// public class StatementBuilder extends AbstractStatementBuilder {
// private List<Object> args = new ArrayList<Object>();
//
// public StatementBuilder() {
// super();
// }
//
// public StatementBuilder(CharSequence s) {
// super(s);
// }
//
// public StatementBuilder(CharSequence s, Object...args) {
// super(s);
// addValues(args);
// }
//
// public StatementBuilder append(CharSequence s) {
// super.append(s);
// return this;
// }
//
// public StatementBuilder append(StatementBuilder builder) {
// super.append(builder.getBuffer());
// args.addAll(builder.args);
// return this;
// }
//
// public StatementBuilder addValue(Object o) {
// args.add(o);
// return this;
// }
//
// public StatementBuilder addValues(Object...os) {
// args.addAll(Arrays.asList(os));
// return this;
// }
//
// /**
// * Create a PreparedStatement with all attached values inserted.
// */
// public PreparedStatement toPreparedStatement(Connection conn)
// throws SQLException {
// PreparedStatement ps = conn.prepareStatement(getBuffer().toString());
// int index = 1;
// for (Object o : args) {
// ps.setObject(index++, o);
// }
// this.setStatement(ps);
// return ps;
// }
//
// @Override
// public String toString() {
// StringBuilder s = new StringBuilder();
// s.append("Statement[")
// .append(getBuffer())
// .append(", values=(");
// for (int i = 0; i < args.size(); i++) {
// if (i > 0) s.append(", ");
// s.append(args.get(i));
// }
// s.append(")]");
// return s.toString();
// }
// }
| import java.sql.ResultSet;
import java.sql.PreparedStatement;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import com.globalsight.ling.tm3.core.TM3Exception;
import com.globalsight.ling.tm3.core.persistence.StatementBuilder; | package com.globalsight.ling.tm3.core.persistence;
/**
* This class should not be public; I need to fix the test setup.
*
* Note that instances of this class are not themselves threadsafe.
*/
public class DistributedId {
private String tableName;
private long nextId = 0;
private long max = 0;
private int increment = 100;
public DistributedId(String tableName) {
this.tableName = tableName;
}
public DistributedId(String tableName, int increment) {
this.tableName = tableName;
this.increment = increment;
}
public long getId(Connection conn) throws SQLException {
if (nextId >= max) {
nextId = reserveId(conn, increment);
max = nextId + increment;
}
return nextId++;
}
public void destroy(Connection conn) throws SQLException { | // Path: src/main/java/com/globalsight/ling/tm3/core/TM3Exception.java
// public class TM3Exception extends RuntimeException {
// public TM3Exception(String s) {
// super(s);
// }
//
// public TM3Exception(String string, Throwable root) {
// super(string, root);
// }
//
// public TM3Exception(Throwable root) {
// super(root);
// }
// }
//
// Path: src/main/java/com/globalsight/ling/tm3/core/persistence/StatementBuilder.java
// public class StatementBuilder extends AbstractStatementBuilder {
// private List<Object> args = new ArrayList<Object>();
//
// public StatementBuilder() {
// super();
// }
//
// public StatementBuilder(CharSequence s) {
// super(s);
// }
//
// public StatementBuilder(CharSequence s, Object...args) {
// super(s);
// addValues(args);
// }
//
// public StatementBuilder append(CharSequence s) {
// super.append(s);
// return this;
// }
//
// public StatementBuilder append(StatementBuilder builder) {
// super.append(builder.getBuffer());
// args.addAll(builder.args);
// return this;
// }
//
// public StatementBuilder addValue(Object o) {
// args.add(o);
// return this;
// }
//
// public StatementBuilder addValues(Object...os) {
// args.addAll(Arrays.asList(os));
// return this;
// }
//
// /**
// * Create a PreparedStatement with all attached values inserted.
// */
// public PreparedStatement toPreparedStatement(Connection conn)
// throws SQLException {
// PreparedStatement ps = conn.prepareStatement(getBuffer().toString());
// int index = 1;
// for (Object o : args) {
// ps.setObject(index++, o);
// }
// this.setStatement(ps);
// return ps;
// }
//
// @Override
// public String toString() {
// StringBuilder s = new StringBuilder();
// s.append("Statement[")
// .append(getBuffer())
// .append(", values=(");
// for (int i = 0; i < args.size(); i++) {
// if (i > 0) s.append(", ");
// s.append(args.get(i));
// }
// s.append(")]");
// return s.toString();
// }
// }
// Path: src/main/java/com/globalsight/ling/tm3/core/persistence/DistributedId.java
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import com.globalsight.ling.tm3.core.TM3Exception;
import com.globalsight.ling.tm3.core.persistence.StatementBuilder;
package com.globalsight.ling.tm3.core.persistence;
/**
* This class should not be public; I need to fix the test setup.
*
* Note that instances of this class are not themselves threadsafe.
*/
public class DistributedId {
private String tableName;
private long nextId = 0;
private long max = 0;
private int increment = 100;
public DistributedId(String tableName) {
this.tableName = tableName;
}
public DistributedId(String tableName, int increment) {
this.tableName = tableName;
this.increment = increment;
}
public long getId(Connection conn) throws SQLException {
if (nextId >= max) {
nextId = reserveId(conn, increment);
max = nextId + increment;
}
return nextId++;
}
public void destroy(Connection conn) throws SQLException { | SQLUtil.exec(conn, new StatementBuilder() |
tingley/tm3 | src/main/java/com/globalsight/ling/tm3/core/StorageInfo.java | // Path: src/main/java/com/globalsight/ling/tm3/core/persistence/DistributedId.java
// public class DistributedId {
//
// private String tableName;
// private long nextId = 0;
// private long max = 0;
// private int increment = 100;
//
// public DistributedId(String tableName) {
// this.tableName = tableName;
// }
//
// public DistributedId(String tableName, int increment) {
// this.tableName = tableName;
// this.increment = increment;
// }
//
// public long getId(Connection conn) throws SQLException {
// if (nextId >= max) {
// nextId = reserveId(conn, increment);
// max = nextId + increment;
// }
// return nextId++;
// }
//
// public void destroy(Connection conn) throws SQLException {
// SQLUtil.exec(conn, new StatementBuilder()
// .append("delete from TM3_ID where tableName = ?")
// .addValue(tableName));
// }
//
// /**
// * Reserve a set of |count| ids.
// * @param conn
// * @param count
// * @return
// * @throws SQLException
// */
// private long reserveId(Connection conn, int count) throws SQLException {
// // The magic to why this query works is the use of LAST_INSERT_ID(expr), which
// // will set the scoped LAST_INSERT_ID value to be the value of 'expr',
// // prior to updating it.
// SQLUtil.exec(conn, new StatementBuilder()
// .append("INSERT INTO TM3_ID (tableName, nextId) VALUES (?, LAST_INSERT_ID(1)+?)")
// .addValues(tableName, count)
// .append(" ON DUPLICATE KEY UPDATE nextId=LAST_INSERT_ID(nextId)+?")
// .addValue(count)
// );
//
// return SQLUtil.getLastInsertId(conn);
// }
// }
//
// Path: src/main/java/com/globalsight/ling/tm3/core/persistence/StatementBuilder.java
// public class StatementBuilder extends AbstractStatementBuilder {
// private List<Object> args = new ArrayList<Object>();
//
// public StatementBuilder() {
// super();
// }
//
// public StatementBuilder(CharSequence s) {
// super(s);
// }
//
// public StatementBuilder(CharSequence s, Object...args) {
// super(s);
// addValues(args);
// }
//
// public StatementBuilder append(CharSequence s) {
// super.append(s);
// return this;
// }
//
// public StatementBuilder append(StatementBuilder builder) {
// super.append(builder.getBuffer());
// args.addAll(builder.args);
// return this;
// }
//
// public StatementBuilder addValue(Object o) {
// args.add(o);
// return this;
// }
//
// public StatementBuilder addValues(Object...os) {
// args.addAll(Arrays.asList(os));
// return this;
// }
//
// /**
// * Create a PreparedStatement with all attached values inserted.
// */
// public PreparedStatement toPreparedStatement(Connection conn)
// throws SQLException {
// PreparedStatement ps = conn.prepareStatement(getBuffer().toString());
// int index = 1;
// for (Object o : args) {
// ps.setObject(index++, o);
// }
// this.setStatement(ps);
// return ps;
// }
//
// @Override
// public String toString() {
// StringBuilder s = new StringBuilder();
// s.append("Statement[")
// .append(getBuffer())
// .append(", values=(");
// for (int i = 0; i < args.size(); i++) {
// if (i > 0) s.append(", ");
// s.append(args.get(i));
// }
// s.append(")]");
// return s.toString();
// }
// }
| import java.sql.Connection;
import java.sql.SQLException;
import java.util.Set;
import java.util.HashSet;
import java.util.Map;
import org.hibernate.Session;
import com.globalsight.ling.tm3.core.persistence.DistributedId;
import com.globalsight.ling.tm3.core.persistence.StatementBuilder; | package com.globalsight.ling.tm3.core;
/**
* Class that manages the table space for a given TM.
* Since different TM types may have different underlying
* table structures, we must abstract the table access through
* some intermediate mechanism.
*
* The TM3StorageInfo object is used to both create and access
* the tables for a given TM.
*/
abstract class StorageInfo<T extends TM3Data> {
private TM3TmType type;
private long id;
private BaseTm<T> tm;
private Session session;
private Set<TM3Attribute> inlineAttributes = new HashSet<TM3Attribute>(); | // Path: src/main/java/com/globalsight/ling/tm3/core/persistence/DistributedId.java
// public class DistributedId {
//
// private String tableName;
// private long nextId = 0;
// private long max = 0;
// private int increment = 100;
//
// public DistributedId(String tableName) {
// this.tableName = tableName;
// }
//
// public DistributedId(String tableName, int increment) {
// this.tableName = tableName;
// this.increment = increment;
// }
//
// public long getId(Connection conn) throws SQLException {
// if (nextId >= max) {
// nextId = reserveId(conn, increment);
// max = nextId + increment;
// }
// return nextId++;
// }
//
// public void destroy(Connection conn) throws SQLException {
// SQLUtil.exec(conn, new StatementBuilder()
// .append("delete from TM3_ID where tableName = ?")
// .addValue(tableName));
// }
//
// /**
// * Reserve a set of |count| ids.
// * @param conn
// * @param count
// * @return
// * @throws SQLException
// */
// private long reserveId(Connection conn, int count) throws SQLException {
// // The magic to why this query works is the use of LAST_INSERT_ID(expr), which
// // will set the scoped LAST_INSERT_ID value to be the value of 'expr',
// // prior to updating it.
// SQLUtil.exec(conn, new StatementBuilder()
// .append("INSERT INTO TM3_ID (tableName, nextId) VALUES (?, LAST_INSERT_ID(1)+?)")
// .addValues(tableName, count)
// .append(" ON DUPLICATE KEY UPDATE nextId=LAST_INSERT_ID(nextId)+?")
// .addValue(count)
// );
//
// return SQLUtil.getLastInsertId(conn);
// }
// }
//
// Path: src/main/java/com/globalsight/ling/tm3/core/persistence/StatementBuilder.java
// public class StatementBuilder extends AbstractStatementBuilder {
// private List<Object> args = new ArrayList<Object>();
//
// public StatementBuilder() {
// super();
// }
//
// public StatementBuilder(CharSequence s) {
// super(s);
// }
//
// public StatementBuilder(CharSequence s, Object...args) {
// super(s);
// addValues(args);
// }
//
// public StatementBuilder append(CharSequence s) {
// super.append(s);
// return this;
// }
//
// public StatementBuilder append(StatementBuilder builder) {
// super.append(builder.getBuffer());
// args.addAll(builder.args);
// return this;
// }
//
// public StatementBuilder addValue(Object o) {
// args.add(o);
// return this;
// }
//
// public StatementBuilder addValues(Object...os) {
// args.addAll(Arrays.asList(os));
// return this;
// }
//
// /**
// * Create a PreparedStatement with all attached values inserted.
// */
// public PreparedStatement toPreparedStatement(Connection conn)
// throws SQLException {
// PreparedStatement ps = conn.prepareStatement(getBuffer().toString());
// int index = 1;
// for (Object o : args) {
// ps.setObject(index++, o);
// }
// this.setStatement(ps);
// return ps;
// }
//
// @Override
// public String toString() {
// StringBuilder s = new StringBuilder();
// s.append("Statement[")
// .append(getBuffer())
// .append(", values=(");
// for (int i = 0; i < args.size(); i++) {
// if (i > 0) s.append(", ");
// s.append(args.get(i));
// }
// s.append(")]");
// return s.toString();
// }
// }
// Path: src/main/java/com/globalsight/ling/tm3/core/StorageInfo.java
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Set;
import java.util.HashSet;
import java.util.Map;
import org.hibernate.Session;
import com.globalsight.ling.tm3.core.persistence.DistributedId;
import com.globalsight.ling.tm3.core.persistence.StatementBuilder;
package com.globalsight.ling.tm3.core;
/**
* Class that manages the table space for a given TM.
* Since different TM types may have different underlying
* table structures, we must abstract the table access through
* some intermediate mechanism.
*
* The TM3StorageInfo object is used to both create and access
* the tables for a given TM.
*/
abstract class StorageInfo<T extends TM3Data> {
private TM3TmType type;
private long id;
private BaseTm<T> tm;
private Session session;
private Set<TM3Attribute> inlineAttributes = new HashSet<TM3Attribute>(); | private DistributedId tuIds, tuvIds; |
tingley/tm3 | src/main/java/com/globalsight/ling/tm3/core/StorageInfo.java | // Path: src/main/java/com/globalsight/ling/tm3/core/persistence/DistributedId.java
// public class DistributedId {
//
// private String tableName;
// private long nextId = 0;
// private long max = 0;
// private int increment = 100;
//
// public DistributedId(String tableName) {
// this.tableName = tableName;
// }
//
// public DistributedId(String tableName, int increment) {
// this.tableName = tableName;
// this.increment = increment;
// }
//
// public long getId(Connection conn) throws SQLException {
// if (nextId >= max) {
// nextId = reserveId(conn, increment);
// max = nextId + increment;
// }
// return nextId++;
// }
//
// public void destroy(Connection conn) throws SQLException {
// SQLUtil.exec(conn, new StatementBuilder()
// .append("delete from TM3_ID where tableName = ?")
// .addValue(tableName));
// }
//
// /**
// * Reserve a set of |count| ids.
// * @param conn
// * @param count
// * @return
// * @throws SQLException
// */
// private long reserveId(Connection conn, int count) throws SQLException {
// // The magic to why this query works is the use of LAST_INSERT_ID(expr), which
// // will set the scoped LAST_INSERT_ID value to be the value of 'expr',
// // prior to updating it.
// SQLUtil.exec(conn, new StatementBuilder()
// .append("INSERT INTO TM3_ID (tableName, nextId) VALUES (?, LAST_INSERT_ID(1)+?)")
// .addValues(tableName, count)
// .append(" ON DUPLICATE KEY UPDATE nextId=LAST_INSERT_ID(nextId)+?")
// .addValue(count)
// );
//
// return SQLUtil.getLastInsertId(conn);
// }
// }
//
// Path: src/main/java/com/globalsight/ling/tm3/core/persistence/StatementBuilder.java
// public class StatementBuilder extends AbstractStatementBuilder {
// private List<Object> args = new ArrayList<Object>();
//
// public StatementBuilder() {
// super();
// }
//
// public StatementBuilder(CharSequence s) {
// super(s);
// }
//
// public StatementBuilder(CharSequence s, Object...args) {
// super(s);
// addValues(args);
// }
//
// public StatementBuilder append(CharSequence s) {
// super.append(s);
// return this;
// }
//
// public StatementBuilder append(StatementBuilder builder) {
// super.append(builder.getBuffer());
// args.addAll(builder.args);
// return this;
// }
//
// public StatementBuilder addValue(Object o) {
// args.add(o);
// return this;
// }
//
// public StatementBuilder addValues(Object...os) {
// args.addAll(Arrays.asList(os));
// return this;
// }
//
// /**
// * Create a PreparedStatement with all attached values inserted.
// */
// public PreparedStatement toPreparedStatement(Connection conn)
// throws SQLException {
// PreparedStatement ps = conn.prepareStatement(getBuffer().toString());
// int index = 1;
// for (Object o : args) {
// ps.setObject(index++, o);
// }
// this.setStatement(ps);
// return ps;
// }
//
// @Override
// public String toString() {
// StringBuilder s = new StringBuilder();
// s.append("Statement[")
// .append(getBuffer())
// .append(", values=(");
// for (int i = 0; i < args.size(); i++) {
// if (i > 0) s.append(", ");
// s.append(args.get(i));
// }
// s.append(")]");
// return s.toString();
// }
// }
| import java.sql.Connection;
import java.sql.SQLException;
import java.util.Set;
import java.util.HashSet;
import java.util.Map;
import org.hibernate.Session;
import com.globalsight.ling.tm3.core.persistence.DistributedId;
import com.globalsight.ling.tm3.core.persistence.StatementBuilder; | if (tuIds == null) {
tuIds = new DistributedId(getTuTableName());
}
return tuIds;
}
protected DistributedId getTuvIds() {
if (tuvIds == null) {
tuvIds = new DistributedId(getTuvTableName());
}
return tuvIds;
}
// XXX Should this use its own connection?
long getTuId(Connection conn) throws SQLException {
return getTuIds().getId(conn);
}
long getTuvId(Connection conn) throws SQLException {
return getTuvIds().getId(conn);
}
/**
* Add a set of INNER JOIN clauses to filter a statement
* by an arbitrary number of attributes.
* @param sb
* @param tuAlias alias of the TU table to join against
* @param attrs
* @return
*/ | // Path: src/main/java/com/globalsight/ling/tm3/core/persistence/DistributedId.java
// public class DistributedId {
//
// private String tableName;
// private long nextId = 0;
// private long max = 0;
// private int increment = 100;
//
// public DistributedId(String tableName) {
// this.tableName = tableName;
// }
//
// public DistributedId(String tableName, int increment) {
// this.tableName = tableName;
// this.increment = increment;
// }
//
// public long getId(Connection conn) throws SQLException {
// if (nextId >= max) {
// nextId = reserveId(conn, increment);
// max = nextId + increment;
// }
// return nextId++;
// }
//
// public void destroy(Connection conn) throws SQLException {
// SQLUtil.exec(conn, new StatementBuilder()
// .append("delete from TM3_ID where tableName = ?")
// .addValue(tableName));
// }
//
// /**
// * Reserve a set of |count| ids.
// * @param conn
// * @param count
// * @return
// * @throws SQLException
// */
// private long reserveId(Connection conn, int count) throws SQLException {
// // The magic to why this query works is the use of LAST_INSERT_ID(expr), which
// // will set the scoped LAST_INSERT_ID value to be the value of 'expr',
// // prior to updating it.
// SQLUtil.exec(conn, new StatementBuilder()
// .append("INSERT INTO TM3_ID (tableName, nextId) VALUES (?, LAST_INSERT_ID(1)+?)")
// .addValues(tableName, count)
// .append(" ON DUPLICATE KEY UPDATE nextId=LAST_INSERT_ID(nextId)+?")
// .addValue(count)
// );
//
// return SQLUtil.getLastInsertId(conn);
// }
// }
//
// Path: src/main/java/com/globalsight/ling/tm3/core/persistence/StatementBuilder.java
// public class StatementBuilder extends AbstractStatementBuilder {
// private List<Object> args = new ArrayList<Object>();
//
// public StatementBuilder() {
// super();
// }
//
// public StatementBuilder(CharSequence s) {
// super(s);
// }
//
// public StatementBuilder(CharSequence s, Object...args) {
// super(s);
// addValues(args);
// }
//
// public StatementBuilder append(CharSequence s) {
// super.append(s);
// return this;
// }
//
// public StatementBuilder append(StatementBuilder builder) {
// super.append(builder.getBuffer());
// args.addAll(builder.args);
// return this;
// }
//
// public StatementBuilder addValue(Object o) {
// args.add(o);
// return this;
// }
//
// public StatementBuilder addValues(Object...os) {
// args.addAll(Arrays.asList(os));
// return this;
// }
//
// /**
// * Create a PreparedStatement with all attached values inserted.
// */
// public PreparedStatement toPreparedStatement(Connection conn)
// throws SQLException {
// PreparedStatement ps = conn.prepareStatement(getBuffer().toString());
// int index = 1;
// for (Object o : args) {
// ps.setObject(index++, o);
// }
// this.setStatement(ps);
// return ps;
// }
//
// @Override
// public String toString() {
// StringBuilder s = new StringBuilder();
// s.append("Statement[")
// .append(getBuffer())
// .append(", values=(");
// for (int i = 0; i < args.size(); i++) {
// if (i > 0) s.append(", ");
// s.append(args.get(i));
// }
// s.append(")]");
// return s.toString();
// }
// }
// Path: src/main/java/com/globalsight/ling/tm3/core/StorageInfo.java
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Set;
import java.util.HashSet;
import java.util.Map;
import org.hibernate.Session;
import com.globalsight.ling.tm3.core.persistence.DistributedId;
import com.globalsight.ling.tm3.core.persistence.StatementBuilder;
if (tuIds == null) {
tuIds = new DistributedId(getTuTableName());
}
return tuIds;
}
protected DistributedId getTuvIds() {
if (tuvIds == null) {
tuvIds = new DistributedId(getTuvTableName());
}
return tuvIds;
}
// XXX Should this use its own connection?
long getTuId(Connection conn) throws SQLException {
return getTuIds().getId(conn);
}
long getTuvId(Connection conn) throws SQLException {
return getTuvIds().getId(conn);
}
/**
* Add a set of INNER JOIN clauses to filter a statement
* by an arbitrary number of attributes.
* @param sb
* @param tuAlias alias of the TU table to join against
* @param attrs
* @return
*/ | StatementBuilder attributeJoinFilter(StatementBuilder sb, |
tingley/tm3 | src/main/java/com/globalsight/ling/tm3/core/AttributeDataHandle.java | // Path: src/main/java/com/globalsight/ling/tm3/core/AbstractDataHandle.java
// abstract class TuIterator implements Iterator<TM3Tu<T>> {
//
// protected Iterator<TM3Tu<T>> currentPage;
// protected long startId = 0;
//
// @Override
// public boolean hasNext() {
// if (currentPage != null && currentPage.hasNext()) {
// return true;
// }
// loadPage();
// return (currentPage != null && currentPage.hasNext());
// }
//
// /**
// * Subclasses must implement this. This method should
// * either set the currentPage member to an iterator to
// * the next page or results, or else set it to null
// * (indicating completion.)
// */
// protected abstract void loadPage();
//
// @Override
// public TM3Tu<T> next() {
// if (hasNext()) {
// return currentPage.next();
// }
// return null;
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
// }
| import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Date;
import com.globalsight.ling.tm3.core.AbstractDataHandle.TuIterator; | return getTm().getStorageInfo().getTuStorage()
.getTuCountByAttributes(inlineAttrs, customAttrs,
getStart(), getEnd());
} catch (SQLException e) {
throw new TM3Exception(e);
}
}
@Override
public long getTuvCount() throws TM3Exception {
try {
return getTm().getStorageInfo().getTuStorage()
.getTuvCountByAttributes(inlineAttrs, customAttrs,
getStart(), getEnd());
} catch (SQLException e) {
throw new TM3Exception(e);
}
}
@Override
public Iterator<TM3Tu<T>> iterator() throws TM3Exception {
return new AttributesTuIterator();
}
@Override
public void purgeData() throws TM3Exception {
// Bailing on this one for now. GlobalSight never calls it.
throw new UnsupportedOperationException("Not yet implemented");
}
| // Path: src/main/java/com/globalsight/ling/tm3/core/AbstractDataHandle.java
// abstract class TuIterator implements Iterator<TM3Tu<T>> {
//
// protected Iterator<TM3Tu<T>> currentPage;
// protected long startId = 0;
//
// @Override
// public boolean hasNext() {
// if (currentPage != null && currentPage.hasNext()) {
// return true;
// }
// loadPage();
// return (currentPage != null && currentPage.hasNext());
// }
//
// /**
// * Subclasses must implement this. This method should
// * either set the currentPage member to an iterator to
// * the next page or results, or else set it to null
// * (indicating completion.)
// */
// protected abstract void loadPage();
//
// @Override
// public TM3Tu<T> next() {
// if (hasNext()) {
// return currentPage.next();
// }
// return null;
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
// }
// Path: src/main/java/com/globalsight/ling/tm3/core/AttributeDataHandle.java
import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Date;
import com.globalsight.ling.tm3.core.AbstractDataHandle.TuIterator;
return getTm().getStorageInfo().getTuStorage()
.getTuCountByAttributes(inlineAttrs, customAttrs,
getStart(), getEnd());
} catch (SQLException e) {
throw new TM3Exception(e);
}
}
@Override
public long getTuvCount() throws TM3Exception {
try {
return getTm().getStorageInfo().getTuStorage()
.getTuvCountByAttributes(inlineAttrs, customAttrs,
getStart(), getEnd());
} catch (SQLException e) {
throw new TM3Exception(e);
}
}
@Override
public Iterator<TM3Tu<T>> iterator() throws TM3Exception {
return new AttributesTuIterator();
}
@Override
public void purgeData() throws TM3Exception {
// Bailing on this one for now. GlobalSight never calls it.
throw new UnsupportedOperationException("Not yet implemented");
}
| class AttributesTuIterator extends TuIterator { |
gfk-ba/senbot | SenBotRunner/src/test/java/com/gfk/senbot/framework/cucumber/tests/CucumberTestBaseTest.java | // Path: SenBotRunner/src/main/java/com/gfk/senbot/framework/cucumber/CucumberTestBase.java
// public class CucumberTestBase {
//
// private static Logger log = LoggerFactory.getLogger(CucumberTestBase.class);
//
// /**
// * Ok, this is an ugly hack so our {@link ParameterizedCucumber} runner extending {@link Parameterized}
// * defined in the {@link RunWith} annotation will not complain about "No runnable methods"
// */
// @Test
// @Ignore
// public void test() {
// assertTrue(true);
// }
//
// /**
// * Detect if the test is {@link RunWith} annotated with typedef {@link ParameterizedCucumber}, if not, instantiate the {@link TestEnvironment}.
// *
// * @throws Exception
// */
// @BeforeClass
// public static void setUpTest() throws Exception {
//
// log.debug("@BeforeClass initiated");
//
// SeleniumManager seleniumManager = SenBotContext.getSenBotContext().getSeleniumManager();
// TestEnvironment associatedEnvironment = seleniumManager.getAssociatedTestEnvironment();
// if (associatedEnvironment == null) {
// TestEnvironment environment = seleniumManager.getSeleniumTestEnvironments().get(0);
// seleniumManager.associateTestEnvironment(environment);
// }
// }
//
// /**
// * Cleanup the SenBot instance
// * @throws Exception
// */
// @AfterClass
// public static void tearDown() throws Exception {
//
// SeleniumManager seleniumManager = SenBotContext.getSenBotContext().getSeleniumManager();
// if(seleniumManager.getAssociatedTestEnvironment() != null) {
// seleniumManager.deAssociateTestEnvironment();
// }
//
// SenBotContext.cleanupSenBot();
// }
//
// /**
// * Picks the browsers on which to run the tests
// */
// @Parameters
// public static List<Object[]> getParameters() throws IOException {
// SeleniumManager seleniumManager = SenBotContext.getSenBotContext().getSeleniumManager();
// final List<TestEnvironment> seleniumTestEnvironments = seleniumManager.getSeleniumTestEnvironments();
//
// List<Object[]> params = new ArrayList<Object[]>() {
//
// /**
// * By calling the underlying seleniumTestEnvironment.get(index) we make sure our
// * globally available test environment matches that of the one returned wrapped in the Object[]
// */
// @Override
// public Object[] get(int index) {
// seleniumTestEnvironments.get(index);
// return super.get(index);
// }
// };
//
// for (TestEnvironment env : seleniumTestEnvironments) {
// params.add(new Object[]{env});
// }
//
// return params;
// }
//
// }
| import org.junit.runner.RunWith;
import com.gfk.senbot.framework.cucumber.CucumberTestBase;
import cucumber.api.junit.Cucumber; | package com.gfk.senbot.framework.cucumber.tests;
@RunWith(Cucumber.class)
//@CucumberOptions
@Cucumber.Options(
format={"json", "json:target/test-results/result.json"},
monochrome = true,
glue = {"com.gfk"},
features = "src/test/resources/features",
tags = {"~@ignore", "~@to-implement", "~@random-failure", "~@broken"},
strict = true) | // Path: SenBotRunner/src/main/java/com/gfk/senbot/framework/cucumber/CucumberTestBase.java
// public class CucumberTestBase {
//
// private static Logger log = LoggerFactory.getLogger(CucumberTestBase.class);
//
// /**
// * Ok, this is an ugly hack so our {@link ParameterizedCucumber} runner extending {@link Parameterized}
// * defined in the {@link RunWith} annotation will not complain about "No runnable methods"
// */
// @Test
// @Ignore
// public void test() {
// assertTrue(true);
// }
//
// /**
// * Detect if the test is {@link RunWith} annotated with typedef {@link ParameterizedCucumber}, if not, instantiate the {@link TestEnvironment}.
// *
// * @throws Exception
// */
// @BeforeClass
// public static void setUpTest() throws Exception {
//
// log.debug("@BeforeClass initiated");
//
// SeleniumManager seleniumManager = SenBotContext.getSenBotContext().getSeleniumManager();
// TestEnvironment associatedEnvironment = seleniumManager.getAssociatedTestEnvironment();
// if (associatedEnvironment == null) {
// TestEnvironment environment = seleniumManager.getSeleniumTestEnvironments().get(0);
// seleniumManager.associateTestEnvironment(environment);
// }
// }
//
// /**
// * Cleanup the SenBot instance
// * @throws Exception
// */
// @AfterClass
// public static void tearDown() throws Exception {
//
// SeleniumManager seleniumManager = SenBotContext.getSenBotContext().getSeleniumManager();
// if(seleniumManager.getAssociatedTestEnvironment() != null) {
// seleniumManager.deAssociateTestEnvironment();
// }
//
// SenBotContext.cleanupSenBot();
// }
//
// /**
// * Picks the browsers on which to run the tests
// */
// @Parameters
// public static List<Object[]> getParameters() throws IOException {
// SeleniumManager seleniumManager = SenBotContext.getSenBotContext().getSeleniumManager();
// final List<TestEnvironment> seleniumTestEnvironments = seleniumManager.getSeleniumTestEnvironments();
//
// List<Object[]> params = new ArrayList<Object[]>() {
//
// /**
// * By calling the underlying seleniumTestEnvironment.get(index) we make sure our
// * globally available test environment matches that of the one returned wrapped in the Object[]
// */
// @Override
// public Object[] get(int index) {
// seleniumTestEnvironments.get(index);
// return super.get(index);
// }
// };
//
// for (TestEnvironment env : seleniumTestEnvironments) {
// params.add(new Object[]{env});
// }
//
// return params;
// }
//
// }
// Path: SenBotRunner/src/test/java/com/gfk/senbot/framework/cucumber/tests/CucumberTestBaseTest.java
import org.junit.runner.RunWith;
import com.gfk.senbot.framework.cucumber.CucumberTestBase;
import cucumber.api.junit.Cucumber;
package com.gfk.senbot.framework.cucumber.tests;
@RunWith(Cucumber.class)
//@CucumberOptions
@Cucumber.Options(
format={"json", "json:target/test-results/result.json"},
monochrome = true,
glue = {"com.gfk"},
features = "src/test/resources/features",
tags = {"~@ignore", "~@to-implement", "~@random-failure", "~@broken"},
strict = true) | public class CucumberTestBaseTest extends CucumberTestBase { |
gfk-ba/senbot | SenBotRunner/src/test/java/com/gfk/senbot/framework/context/MockScenarioCreationHook.java | // Path: SenBotRunner/src/main/java/com/gfk/senbot/framework/cucumber/stepdefinitions/ScenarioGlobals.java
// public class ScenarioGlobals {
//
// private static final Logger log = LoggerFactory.getLogger(ScenarioGlobals.class);
// private Map<String, Object> scenarioAttributes = new HashMap<String, Object>();
// private final Long scenarioStart;
// private TestEnvironment testEnvironment;
// private WebDriver driver = SenBotContext.getSeleniumDriver();
// private String namespace = null;
// private List<ExpectedGlobalCondition> expectedGlobalConditions = new ArrayList<ExpectedGlobalCondition>();
//
// /**
// * Constructor
// */
// public ScenarioGlobals() {
// scenarioStart = System.currentTimeMillis();
// }
//
// /**
// * A map containing all scenario attributes
// *
// * @param key The key
// * @param value The value
// */
// public void setAttribute(String key, Object value) {
// scenarioAttributes.put(key, value);
// }
//
// /**
// * @return A map containing all scenario attributes
// */
// public Object getAttribute(String key) {
// return scenarioAttributes.get(key);
// }
//
// /**
// * Stores the time of creation of this {@link ScenarioGlobals} object so that we can use it what services
// * are used during it's lifetime. For example used for checking if selenium is used or not.
// *
// * @return scenarioStart
// */
// public Long getScenarioStart() {
// return scenarioStart;
// }
//
// /**
// * Register loader with the {@link ScenarioGlobals} so the different Selenium services can wait for them to be removed
// * @param loaderIndicators
// */
// public void registerLoaderIndicators(By... loaderIndicators) {
// for(By locator : loaderIndicators) {
// log.debug("Registered loader: " + locator);
// this.expectedGlobalConditions.add(new ExpectedWebElementCondition(locator));
// }
// }
//
// /**
// * Clear loader with the {@link ScenarioGlobals} so the different Selenium services can wait for them to be removed
// */
// public void clearExpectedGlobalConditions() {
// this.expectedGlobalConditions.clear();
// }
//
// /**
// * @return The {@link TestEnvironment} this {@link Scenario} is running in
// */
// public TestEnvironment getTestEnvironment() {
// return testEnvironment;
// }
//
// /**
// * @param testEnvironment The {@link TestEnvironment} this {@link Scenario} is running in
// */
// public void setTestEnvironment(TestEnvironment testEnvironment) {
// this.testEnvironment = testEnvironment;
// }
//
// /**
// * @return a unique to this Scenario namespace string
// */
// public String getNameSpace() {
// if(namespace == null) {
// namespace = "SNS" + new Integer(UUID.randomUUID().hashCode()).toString() + "-";
// }
// return namespace;
// }
//
// public List<ExpectedGlobalCondition> getExpectedGlobalConditions() {
// return expectedGlobalConditions;
// }
//
// public void addExpectedGlobalConditions(
// ExpectedGlobalCondition expectedGlobalCondition) {
// expectedGlobalConditions.add(expectedGlobalCondition);
//
// }
//
// }
//
// Path: SenBotRunner/src/main/java/com/gfk/senbot/framework/cucumber/stepdefinitions/ScenarionCreationShutdownHook.java
// public interface ScenarionCreationShutdownHook {
//
// void scenarionStarted(ScenarioGlobals scenarioGlobals);
//
// void scenarionShutdown(ScenarioGlobals scenarioGlobals);
//
// }
| import com.gfk.senbot.framework.cucumber.stepdefinitions.ScenarioGlobals;
import com.gfk.senbot.framework.cucumber.stepdefinitions.ScenarionCreationShutdownHook; | package com.gfk.senbot.framework.context;
public class MockScenarioCreationHook implements ScenarionCreationShutdownHook {
public static final String STARTED_ATTRIBUTE_KEY = "STARTED_ATTRIBUTE_KEY";
public static final String STARTED_ATTRIBUTE_VALUE = "STARTED_ATTRIBUTE_VALUE";
public static final String STOPPED_ATTRIBUTE_KEY = "STOPPED_ATTRIBUTE_KEY";
public static final String STOPPED_ATTRIBUTE_VALUE = "STOPPED_ATTRIBUTE_VALUE";
| // Path: SenBotRunner/src/main/java/com/gfk/senbot/framework/cucumber/stepdefinitions/ScenarioGlobals.java
// public class ScenarioGlobals {
//
// private static final Logger log = LoggerFactory.getLogger(ScenarioGlobals.class);
// private Map<String, Object> scenarioAttributes = new HashMap<String, Object>();
// private final Long scenarioStart;
// private TestEnvironment testEnvironment;
// private WebDriver driver = SenBotContext.getSeleniumDriver();
// private String namespace = null;
// private List<ExpectedGlobalCondition> expectedGlobalConditions = new ArrayList<ExpectedGlobalCondition>();
//
// /**
// * Constructor
// */
// public ScenarioGlobals() {
// scenarioStart = System.currentTimeMillis();
// }
//
// /**
// * A map containing all scenario attributes
// *
// * @param key The key
// * @param value The value
// */
// public void setAttribute(String key, Object value) {
// scenarioAttributes.put(key, value);
// }
//
// /**
// * @return A map containing all scenario attributes
// */
// public Object getAttribute(String key) {
// return scenarioAttributes.get(key);
// }
//
// /**
// * Stores the time of creation of this {@link ScenarioGlobals} object so that we can use it what services
// * are used during it's lifetime. For example used for checking if selenium is used or not.
// *
// * @return scenarioStart
// */
// public Long getScenarioStart() {
// return scenarioStart;
// }
//
// /**
// * Register loader with the {@link ScenarioGlobals} so the different Selenium services can wait for them to be removed
// * @param loaderIndicators
// */
// public void registerLoaderIndicators(By... loaderIndicators) {
// for(By locator : loaderIndicators) {
// log.debug("Registered loader: " + locator);
// this.expectedGlobalConditions.add(new ExpectedWebElementCondition(locator));
// }
// }
//
// /**
// * Clear loader with the {@link ScenarioGlobals} so the different Selenium services can wait for them to be removed
// */
// public void clearExpectedGlobalConditions() {
// this.expectedGlobalConditions.clear();
// }
//
// /**
// * @return The {@link TestEnvironment} this {@link Scenario} is running in
// */
// public TestEnvironment getTestEnvironment() {
// return testEnvironment;
// }
//
// /**
// * @param testEnvironment The {@link TestEnvironment} this {@link Scenario} is running in
// */
// public void setTestEnvironment(TestEnvironment testEnvironment) {
// this.testEnvironment = testEnvironment;
// }
//
// /**
// * @return a unique to this Scenario namespace string
// */
// public String getNameSpace() {
// if(namespace == null) {
// namespace = "SNS" + new Integer(UUID.randomUUID().hashCode()).toString() + "-";
// }
// return namespace;
// }
//
// public List<ExpectedGlobalCondition> getExpectedGlobalConditions() {
// return expectedGlobalConditions;
// }
//
// public void addExpectedGlobalConditions(
// ExpectedGlobalCondition expectedGlobalCondition) {
// expectedGlobalConditions.add(expectedGlobalCondition);
//
// }
//
// }
//
// Path: SenBotRunner/src/main/java/com/gfk/senbot/framework/cucumber/stepdefinitions/ScenarionCreationShutdownHook.java
// public interface ScenarionCreationShutdownHook {
//
// void scenarionStarted(ScenarioGlobals scenarioGlobals);
//
// void scenarionShutdown(ScenarioGlobals scenarioGlobals);
//
// }
// Path: SenBotRunner/src/test/java/com/gfk/senbot/framework/context/MockScenarioCreationHook.java
import com.gfk.senbot.framework.cucumber.stepdefinitions.ScenarioGlobals;
import com.gfk.senbot.framework.cucumber.stepdefinitions.ScenarionCreationShutdownHook;
package com.gfk.senbot.framework.context;
public class MockScenarioCreationHook implements ScenarionCreationShutdownHook {
public static final String STARTED_ATTRIBUTE_KEY = "STARTED_ATTRIBUTE_KEY";
public static final String STARTED_ATTRIBUTE_VALUE = "STARTED_ATTRIBUTE_VALUE";
public static final String STOPPED_ATTRIBUTE_KEY = "STOPPED_ATTRIBUTE_KEY";
public static final String STOPPED_ATTRIBUTE_VALUE = "STOPPED_ATTRIBUTE_VALUE";
| public void scenarionStarted(ScenarioGlobals scenarioGlobals) { |
gfk-ba/senbot | SenBotRunner/src/test/java/com/gfk/senbot/framework/cucumber/stepdefinitions/selenium/SeleniumNavigationStepsTest.java | // Path: SenBotRunner/src/test/java/com/gfkmock/senbot/framework/cucumber/stepdefinitions/MockSeleniumNavigationStepDefinitions.java
// public class MockSeleniumNavigationStepDefinitions extends SeleniumNavigationSteps {
//
// private WebDriver mockDriver;
//
// public MockSeleniumNavigationStepDefinitions(WebDriver mockDriver) {
// super();
// this.mockDriver = mockDriver;
// }
//
// @Override
// public WebDriver getWebDriver() {
// return mockDriver;
// }
//
// }
| import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.junit.Ignore;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriver.Navigation;
import com.gfkmock.senbot.framework.cucumber.stepdefinitions.MockSeleniumNavigationStepDefinitions; | package com.gfk.senbot.framework.cucumber.stepdefinitions.selenium;
public class SeleniumNavigationStepsTest {
@Test
public void testPageRefresh() {
final WebDriver mockDriver = mock(WebDriver.class);
Navigation navigation = mock(Navigation.class);
when(mockDriver.navigate()).thenReturn(navigation);
| // Path: SenBotRunner/src/test/java/com/gfkmock/senbot/framework/cucumber/stepdefinitions/MockSeleniumNavigationStepDefinitions.java
// public class MockSeleniumNavigationStepDefinitions extends SeleniumNavigationSteps {
//
// private WebDriver mockDriver;
//
// public MockSeleniumNavigationStepDefinitions(WebDriver mockDriver) {
// super();
// this.mockDriver = mockDriver;
// }
//
// @Override
// public WebDriver getWebDriver() {
// return mockDriver;
// }
//
// }
// Path: SenBotRunner/src/test/java/com/gfk/senbot/framework/cucumber/stepdefinitions/selenium/SeleniumNavigationStepsTest.java
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.junit.Ignore;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriver.Navigation;
import com.gfkmock.senbot.framework.cucumber.stepdefinitions.MockSeleniumNavigationStepDefinitions;
package com.gfk.senbot.framework.cucumber.stepdefinitions.selenium;
public class SeleniumNavigationStepsTest {
@Test
public void testPageRefresh() {
final WebDriver mockDriver = mock(WebDriver.class);
Navigation navigation = mock(Navigation.class);
when(mockDriver.navigate()).thenReturn(navigation);
| MockSeleniumNavigationStepDefinitions navigationSteps = new MockSeleniumNavigationStepDefinitions(mockDriver); |
gfk-ba/senbot | SenBotRunner/src/test/java/com/gfk/senbot/framework/context/CucumberManagerTest.java | // Path: SenBotRunner/src/main/java/com/gfk/senbot/framework/cucumber/stepdefinitions/ScenarioGlobals.java
// public class ScenarioGlobals {
//
// private static final Logger log = LoggerFactory.getLogger(ScenarioGlobals.class);
// private Map<String, Object> scenarioAttributes = new HashMap<String, Object>();
// private final Long scenarioStart;
// private TestEnvironment testEnvironment;
// private WebDriver driver = SenBotContext.getSeleniumDriver();
// private String namespace = null;
// private List<ExpectedGlobalCondition> expectedGlobalConditions = new ArrayList<ExpectedGlobalCondition>();
//
// /**
// * Constructor
// */
// public ScenarioGlobals() {
// scenarioStart = System.currentTimeMillis();
// }
//
// /**
// * A map containing all scenario attributes
// *
// * @param key The key
// * @param value The value
// */
// public void setAttribute(String key, Object value) {
// scenarioAttributes.put(key, value);
// }
//
// /**
// * @return A map containing all scenario attributes
// */
// public Object getAttribute(String key) {
// return scenarioAttributes.get(key);
// }
//
// /**
// * Stores the time of creation of this {@link ScenarioGlobals} object so that we can use it what services
// * are used during it's lifetime. For example used for checking if selenium is used or not.
// *
// * @return scenarioStart
// */
// public Long getScenarioStart() {
// return scenarioStart;
// }
//
// /**
// * Register loader with the {@link ScenarioGlobals} so the different Selenium services can wait for them to be removed
// * @param loaderIndicators
// */
// public void registerLoaderIndicators(By... loaderIndicators) {
// for(By locator : loaderIndicators) {
// log.debug("Registered loader: " + locator);
// this.expectedGlobalConditions.add(new ExpectedWebElementCondition(locator));
// }
// }
//
// /**
// * Clear loader with the {@link ScenarioGlobals} so the different Selenium services can wait for them to be removed
// */
// public void clearExpectedGlobalConditions() {
// this.expectedGlobalConditions.clear();
// }
//
// /**
// * @return The {@link TestEnvironment} this {@link Scenario} is running in
// */
// public TestEnvironment getTestEnvironment() {
// return testEnvironment;
// }
//
// /**
// * @param testEnvironment The {@link TestEnvironment} this {@link Scenario} is running in
// */
// public void setTestEnvironment(TestEnvironment testEnvironment) {
// this.testEnvironment = testEnvironment;
// }
//
// /**
// * @return a unique to this Scenario namespace string
// */
// public String getNameSpace() {
// if(namespace == null) {
// namespace = "SNS" + new Integer(UUID.randomUUID().hashCode()).toString() + "-";
// }
// return namespace;
// }
//
// public List<ExpectedGlobalCondition> getExpectedGlobalConditions() {
// return expectedGlobalConditions;
// }
//
// public void addExpectedGlobalConditions(
// ExpectedGlobalCondition expectedGlobalCondition) {
// expectedGlobalConditions.add(expectedGlobalCondition);
//
// }
//
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import java.lang.reflect.InvocationTargetException;
import org.junit.Before;
import org.junit.Test;
import com.gfk.senbot.framework.cucumber.stepdefinitions.ScenarioGlobals; | package com.gfk.senbot.framework.context;
public class CucumberManagerTest {
@Before
public void setup() {
SenBotContext.cleanupSenBot();
}
@Test
public void testStartNewScenario() throws SecurityException, IllegalArgumentException, NoSuchMethodException, ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException {
CucumberManager manager = new CucumberManager("com.gfk.senbot.framework.context.MockScenarioCreationHook", null, false, 1, 3600);
assertNull("No globals should be associated with the current thread when not yet started", manager.getCurrentScenarioGlobals());
| // Path: SenBotRunner/src/main/java/com/gfk/senbot/framework/cucumber/stepdefinitions/ScenarioGlobals.java
// public class ScenarioGlobals {
//
// private static final Logger log = LoggerFactory.getLogger(ScenarioGlobals.class);
// private Map<String, Object> scenarioAttributes = new HashMap<String, Object>();
// private final Long scenarioStart;
// private TestEnvironment testEnvironment;
// private WebDriver driver = SenBotContext.getSeleniumDriver();
// private String namespace = null;
// private List<ExpectedGlobalCondition> expectedGlobalConditions = new ArrayList<ExpectedGlobalCondition>();
//
// /**
// * Constructor
// */
// public ScenarioGlobals() {
// scenarioStart = System.currentTimeMillis();
// }
//
// /**
// * A map containing all scenario attributes
// *
// * @param key The key
// * @param value The value
// */
// public void setAttribute(String key, Object value) {
// scenarioAttributes.put(key, value);
// }
//
// /**
// * @return A map containing all scenario attributes
// */
// public Object getAttribute(String key) {
// return scenarioAttributes.get(key);
// }
//
// /**
// * Stores the time of creation of this {@link ScenarioGlobals} object so that we can use it what services
// * are used during it's lifetime. For example used for checking if selenium is used or not.
// *
// * @return scenarioStart
// */
// public Long getScenarioStart() {
// return scenarioStart;
// }
//
// /**
// * Register loader with the {@link ScenarioGlobals} so the different Selenium services can wait for them to be removed
// * @param loaderIndicators
// */
// public void registerLoaderIndicators(By... loaderIndicators) {
// for(By locator : loaderIndicators) {
// log.debug("Registered loader: " + locator);
// this.expectedGlobalConditions.add(new ExpectedWebElementCondition(locator));
// }
// }
//
// /**
// * Clear loader with the {@link ScenarioGlobals} so the different Selenium services can wait for them to be removed
// */
// public void clearExpectedGlobalConditions() {
// this.expectedGlobalConditions.clear();
// }
//
// /**
// * @return The {@link TestEnvironment} this {@link Scenario} is running in
// */
// public TestEnvironment getTestEnvironment() {
// return testEnvironment;
// }
//
// /**
// * @param testEnvironment The {@link TestEnvironment} this {@link Scenario} is running in
// */
// public void setTestEnvironment(TestEnvironment testEnvironment) {
// this.testEnvironment = testEnvironment;
// }
//
// /**
// * @return a unique to this Scenario namespace string
// */
// public String getNameSpace() {
// if(namespace == null) {
// namespace = "SNS" + new Integer(UUID.randomUUID().hashCode()).toString() + "-";
// }
// return namespace;
// }
//
// public List<ExpectedGlobalCondition> getExpectedGlobalConditions() {
// return expectedGlobalConditions;
// }
//
// public void addExpectedGlobalConditions(
// ExpectedGlobalCondition expectedGlobalCondition) {
// expectedGlobalConditions.add(expectedGlobalCondition);
//
// }
//
// }
// Path: SenBotRunner/src/test/java/com/gfk/senbot/framework/context/CucumberManagerTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import java.lang.reflect.InvocationTargetException;
import org.junit.Before;
import org.junit.Test;
import com.gfk.senbot.framework.cucumber.stepdefinitions.ScenarioGlobals;
package com.gfk.senbot.framework.context;
public class CucumberManagerTest {
@Before
public void setup() {
SenBotContext.cleanupSenBot();
}
@Test
public void testStartNewScenario() throws SecurityException, IllegalArgumentException, NoSuchMethodException, ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException {
CucumberManager manager = new CucumberManager("com.gfk.senbot.framework.context.MockScenarioCreationHook", null, false, 1, 3600);
assertNull("No globals should be associated with the current thread when not yet started", manager.getCurrentScenarioGlobals());
| ScenarioGlobals instantiatedScenario = manager.startNewScenario(); |
gfk-ba/senbot | SenBotDemo/src/test/java/com/gfk/senbotdemo/ScenarioCreationHook.java | // Path: SenBotRunner/src/main/java/com/gfk/senbot/framework/cucumber/stepdefinitions/ScenarioGlobals.java
// public class ScenarioGlobals {
//
// private static final Logger log = LoggerFactory.getLogger(ScenarioGlobals.class);
// private Map<String, Object> scenarioAttributes = new HashMap<String, Object>();
// private final Long scenarioStart;
// private TestEnvironment testEnvironment;
// private WebDriver driver = SenBotContext.getSeleniumDriver();
// private String namespace = null;
// private List<ExpectedGlobalCondition> expectedGlobalConditions = new ArrayList<ExpectedGlobalCondition>();
//
// /**
// * Constructor
// */
// public ScenarioGlobals() {
// scenarioStart = System.currentTimeMillis();
// }
//
// /**
// * A map containing all scenario attributes
// *
// * @param key The key
// * @param value The value
// */
// public void setAttribute(String key, Object value) {
// scenarioAttributes.put(key, value);
// }
//
// /**
// * @return A map containing all scenario attributes
// */
// public Object getAttribute(String key) {
// return scenarioAttributes.get(key);
// }
//
// /**
// * Stores the time of creation of this {@link ScenarioGlobals} object so that we can use it what services
// * are used during it's lifetime. For example used for checking if selenium is used or not.
// *
// * @return scenarioStart
// */
// public Long getScenarioStart() {
// return scenarioStart;
// }
//
// /**
// * Register loader with the {@link ScenarioGlobals} so the different Selenium services can wait for them to be removed
// * @param loaderIndicators
// */
// public void registerLoaderIndicators(By... loaderIndicators) {
// for(By locator : loaderIndicators) {
// log.debug("Registered loader: " + locator);
// this.expectedGlobalConditions.add(new ExpectedWebElementCondition(locator));
// }
// }
//
// /**
// * Clear loader with the {@link ScenarioGlobals} so the different Selenium services can wait for them to be removed
// */
// public void clearExpectedGlobalConditions() {
// this.expectedGlobalConditions.clear();
// }
//
// /**
// * @return The {@link TestEnvironment} this {@link Scenario} is running in
// */
// public TestEnvironment getTestEnvironment() {
// return testEnvironment;
// }
//
// /**
// * @param testEnvironment The {@link TestEnvironment} this {@link Scenario} is running in
// */
// public void setTestEnvironment(TestEnvironment testEnvironment) {
// this.testEnvironment = testEnvironment;
// }
//
// /**
// * @return a unique to this Scenario namespace string
// */
// public String getNameSpace() {
// if(namespace == null) {
// namespace = "SNS" + new Integer(UUID.randomUUID().hashCode()).toString() + "-";
// }
// return namespace;
// }
//
// public List<ExpectedGlobalCondition> getExpectedGlobalConditions() {
// return expectedGlobalConditions;
// }
//
// public void addExpectedGlobalConditions(
// ExpectedGlobalCondition expectedGlobalCondition) {
// expectedGlobalConditions.add(expectedGlobalCondition);
//
// }
//
// }
//
// Path: SenBotRunner/src/main/java/com/gfk/senbot/framework/cucumber/stepdefinitions/ScenarionCreationShutdownHook.java
// public interface ScenarionCreationShutdownHook {
//
// void scenarionStarted(ScenarioGlobals scenarioGlobals);
//
// void scenarionShutdown(ScenarioGlobals scenarioGlobals);
//
// }
| import org.openqa.selenium.By;
import com.gfk.senbot.framework.cucumber.stepdefinitions.ScenarioGlobals;
import com.gfk.senbot.framework.cucumber.stepdefinitions.ScenarionCreationShutdownHook;
import cucumber.api.Scenario; | package com.gfk.senbotdemo;
/**
* The {@link ScenarionCreationShutdownHook} specific to the drive framework registering {@link Scenario} scoped
* variables.
*/
public class ScenarioCreationHook implements ScenarionCreationShutdownHook {
public static final By LOADER_INDICATOR = By.id("yourLoaderId");
public static final By UI_DISABLER_INDICATOR = By.id("yourSecondLoaderId");
/**
* Register the default loader locator so that the default selenium calls will always wait for this locator to be
* invisible before proceeding
*/ | // Path: SenBotRunner/src/main/java/com/gfk/senbot/framework/cucumber/stepdefinitions/ScenarioGlobals.java
// public class ScenarioGlobals {
//
// private static final Logger log = LoggerFactory.getLogger(ScenarioGlobals.class);
// private Map<String, Object> scenarioAttributes = new HashMap<String, Object>();
// private final Long scenarioStart;
// private TestEnvironment testEnvironment;
// private WebDriver driver = SenBotContext.getSeleniumDriver();
// private String namespace = null;
// private List<ExpectedGlobalCondition> expectedGlobalConditions = new ArrayList<ExpectedGlobalCondition>();
//
// /**
// * Constructor
// */
// public ScenarioGlobals() {
// scenarioStart = System.currentTimeMillis();
// }
//
// /**
// * A map containing all scenario attributes
// *
// * @param key The key
// * @param value The value
// */
// public void setAttribute(String key, Object value) {
// scenarioAttributes.put(key, value);
// }
//
// /**
// * @return A map containing all scenario attributes
// */
// public Object getAttribute(String key) {
// return scenarioAttributes.get(key);
// }
//
// /**
// * Stores the time of creation of this {@link ScenarioGlobals} object so that we can use it what services
// * are used during it's lifetime. For example used for checking if selenium is used or not.
// *
// * @return scenarioStart
// */
// public Long getScenarioStart() {
// return scenarioStart;
// }
//
// /**
// * Register loader with the {@link ScenarioGlobals} so the different Selenium services can wait for them to be removed
// * @param loaderIndicators
// */
// public void registerLoaderIndicators(By... loaderIndicators) {
// for(By locator : loaderIndicators) {
// log.debug("Registered loader: " + locator);
// this.expectedGlobalConditions.add(new ExpectedWebElementCondition(locator));
// }
// }
//
// /**
// * Clear loader with the {@link ScenarioGlobals} so the different Selenium services can wait for them to be removed
// */
// public void clearExpectedGlobalConditions() {
// this.expectedGlobalConditions.clear();
// }
//
// /**
// * @return The {@link TestEnvironment} this {@link Scenario} is running in
// */
// public TestEnvironment getTestEnvironment() {
// return testEnvironment;
// }
//
// /**
// * @param testEnvironment The {@link TestEnvironment} this {@link Scenario} is running in
// */
// public void setTestEnvironment(TestEnvironment testEnvironment) {
// this.testEnvironment = testEnvironment;
// }
//
// /**
// * @return a unique to this Scenario namespace string
// */
// public String getNameSpace() {
// if(namespace == null) {
// namespace = "SNS" + new Integer(UUID.randomUUID().hashCode()).toString() + "-";
// }
// return namespace;
// }
//
// public List<ExpectedGlobalCondition> getExpectedGlobalConditions() {
// return expectedGlobalConditions;
// }
//
// public void addExpectedGlobalConditions(
// ExpectedGlobalCondition expectedGlobalCondition) {
// expectedGlobalConditions.add(expectedGlobalCondition);
//
// }
//
// }
//
// Path: SenBotRunner/src/main/java/com/gfk/senbot/framework/cucumber/stepdefinitions/ScenarionCreationShutdownHook.java
// public interface ScenarionCreationShutdownHook {
//
// void scenarionStarted(ScenarioGlobals scenarioGlobals);
//
// void scenarionShutdown(ScenarioGlobals scenarioGlobals);
//
// }
// Path: SenBotDemo/src/test/java/com/gfk/senbotdemo/ScenarioCreationHook.java
import org.openqa.selenium.By;
import com.gfk.senbot.framework.cucumber.stepdefinitions.ScenarioGlobals;
import com.gfk.senbot.framework.cucumber.stepdefinitions.ScenarionCreationShutdownHook;
import cucumber.api.Scenario;
package com.gfk.senbotdemo;
/**
* The {@link ScenarionCreationShutdownHook} specific to the drive framework registering {@link Scenario} scoped
* variables.
*/
public class ScenarioCreationHook implements ScenarionCreationShutdownHook {
public static final By LOADER_INDICATOR = By.id("yourLoaderId");
public static final By UI_DISABLER_INDICATOR = By.id("yourSecondLoaderId");
/**
* Register the default loader locator so that the default selenium calls will always wait for this locator to be
* invisible before proceeding
*/ | public void scenarionStarted(ScenarioGlobals scenarioGlobals) { |
gfk-ba/senbot | SenBotRunner/src/main/java/com/gfk/senbot/framework/context/SeleniumManager.java | // Path: SenBotRunner/src/main/java/com/gfk/senbot/framework/cucumber/stepdefinitions/ScenarioGlobals.java
// public class ScenarioGlobals {
//
// private static final Logger log = LoggerFactory.getLogger(ScenarioGlobals.class);
// private Map<String, Object> scenarioAttributes = new HashMap<String, Object>();
// private final Long scenarioStart;
// private TestEnvironment testEnvironment;
// private WebDriver driver = SenBotContext.getSeleniumDriver();
// private String namespace = null;
// private List<ExpectedGlobalCondition> expectedGlobalConditions = new ArrayList<ExpectedGlobalCondition>();
//
// /**
// * Constructor
// */
// public ScenarioGlobals() {
// scenarioStart = System.currentTimeMillis();
// }
//
// /**
// * A map containing all scenario attributes
// *
// * @param key The key
// * @param value The value
// */
// public void setAttribute(String key, Object value) {
// scenarioAttributes.put(key, value);
// }
//
// /**
// * @return A map containing all scenario attributes
// */
// public Object getAttribute(String key) {
// return scenarioAttributes.get(key);
// }
//
// /**
// * Stores the time of creation of this {@link ScenarioGlobals} object so that we can use it what services
// * are used during it's lifetime. For example used for checking if selenium is used or not.
// *
// * @return scenarioStart
// */
// public Long getScenarioStart() {
// return scenarioStart;
// }
//
// /**
// * Register loader with the {@link ScenarioGlobals} so the different Selenium services can wait for them to be removed
// * @param loaderIndicators
// */
// public void registerLoaderIndicators(By... loaderIndicators) {
// for(By locator : loaderIndicators) {
// log.debug("Registered loader: " + locator);
// this.expectedGlobalConditions.add(new ExpectedWebElementCondition(locator));
// }
// }
//
// /**
// * Clear loader with the {@link ScenarioGlobals} so the different Selenium services can wait for them to be removed
// */
// public void clearExpectedGlobalConditions() {
// this.expectedGlobalConditions.clear();
// }
//
// /**
// * @return The {@link TestEnvironment} this {@link Scenario} is running in
// */
// public TestEnvironment getTestEnvironment() {
// return testEnvironment;
// }
//
// /**
// * @param testEnvironment The {@link TestEnvironment} this {@link Scenario} is running in
// */
// public void setTestEnvironment(TestEnvironment testEnvironment) {
// this.testEnvironment = testEnvironment;
// }
//
// /**
// * @return a unique to this Scenario namespace string
// */
// public String getNameSpace() {
// if(namespace == null) {
// namespace = "SNS" + new Integer(UUID.randomUUID().hashCode()).toString() + "-";
// }
// return namespace;
// }
//
// public List<ExpectedGlobalCondition> getExpectedGlobalConditions() {
// return expectedGlobalConditions;
// }
//
// public void addExpectedGlobalConditions(
// ExpectedGlobalCondition expectedGlobalCondition) {
// expectedGlobalConditions.add(expectedGlobalCondition);
//
// }
//
// }
| import java.awt.AWTException;
import java.awt.Robot;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.openqa.selenium.Platform;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.FindBys;
import org.openqa.selenium.support.PageFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.gfk.senbot.framework.cucumber.stepdefinitions.ScenarioGlobals; | platform,
locale);
seleniumTestEnvironments.add(testEnvironment);
}
}
}
/**
* Check {@link PageFactory} for how these Objects are instantiated using the {@link FindBy} and {@link FindBys} annotations.
* Senbot will cache your objects in the Scenario globals so that they only get initialized once
*
* @param T
* @return instanciated T
*/
public <T> T getViewRepresentation(Class<T> T) {
return getViewRepresentation(T, false);
}
/**
* Check {@link PageFactory} for how these Objects are instantiated using the {@link FindBy} and {@link FindBys} annotations.
* Senbot will cache your objects in the Scenario globals so that they only get initialized once
*
* @param T
* @param forceRefresh if true we will always reinstantiate
* @return instanciated T
*/
public <T> T getViewRepresentation(Class<T> T, boolean forceRefresh) { | // Path: SenBotRunner/src/main/java/com/gfk/senbot/framework/cucumber/stepdefinitions/ScenarioGlobals.java
// public class ScenarioGlobals {
//
// private static final Logger log = LoggerFactory.getLogger(ScenarioGlobals.class);
// private Map<String, Object> scenarioAttributes = new HashMap<String, Object>();
// private final Long scenarioStart;
// private TestEnvironment testEnvironment;
// private WebDriver driver = SenBotContext.getSeleniumDriver();
// private String namespace = null;
// private List<ExpectedGlobalCondition> expectedGlobalConditions = new ArrayList<ExpectedGlobalCondition>();
//
// /**
// * Constructor
// */
// public ScenarioGlobals() {
// scenarioStart = System.currentTimeMillis();
// }
//
// /**
// * A map containing all scenario attributes
// *
// * @param key The key
// * @param value The value
// */
// public void setAttribute(String key, Object value) {
// scenarioAttributes.put(key, value);
// }
//
// /**
// * @return A map containing all scenario attributes
// */
// public Object getAttribute(String key) {
// return scenarioAttributes.get(key);
// }
//
// /**
// * Stores the time of creation of this {@link ScenarioGlobals} object so that we can use it what services
// * are used during it's lifetime. For example used for checking if selenium is used or not.
// *
// * @return scenarioStart
// */
// public Long getScenarioStart() {
// return scenarioStart;
// }
//
// /**
// * Register loader with the {@link ScenarioGlobals} so the different Selenium services can wait for them to be removed
// * @param loaderIndicators
// */
// public void registerLoaderIndicators(By... loaderIndicators) {
// for(By locator : loaderIndicators) {
// log.debug("Registered loader: " + locator);
// this.expectedGlobalConditions.add(new ExpectedWebElementCondition(locator));
// }
// }
//
// /**
// * Clear loader with the {@link ScenarioGlobals} so the different Selenium services can wait for them to be removed
// */
// public void clearExpectedGlobalConditions() {
// this.expectedGlobalConditions.clear();
// }
//
// /**
// * @return The {@link TestEnvironment} this {@link Scenario} is running in
// */
// public TestEnvironment getTestEnvironment() {
// return testEnvironment;
// }
//
// /**
// * @param testEnvironment The {@link TestEnvironment} this {@link Scenario} is running in
// */
// public void setTestEnvironment(TestEnvironment testEnvironment) {
// this.testEnvironment = testEnvironment;
// }
//
// /**
// * @return a unique to this Scenario namespace string
// */
// public String getNameSpace() {
// if(namespace == null) {
// namespace = "SNS" + new Integer(UUID.randomUUID().hashCode()).toString() + "-";
// }
// return namespace;
// }
//
// public List<ExpectedGlobalCondition> getExpectedGlobalConditions() {
// return expectedGlobalConditions;
// }
//
// public void addExpectedGlobalConditions(
// ExpectedGlobalCondition expectedGlobalCondition) {
// expectedGlobalConditions.add(expectedGlobalCondition);
//
// }
//
// }
// Path: SenBotRunner/src/main/java/com/gfk/senbot/framework/context/SeleniumManager.java
import java.awt.AWTException;
import java.awt.Robot;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.openqa.selenium.Platform;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.FindBys;
import org.openqa.selenium.support.PageFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.gfk.senbot.framework.cucumber.stepdefinitions.ScenarioGlobals;
platform,
locale);
seleniumTestEnvironments.add(testEnvironment);
}
}
}
/**
* Check {@link PageFactory} for how these Objects are instantiated using the {@link FindBy} and {@link FindBys} annotations.
* Senbot will cache your objects in the Scenario globals so that they only get initialized once
*
* @param T
* @return instanciated T
*/
public <T> T getViewRepresentation(Class<T> T) {
return getViewRepresentation(T, false);
}
/**
* Check {@link PageFactory} for how these Objects are instantiated using the {@link FindBy} and {@link FindBys} annotations.
* Senbot will cache your objects in the Scenario globals so that they only get initialized once
*
* @param T
* @param forceRefresh if true we will always reinstantiate
* @return instanciated T
*/
public <T> T getViewRepresentation(Class<T> T, boolean forceRefresh) { | ScenarioGlobals currentScenarioGlobals = SenBotContext.getSenBotContext().getCucumberManager().getCurrentScenarioGlobals(); |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/util/task/AbstractThreadedTask.java | // Path: src/main/java/ch/picard/ppimapbuilder/util/concurrent/ExecutorServiceManager.java
// public class ExecutorServiceManager {
//
// public static final Integer DEFAULT_NB_THREAD = Runtime.getRuntime().availableProcessors()+1;
// protected final Integer maxNumberThread;
//
// private final Set<ExecutorService> allExecutorServices;
// private final Set<ExecutorService> inUseExecutorServices;
// private final Set<ExecutorService> freeExecutorServices;
//
// public ExecutorServiceManager() {
// this(DEFAULT_NB_THREAD);
// }
//
// public ExecutorServiceManager(Integer maxNumberThread) {
// this.allExecutorServices = new HashSet<ExecutorService>();
// this.inUseExecutorServices = new HashSet<ExecutorService>();
// this.freeExecutorServices = new HashSet<ExecutorService>();
// this.maxNumberThread = maxNumberThread;
// }
//
// public synchronized ExecutorService getOrCreateThreadPool() {
// if(maxNumberThread == null) return null;
// for (ExecutorService service : freeExecutorServices)
// return register(service);
// return createThreadPool(maxNumberThread);
// }
//
// public synchronized ExecutorService createThreadPool(int nbThread) {
// return register(Executors.newFixedThreadPool(nbThread));
// }
//
// public synchronized void unRegister(ExecutorService service) {
// if(freeExecutorServices.size() >= Math.pow(DEFAULT_NB_THREAD, 2)+1)
// remove(service);
// else {
// inUseExecutorServices.remove(service);
// freeExecutorServices.add(service);
// }
// }
//
// private ExecutorService register(ExecutorService service) {
// allExecutorServices.add(service);
// freeExecutorServices.remove(service);
// inUseExecutorServices.add(service);
// return service;
// }
//
// public synchronized void remove(ExecutorService service) {
// allExecutorServices.remove(service);
// inUseExecutorServices.remove(service);
// freeExecutorServices.remove(service);
// }
//
// public Integer getMaxNumberThread() {
// return maxNumberThread;
// }
//
// public void shutdown() {
// for (ExecutorService service : allExecutorServices)
// if (!service.isShutdown() || !service.isTerminated())
// service.shutdownNow();
// }
//
// public void clear() {
// allExecutorServices.clear();
// inUseExecutorServices.clear();
// freeExecutorServices.clear();
// }
// }
| import ch.picard.ppimapbuilder.util.concurrent.ExecutorServiceManager;
import org.cytoscape.work.Task; | package ch.picard.ppimapbuilder.util.task;
public abstract class AbstractThreadedTask implements Task {
private boolean canceled = false; | // Path: src/main/java/ch/picard/ppimapbuilder/util/concurrent/ExecutorServiceManager.java
// public class ExecutorServiceManager {
//
// public static final Integer DEFAULT_NB_THREAD = Runtime.getRuntime().availableProcessors()+1;
// protected final Integer maxNumberThread;
//
// private final Set<ExecutorService> allExecutorServices;
// private final Set<ExecutorService> inUseExecutorServices;
// private final Set<ExecutorService> freeExecutorServices;
//
// public ExecutorServiceManager() {
// this(DEFAULT_NB_THREAD);
// }
//
// public ExecutorServiceManager(Integer maxNumberThread) {
// this.allExecutorServices = new HashSet<ExecutorService>();
// this.inUseExecutorServices = new HashSet<ExecutorService>();
// this.freeExecutorServices = new HashSet<ExecutorService>();
// this.maxNumberThread = maxNumberThread;
// }
//
// public synchronized ExecutorService getOrCreateThreadPool() {
// if(maxNumberThread == null) return null;
// for (ExecutorService service : freeExecutorServices)
// return register(service);
// return createThreadPool(maxNumberThread);
// }
//
// public synchronized ExecutorService createThreadPool(int nbThread) {
// return register(Executors.newFixedThreadPool(nbThread));
// }
//
// public synchronized void unRegister(ExecutorService service) {
// if(freeExecutorServices.size() >= Math.pow(DEFAULT_NB_THREAD, 2)+1)
// remove(service);
// else {
// inUseExecutorServices.remove(service);
// freeExecutorServices.add(service);
// }
// }
//
// private ExecutorService register(ExecutorService service) {
// allExecutorServices.add(service);
// freeExecutorServices.remove(service);
// inUseExecutorServices.add(service);
// return service;
// }
//
// public synchronized void remove(ExecutorService service) {
// allExecutorServices.remove(service);
// inUseExecutorServices.remove(service);
// freeExecutorServices.remove(service);
// }
//
// public Integer getMaxNumberThread() {
// return maxNumberThread;
// }
//
// public void shutdown() {
// for (ExecutorService service : allExecutorServices)
// if (!service.isShutdown() || !service.isTerminated())
// service.shutdownNow();
// }
//
// public void clear() {
// allExecutorServices.clear();
// inUseExecutorServices.clear();
// freeExecutorServices.clear();
// }
// }
// Path: src/main/java/ch/picard/ppimapbuilder/util/task/AbstractThreadedTask.java
import ch.picard.ppimapbuilder.util.concurrent.ExecutorServiceManager;
import org.cytoscape.work.Task;
package ch.picard.ppimapbuilder.util.task;
public abstract class AbstractThreadedTask implements Task {
private boolean canceled = false; | protected final ExecutorServiceManager executorServiceManager; |
PPiMapBuilder/PPiMapBuilder | src/test/java/ch/picard/ppimapbuilder/util/io/FileUtilTest.java | // Path: src/test/java/ch/picard/ppimapbuilder/TestUtils.java
// public class TestUtils {
//
// private static final boolean deleteAtShutDown = false;
// private static final File baseTestOutputFolder = new File("test-output");
//
// public static File createTestOutputFolder(String preffix) {
// final File testFolderOutput = getTestOutputFolder(preffix + "-output-" + System.currentTimeMillis());
// testFolderOutput.mkdir();
//
// if(deleteAtShutDown) {
// Runtime.getRuntime().addShutdownHook(new Thread(){
// @Override
// public void run() {
// FileUtil.recursiveDelete(testFolderOutput);
// }
// });
// }
//
// return testFolderOutput;
// }
//
// public static File getBaseTestOutputFolder() {
// return baseTestOutputFolder;
// }
//
// public static File getTestOutputFolder(String folderName) {
// return new File(baseTestOutputFolder, folderName);
// }
// }
| import org.junit.Test;
import java.io.File;
import ch.picard.ppimapbuilder.TestUtils;
import junit.framework.TestCase; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.util.io;
public class FileUtilTest extends TestCase {
@Test
public void testGetHumanReadableFileSize() throws Exception { | // Path: src/test/java/ch/picard/ppimapbuilder/TestUtils.java
// public class TestUtils {
//
// private static final boolean deleteAtShutDown = false;
// private static final File baseTestOutputFolder = new File("test-output");
//
// public static File createTestOutputFolder(String preffix) {
// final File testFolderOutput = getTestOutputFolder(preffix + "-output-" + System.currentTimeMillis());
// testFolderOutput.mkdir();
//
// if(deleteAtShutDown) {
// Runtime.getRuntime().addShutdownHook(new Thread(){
// @Override
// public void run() {
// FileUtil.recursiveDelete(testFolderOutput);
// }
// });
// }
//
// return testFolderOutput;
// }
//
// public static File getBaseTestOutputFolder() {
// return baseTestOutputFolder;
// }
//
// public static File getTestOutputFolder(String folderName) {
// return new File(baseTestOutputFolder, folderName);
// }
// }
// Path: src/test/java/ch/picard/ppimapbuilder/util/io/FileUtilTest.java
import org.junit.Test;
import java.io.File;
import ch.picard.ppimapbuilder.TestUtils;
import junit.framework.TestCase;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.util.io;
public class FileUtilTest extends TestCase {
@Test
public void testGetHumanReadableFileSize() throws Exception { | File folder = TestUtils.getBaseTestOutputFolder(); |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/data/protein/UniProtEntry.java | // Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/GeneOntologyTerm.java
// public class GeneOntologyTerm extends OntologyTerm implements JSONable, Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private final String term;
// private final GeneOntologyCategory category;
// public static final int TERM_LENGTH = 10;
//
// public GeneOntologyTerm(String identifier) {
// this(identifier, "", null);
// }
//
// public GeneOntologyTerm(String identifier, String term, char category) {
// this(identifier, term, GeneOntologyCategory.getByLetter(category));
// }
//
// public GeneOntologyTerm(String identifier, String term, GeneOntologyCategory category) {
// super(identifier);
// this.term = term;
// this.category = category;
// }
//
// public String getTerm() {
// return term;
// }
//
// public GeneOntologyCategory getCategory() {
// return category;
// }
//
// @Override
// public String toString() {
// return getIdentifier();
// }
//
// @Override
// public String toJSON() {
// JsonObject out = new JsonObject();
// out.add("id", getIdentifier());
// out.add("term", term);
// return out.toString();
// }
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/GeneOntologyTermSet.java
// public class GeneOntologyTermSet extends HashSet<GeneOntologyTerm> {
//
// private static final long serialVersionUID = 1L;
//
// public GeneOntologyTermSet() {
// super();
// }
//
// public GeneOntologyTermSet(Collection<GeneOntologyTerm> terms) {
// super(terms);
// }
//
// public GeneOntologyTermSet getByCategory(GeneOntologyCategory category) {
// GeneOntologyTermSet result = new GeneOntologyTermSet();
// for (GeneOntologyTerm geneOntologyTerm : this) {
// if(geneOntologyTerm.getCategory().equals(category))
// result.add(geneOntologyTerm);
// }
// return result;
// }
//
// public List<String> asStringList() {
// ArrayList<String> list = new ArrayList<String>();
// for (GeneOntologyTerm go : this)
// list.add(go.toString());
// return list;
// }
// }
| import ch.picard.ppimapbuilder.data.ontology.GeneOntologyTerm;
import ch.picard.ppimapbuilder.data.ontology.GeneOntologyTermSet;
import ch.picard.ppimapbuilder.data.organism.Organism;
import com.eclipsesource.json.JsonObject;
import java.util.*; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.protein;
public class UniProtEntry extends Protein {
private final LinkedHashSet<String> accessions;
private final String geneName;
private final Set<String> synonymGeneNames;
private final String proteinName;
private final String ecNumber;
private final boolean reviewed; | // Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/GeneOntologyTerm.java
// public class GeneOntologyTerm extends OntologyTerm implements JSONable, Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private final String term;
// private final GeneOntologyCategory category;
// public static final int TERM_LENGTH = 10;
//
// public GeneOntologyTerm(String identifier) {
// this(identifier, "", null);
// }
//
// public GeneOntologyTerm(String identifier, String term, char category) {
// this(identifier, term, GeneOntologyCategory.getByLetter(category));
// }
//
// public GeneOntologyTerm(String identifier, String term, GeneOntologyCategory category) {
// super(identifier);
// this.term = term;
// this.category = category;
// }
//
// public String getTerm() {
// return term;
// }
//
// public GeneOntologyCategory getCategory() {
// return category;
// }
//
// @Override
// public String toString() {
// return getIdentifier();
// }
//
// @Override
// public String toJSON() {
// JsonObject out = new JsonObject();
// out.add("id", getIdentifier());
// out.add("term", term);
// return out.toString();
// }
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/GeneOntologyTermSet.java
// public class GeneOntologyTermSet extends HashSet<GeneOntologyTerm> {
//
// private static final long serialVersionUID = 1L;
//
// public GeneOntologyTermSet() {
// super();
// }
//
// public GeneOntologyTermSet(Collection<GeneOntologyTerm> terms) {
// super(terms);
// }
//
// public GeneOntologyTermSet getByCategory(GeneOntologyCategory category) {
// GeneOntologyTermSet result = new GeneOntologyTermSet();
// for (GeneOntologyTerm geneOntologyTerm : this) {
// if(geneOntologyTerm.getCategory().equals(category))
// result.add(geneOntologyTerm);
// }
// return result;
// }
//
// public List<String> asStringList() {
// ArrayList<String> list = new ArrayList<String>();
// for (GeneOntologyTerm go : this)
// list.add(go.toString());
// return list;
// }
// }
// Path: src/main/java/ch/picard/ppimapbuilder/data/protein/UniProtEntry.java
import ch.picard.ppimapbuilder.data.ontology.GeneOntologyTerm;
import ch.picard.ppimapbuilder.data.ontology.GeneOntologyTermSet;
import ch.picard.ppimapbuilder.data.organism.Organism;
import com.eclipsesource.json.JsonObject;
import java.util.*;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.protein;
public class UniProtEntry extends Protein {
private final LinkedHashSet<String> accessions;
private final String geneName;
private final Set<String> synonymGeneNames;
private final String proteinName;
private final String ecNumber;
private final boolean reviewed; | private final GeneOntologyTermSet geneOntologyTerms; |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/data/protein/UniProtEntry.java | // Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/GeneOntologyTerm.java
// public class GeneOntologyTerm extends OntologyTerm implements JSONable, Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private final String term;
// private final GeneOntologyCategory category;
// public static final int TERM_LENGTH = 10;
//
// public GeneOntologyTerm(String identifier) {
// this(identifier, "", null);
// }
//
// public GeneOntologyTerm(String identifier, String term, char category) {
// this(identifier, term, GeneOntologyCategory.getByLetter(category));
// }
//
// public GeneOntologyTerm(String identifier, String term, GeneOntologyCategory category) {
// super(identifier);
// this.term = term;
// this.category = category;
// }
//
// public String getTerm() {
// return term;
// }
//
// public GeneOntologyCategory getCategory() {
// return category;
// }
//
// @Override
// public String toString() {
// return getIdentifier();
// }
//
// @Override
// public String toJSON() {
// JsonObject out = new JsonObject();
// out.add("id", getIdentifier());
// out.add("term", term);
// return out.toString();
// }
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/GeneOntologyTermSet.java
// public class GeneOntologyTermSet extends HashSet<GeneOntologyTerm> {
//
// private static final long serialVersionUID = 1L;
//
// public GeneOntologyTermSet() {
// super();
// }
//
// public GeneOntologyTermSet(Collection<GeneOntologyTerm> terms) {
// super(terms);
// }
//
// public GeneOntologyTermSet getByCategory(GeneOntologyCategory category) {
// GeneOntologyTermSet result = new GeneOntologyTermSet();
// for (GeneOntologyTerm geneOntologyTerm : this) {
// if(geneOntologyTerm.getCategory().equals(category))
// result.add(geneOntologyTerm);
// }
// return result;
// }
//
// public List<String> asStringList() {
// ArrayList<String> list = new ArrayList<String>();
// for (GeneOntologyTerm go : this)
// list.add(go.toString());
// return list;
// }
// }
| import ch.picard.ppimapbuilder.data.ontology.GeneOntologyTerm;
import ch.picard.ppimapbuilder.data.ontology.GeneOntologyTermSet;
import ch.picard.ppimapbuilder.data.organism.Organism;
import com.eclipsesource.json.JsonObject;
import java.util.*; | getOrCreateSynonymGeneNames().add(synonymGeneName);
return this;
}
public Builder addSynonymGeneNames(Collection<String> synonymGeneNames) {
for (String synonymGeneName : synonymGeneNames)
addSynonymGeneName(synonymGeneName);
return this;
}
public Builder setProteinName(String proteinName) {
this.proteinName = proteinName;
return this;
}
public Builder setEcNumber(String ecNumber) {
this.ecNumber = ecNumber;
return this;
}
public Builder setReviewed(boolean reviewed) {
this.reviewed = reviewed;
return this;
}
private GeneOntologyTermSet getOrCreateGeneOntologyTerms() {
if(geneOntologyTerms != null) return geneOntologyTerms;
return geneOntologyTerms = new GeneOntologyTermSet();
}
| // Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/GeneOntologyTerm.java
// public class GeneOntologyTerm extends OntologyTerm implements JSONable, Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private final String term;
// private final GeneOntologyCategory category;
// public static final int TERM_LENGTH = 10;
//
// public GeneOntologyTerm(String identifier) {
// this(identifier, "", null);
// }
//
// public GeneOntologyTerm(String identifier, String term, char category) {
// this(identifier, term, GeneOntologyCategory.getByLetter(category));
// }
//
// public GeneOntologyTerm(String identifier, String term, GeneOntologyCategory category) {
// super(identifier);
// this.term = term;
// this.category = category;
// }
//
// public String getTerm() {
// return term;
// }
//
// public GeneOntologyCategory getCategory() {
// return category;
// }
//
// @Override
// public String toString() {
// return getIdentifier();
// }
//
// @Override
// public String toJSON() {
// JsonObject out = new JsonObject();
// out.add("id", getIdentifier());
// out.add("term", term);
// return out.toString();
// }
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/GeneOntologyTermSet.java
// public class GeneOntologyTermSet extends HashSet<GeneOntologyTerm> {
//
// private static final long serialVersionUID = 1L;
//
// public GeneOntologyTermSet() {
// super();
// }
//
// public GeneOntologyTermSet(Collection<GeneOntologyTerm> terms) {
// super(terms);
// }
//
// public GeneOntologyTermSet getByCategory(GeneOntologyCategory category) {
// GeneOntologyTermSet result = new GeneOntologyTermSet();
// for (GeneOntologyTerm geneOntologyTerm : this) {
// if(geneOntologyTerm.getCategory().equals(category))
// result.add(geneOntologyTerm);
// }
// return result;
// }
//
// public List<String> asStringList() {
// ArrayList<String> list = new ArrayList<String>();
// for (GeneOntologyTerm go : this)
// list.add(go.toString());
// return list;
// }
// }
// Path: src/main/java/ch/picard/ppimapbuilder/data/protein/UniProtEntry.java
import ch.picard.ppimapbuilder.data.ontology.GeneOntologyTerm;
import ch.picard.ppimapbuilder.data.ontology.GeneOntologyTermSet;
import ch.picard.ppimapbuilder.data.organism.Organism;
import com.eclipsesource.json.JsonObject;
import java.util.*;
getOrCreateSynonymGeneNames().add(synonymGeneName);
return this;
}
public Builder addSynonymGeneNames(Collection<String> synonymGeneNames) {
for (String synonymGeneName : synonymGeneNames)
addSynonymGeneName(synonymGeneName);
return this;
}
public Builder setProteinName(String proteinName) {
this.proteinName = proteinName;
return this;
}
public Builder setEcNumber(String ecNumber) {
this.ecNumber = ecNumber;
return this;
}
public Builder setReviewed(boolean reviewed) {
this.reviewed = reviewed;
return this;
}
private GeneOntologyTermSet getOrCreateGeneOntologyTerms() {
if(geneOntologyTerms != null) return geneOntologyTerms;
return geneOntologyTerms = new GeneOntologyTermSet();
}
| public Builder addGeneOntologyTerms(Collection<GeneOntologyTerm> terms) { |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/data/protein/UniProtEntrySet.java | // Path: src/main/java/ch/picard/ppimapbuilder/data/protein/ortholog/OrthologScoredProtein.java
// public class OrthologScoredProtein extends Protein {
//
// private static final long serialVersionUID = 1L;
//
// private final Double score;
//
// public OrthologScoredProtein(Protein protein, Double score) {
// super(protein.getUniProtId(), protein.getOrganism());
// this.score = score;
// }
//
// public Double getScore() {
// return score;
// }
//
// }
| import java.util.Map;
import java.util.Set;
import ch.picard.ppimapbuilder.data.organism.Organism;
import ch.picard.ppimapbuilder.data.protein.ortholog.OrthologScoredProtein;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
import java.util.List; |
return atLeastOneAdditionMade;
}
public void addOrtholog(Protein entry, List<? extends Protein> orthologs) {
UniProtEntry uniProtEntry = null;
if (entry instanceof UniProtEntry) {
uniProtEntry = (UniProtEntry) entry;
add(uniProtEntry);
} else
uniProtEntry = findByPrimaryAccession(entry.getUniProtId());
if (uniProtEntry == null)
return;
for (Protein ortholog : orthologs) {
Map<String, UniProtEntry> entries = uniprotEntriesIndexed.get(ortholog.getOrganism());
if (entries == null) {
entries = Maps.newHashMap();
uniprotEntriesIndexed.put(ortholog.getOrganism(), entries);
}
entries.put(ortholog.getUniProtId(), uniProtEntry);
String strictId = ProteinUtils.UniProtId.extractStrictUniProtId(ortholog.getUniProtId());
if(!strictId.equals(ortholog.getUniProtId())) {
entries.put(strictId, uniProtEntry);
}
}
}
| // Path: src/main/java/ch/picard/ppimapbuilder/data/protein/ortholog/OrthologScoredProtein.java
// public class OrthologScoredProtein extends Protein {
//
// private static final long serialVersionUID = 1L;
//
// private final Double score;
//
// public OrthologScoredProtein(Protein protein, Double score) {
// super(protein.getUniProtId(), protein.getOrganism());
// this.score = score;
// }
//
// public Double getScore() {
// return score;
// }
//
// }
// Path: src/main/java/ch/picard/ppimapbuilder/data/protein/UniProtEntrySet.java
import java.util.Map;
import java.util.Set;
import ch.picard.ppimapbuilder.data.organism.Organism;
import ch.picard.ppimapbuilder.data.protein.ortholog.OrthologScoredProtein;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
return atLeastOneAdditionMade;
}
public void addOrtholog(Protein entry, List<? extends Protein> orthologs) {
UniProtEntry uniProtEntry = null;
if (entry instanceof UniProtEntry) {
uniProtEntry = (UniProtEntry) entry;
add(uniProtEntry);
} else
uniProtEntry = findByPrimaryAccession(entry.getUniProtId());
if (uniProtEntry == null)
return;
for (Protein ortholog : orthologs) {
Map<String, UniProtEntry> entries = uniprotEntriesIndexed.get(ortholog.getOrganism());
if (entries == null) {
entries = Maps.newHashMap();
uniprotEntriesIndexed.put(ortholog.getOrganism(), entries);
}
entries.put(ortholog.getUniProtId(), uniProtEntry);
String strictId = ProteinUtils.UniProtId.extractStrictUniProtId(ortholog.getUniProtId());
if(!strictId.equals(ortholog.getUniProtId())) {
entries.put(strictId, uniProtEntry);
}
}
}
| public void addOrthologs(Map<Protein, Map<Organism, List<OrthologScoredProtein>>> orthologs) { |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/ui/querywindow/component/panel/field/UniprotSelection.java | // Path: src/main/java/ch/picard/ppimapbuilder/ui/util/PMBUIStyle.java
// public class PMBUIStyle {
//
// private static Color defaultPanelColor = UIManager.getColor("Panel.background");
// private static float hsbVals[] = Color.RGBtoHSB(
// defaultPanelColor.getRed(),
// defaultPanelColor.getGreen(),
// defaultPanelColor.getBlue(),
// null
// );
//
// public static final Color blurActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color blurInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.95f);
//
// public static final Color focusActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color focusInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.84f);
//
// public static final Color defaultBorderColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.94f);
//
// public static final Border defaultComponentBorder = new LineBorder(defaultBorderColor, 1);
// public static final Border fancyPanelBorder = new CompoundBorder(
// // Outside border 1px bottom light color
// new MatteBorder(0, 0, 1, 0, Color.WHITE),
// // Border all around panel 1px dark grey
// defaultComponentBorder
// );
// public static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
//
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/ui/util/label/HelpIcon.java
// public class HelpIcon extends JLabel{
// private static final long serialVersionUID = 1L;
//
// public HelpIcon(String message) {
// super();
// try {
// setIcon(new ImageIcon(HelpIcon.class.getResource("help.png")));
// } catch (Exception e) {
// setText("[?]");
// }
// setToolTipText(message);
// }
// }
| import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import ch.picard.ppimapbuilder.ui.util.PMBUIStyle;
import ch.picard.ppimapbuilder.ui.util.label.HelpIcon;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.ui.querywindow.component.panel.field;
public class UniprotSelection extends JPanel {
private JTextArea identifiers;
public UniprotSelection() {
// Uniprot identifiers left panel | // Path: src/main/java/ch/picard/ppimapbuilder/ui/util/PMBUIStyle.java
// public class PMBUIStyle {
//
// private static Color defaultPanelColor = UIManager.getColor("Panel.background");
// private static float hsbVals[] = Color.RGBtoHSB(
// defaultPanelColor.getRed(),
// defaultPanelColor.getGreen(),
// defaultPanelColor.getBlue(),
// null
// );
//
// public static final Color blurActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color blurInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.95f);
//
// public static final Color focusActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color focusInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.84f);
//
// public static final Color defaultBorderColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.94f);
//
// public static final Border defaultComponentBorder = new LineBorder(defaultBorderColor, 1);
// public static final Border fancyPanelBorder = new CompoundBorder(
// // Outside border 1px bottom light color
// new MatteBorder(0, 0, 1, 0, Color.WHITE),
// // Border all around panel 1px dark grey
// defaultComponentBorder
// );
// public static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
//
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/ui/util/label/HelpIcon.java
// public class HelpIcon extends JLabel{
// private static final long serialVersionUID = 1L;
//
// public HelpIcon(String message) {
// super();
// try {
// setIcon(new ImageIcon(HelpIcon.class.getResource("help.png")));
// } catch (Exception e) {
// setText("[?]");
// }
// setToolTipText(message);
// }
// }
// Path: src/main/java/ch/picard/ppimapbuilder/ui/querywindow/component/panel/field/UniprotSelection.java
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import ch.picard.ppimapbuilder.ui.util.PMBUIStyle;
import ch.picard.ppimapbuilder.ui.util.label.HelpIcon;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.ui.querywindow.component.panel.field;
public class UniprotSelection extends JPanel {
private JTextArea identifiers;
public UniprotSelection() {
// Uniprot identifiers left panel | setBorder(PMBUIStyle.fancyPanelBorder); |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/ui/querywindow/component/panel/field/UniprotSelection.java | // Path: src/main/java/ch/picard/ppimapbuilder/ui/util/PMBUIStyle.java
// public class PMBUIStyle {
//
// private static Color defaultPanelColor = UIManager.getColor("Panel.background");
// private static float hsbVals[] = Color.RGBtoHSB(
// defaultPanelColor.getRed(),
// defaultPanelColor.getGreen(),
// defaultPanelColor.getBlue(),
// null
// );
//
// public static final Color blurActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color blurInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.95f);
//
// public static final Color focusActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color focusInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.84f);
//
// public static final Color defaultBorderColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.94f);
//
// public static final Border defaultComponentBorder = new LineBorder(defaultBorderColor, 1);
// public static final Border fancyPanelBorder = new CompoundBorder(
// // Outside border 1px bottom light color
// new MatteBorder(0, 0, 1, 0, Color.WHITE),
// // Border all around panel 1px dark grey
// defaultComponentBorder
// );
// public static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
//
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/ui/util/label/HelpIcon.java
// public class HelpIcon extends JLabel{
// private static final long serialVersionUID = 1L;
//
// public HelpIcon(String message) {
// super();
// try {
// setIcon(new ImageIcon(HelpIcon.class.getResource("help.png")));
// } catch (Exception e) {
// setText("[?]");
// }
// setToolTipText(message);
// }
// }
| import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import ch.picard.ppimapbuilder.ui.util.PMBUIStyle;
import ch.picard.ppimapbuilder.ui.util.label.HelpIcon;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.ui.querywindow.component.panel.field;
public class UniprotSelection extends JPanel {
private JTextArea identifiers;
public UniprotSelection() {
// Uniprot identifiers left panel
setBorder(PMBUIStyle.fancyPanelBorder);
this.setLayout(new MigLayout("inset 15", "[129px,grow][14px:14px:14px,right]", "[20px][366px,grow][35px]"));
// Label "Uniprot identifiers"
JLabel lblIdentifiers = new JLabel("Uniprot Identifiers\n");
this.add(lblIdentifiers, "flowx,cell 0 0,alignx left,aligny top");
// Uniprot identifiers Help Icon | // Path: src/main/java/ch/picard/ppimapbuilder/ui/util/PMBUIStyle.java
// public class PMBUIStyle {
//
// private static Color defaultPanelColor = UIManager.getColor("Panel.background");
// private static float hsbVals[] = Color.RGBtoHSB(
// defaultPanelColor.getRed(),
// defaultPanelColor.getGreen(),
// defaultPanelColor.getBlue(),
// null
// );
//
// public static final Color blurActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color blurInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.95f);
//
// public static final Color focusActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color focusInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.84f);
//
// public static final Color defaultBorderColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.94f);
//
// public static final Border defaultComponentBorder = new LineBorder(defaultBorderColor, 1);
// public static final Border fancyPanelBorder = new CompoundBorder(
// // Outside border 1px bottom light color
// new MatteBorder(0, 0, 1, 0, Color.WHITE),
// // Border all around panel 1px dark grey
// defaultComponentBorder
// );
// public static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
//
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/ui/util/label/HelpIcon.java
// public class HelpIcon extends JLabel{
// private static final long serialVersionUID = 1L;
//
// public HelpIcon(String message) {
// super();
// try {
// setIcon(new ImageIcon(HelpIcon.class.getResource("help.png")));
// } catch (Exception e) {
// setText("[?]");
// }
// setToolTipText(message);
// }
// }
// Path: src/main/java/ch/picard/ppimapbuilder/ui/querywindow/component/panel/field/UniprotSelection.java
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import ch.picard.ppimapbuilder.ui.util.PMBUIStyle;
import ch.picard.ppimapbuilder.ui.util.label.HelpIcon;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.ui.querywindow.component.panel.field;
public class UniprotSelection extends JPanel {
private JTextArea identifiers;
public UniprotSelection() {
// Uniprot identifiers left panel
setBorder(PMBUIStyle.fancyPanelBorder);
this.setLayout(new MigLayout("inset 15", "[129px,grow][14px:14px:14px,right]", "[20px][366px,grow][35px]"));
// Label "Uniprot identifiers"
JLabel lblIdentifiers = new JLabel("Uniprot Identifiers\n");
this.add(lblIdentifiers, "flowx,cell 0 0,alignx left,aligny top");
// Uniprot identifiers Help Icon | JLabel lblHelpUniprotIdentifiers = new HelpIcon("Please enter Uniprot identifiers (one per line)"); |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/ui/querywindow/component/panel/field/ReferenceOrganismSelectionPanel.java | // Path: src/main/java/ch/picard/ppimapbuilder/ui/util/label/HelpIcon.java
// public class HelpIcon extends JLabel{
// private static final long serialVersionUID = 1L;
//
// public HelpIcon(String message) {
// super();
// try {
// setIcon(new ImageIcon(HelpIcon.class.getResource("help.png")));
// } catch (Exception e) {
// setText("[?]");
// }
// setToolTipText(message);
// }
// }
| import ch.picard.ppimapbuilder.data.organism.Organism;
import ch.picard.ppimapbuilder.ui.util.label.HelpIcon;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.List; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.ui.querywindow.component.panel.field;
public class ReferenceOrganismSelectionPanel extends JPanel {
private static final long serialVersionUID = 1L;
private final JComboBox<Organism> refOrgCb;
private final OtherOrganismSelectionPanel otherOrganismSelectionPanel;
private ItemListener itemListener = null;
public ReferenceOrganismSelectionPanel() {
this(null);
}
public ReferenceOrganismSelectionPanel(OtherOrganismSelectionPanel otherOrganismSelectionPanel) {
this.otherOrganismSelectionPanel = otherOrganismSelectionPanel;
setLayout(new MigLayout("ins 0", "[grow][]", "[][grow]"));
setOpaque(false);
// Reference organism label
JLabel lblReferenceOrganism = new JLabel("Reference organism:");
add(lblReferenceOrganism);
// Reference organism Help Icon | // Path: src/main/java/ch/picard/ppimapbuilder/ui/util/label/HelpIcon.java
// public class HelpIcon extends JLabel{
// private static final long serialVersionUID = 1L;
//
// public HelpIcon(String message) {
// super();
// try {
// setIcon(new ImageIcon(HelpIcon.class.getResource("help.png")));
// } catch (Exception e) {
// setText("[?]");
// }
// setToolTipText(message);
// }
// }
// Path: src/main/java/ch/picard/ppimapbuilder/ui/querywindow/component/panel/field/ReferenceOrganismSelectionPanel.java
import ch.picard.ppimapbuilder.data.organism.Organism;
import ch.picard.ppimapbuilder.ui.util.label.HelpIcon;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.List;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.ui.querywindow.component.panel.field;
public class ReferenceOrganismSelectionPanel extends JPanel {
private static final long serialVersionUID = 1L;
private final JComboBox<Organism> refOrgCb;
private final OtherOrganismSelectionPanel otherOrganismSelectionPanel;
private ItemListener itemListener = null;
public ReferenceOrganismSelectionPanel() {
this(null);
}
public ReferenceOrganismSelectionPanel(OtherOrganismSelectionPanel otherOrganismSelectionPanel) {
this.otherOrganismSelectionPanel = otherOrganismSelectionPanel;
setLayout(new MigLayout("ins 0", "[grow][]", "[][grow]"));
setOpaque(false);
// Reference organism label
JLabel lblReferenceOrganism = new JLabel("Reference organism:");
add(lblReferenceOrganism);
// Reference organism Help Icon | JLabel lblHelpRefOrganism = new HelpIcon("Select here the organism from which the protein you entered come from"); |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/data/ontology/goslim/GOSlimOBOParser.java | // Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/GeneOntologyTerm.java
// public class GeneOntologyTerm extends OntologyTerm implements JSONable, Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private final String term;
// private final GeneOntologyCategory category;
// public static final int TERM_LENGTH = 10;
//
// public GeneOntologyTerm(String identifier) {
// this(identifier, "", null);
// }
//
// public GeneOntologyTerm(String identifier, String term, char category) {
// this(identifier, term, GeneOntologyCategory.getByLetter(category));
// }
//
// public GeneOntologyTerm(String identifier, String term, GeneOntologyCategory category) {
// super(identifier);
// this.term = term;
// this.category = category;
// }
//
// public String getTerm() {
// return term;
// }
//
// public GeneOntologyCategory getCategory() {
// return category;
// }
//
// @Override
// public String toString() {
// return getIdentifier();
// }
//
// @Override
// public String toJSON() {
// JsonObject out = new JsonObject();
// out.add("id", getIdentifier());
// out.add("term", term);
// return out.toString();
// }
// }
| import ch.picard.ppimapbuilder.data.ontology.GeneOntologyTerm;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader; | try {
reader = new BufferedReader(new InputStreamReader(inputStream));
String line;
boolean inTerm = false;
String identifier = null;
String term = null;
Character category = null;
while((line = reader.readLine()) != null) {
if(line.contains("[Term]")) {
inTerm = true;
identifier = term = null;
category = null;
}
else if(inTerm && line.startsWith("id:")) {
String id = line.replace("id: ", "");
identifier = id.startsWith("GO") ? id : null;
}
else if(line.startsWith("name:") && identifier != null) {
term = line.replace("name: ", "");
}
else if(line.startsWith("namespace:") && term != null) {
String namespace = line.replace("namespace: ", "");
if(namespace.equals("biological_process"))
category = 'P';
else if(namespace.equals("molecular_function"))
category = 'F';
else if(namespace.equals("cellular_component"))
category = 'C';
| // Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/GeneOntologyTerm.java
// public class GeneOntologyTerm extends OntologyTerm implements JSONable, Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private final String term;
// private final GeneOntologyCategory category;
// public static final int TERM_LENGTH = 10;
//
// public GeneOntologyTerm(String identifier) {
// this(identifier, "", null);
// }
//
// public GeneOntologyTerm(String identifier, String term, char category) {
// this(identifier, term, GeneOntologyCategory.getByLetter(category));
// }
//
// public GeneOntologyTerm(String identifier, String term, GeneOntologyCategory category) {
// super(identifier);
// this.term = term;
// this.category = category;
// }
//
// public String getTerm() {
// return term;
// }
//
// public GeneOntologyCategory getCategory() {
// return category;
// }
//
// @Override
// public String toString() {
// return getIdentifier();
// }
//
// @Override
// public String toJSON() {
// JsonObject out = new JsonObject();
// out.add("id", getIdentifier());
// out.add("term", term);
// return out.toString();
// }
// }
// Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/goslim/GOSlimOBOParser.java
import ch.picard.ppimapbuilder.data.ontology.GeneOntologyTerm;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
try {
reader = new BufferedReader(new InputStreamReader(inputStream));
String line;
boolean inTerm = false;
String identifier = null;
String term = null;
Character category = null;
while((line = reader.readLine()) != null) {
if(line.contains("[Term]")) {
inTerm = true;
identifier = term = null;
category = null;
}
else if(inTerm && line.startsWith("id:")) {
String id = line.replace("id: ", "");
identifier = id.startsWith("GO") ? id : null;
}
else if(line.startsWith("name:") && identifier != null) {
term = line.replace("name: ", "");
}
else if(line.startsWith("namespace:") && term != null) {
String namespace = line.replace("namespace: ", "");
if(namespace.equals("biological_process"))
category = 'P';
else if(namespace.equals("molecular_function"))
category = 'F';
else if(namespace.equals("cellular_component"))
category = 'C';
| set.add(new GeneOntologyTerm(identifier, term, category)); |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/ui/util/field/ListDeletableItem.java | // Path: src/main/java/ch/picard/ppimapbuilder/ui/util/PMBUIStyle.java
// public class PMBUIStyle {
//
// private static Color defaultPanelColor = UIManager.getColor("Panel.background");
// private static float hsbVals[] = Color.RGBtoHSB(
// defaultPanelColor.getRed(),
// defaultPanelColor.getGreen(),
// defaultPanelColor.getBlue(),
// null
// );
//
// public static final Color blurActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color blurInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.95f);
//
// public static final Color focusActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color focusInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.84f);
//
// public static final Color defaultBorderColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.94f);
//
// public static final Border defaultComponentBorder = new LineBorder(defaultBorderColor, 1);
// public static final Border fancyPanelBorder = new CompoundBorder(
// // Outside border 1px bottom light color
// new MatteBorder(0, 0, 1, 0, Color.WHITE),
// // Border all around panel 1px dark grey
// defaultComponentBorder
// );
// public static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
//
// }
| import ch.picard.ppimapbuilder.ui.util.PMBUIStyle;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionListener; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.ui.util.field;
public class ListDeletableItem {
private final JPanel listPanel;
private final JScrollPane scrollPane;
public ListDeletableItem() {
scrollPane = new JScrollPane(listPanel = new JPanel()); | // Path: src/main/java/ch/picard/ppimapbuilder/ui/util/PMBUIStyle.java
// public class PMBUIStyle {
//
// private static Color defaultPanelColor = UIManager.getColor("Panel.background");
// private static float hsbVals[] = Color.RGBtoHSB(
// defaultPanelColor.getRed(),
// defaultPanelColor.getGreen(),
// defaultPanelColor.getBlue(),
// null
// );
//
// public static final Color blurActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color blurInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.95f);
//
// public static final Color focusActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color focusInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.84f);
//
// public static final Color defaultBorderColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.94f);
//
// public static final Border defaultComponentBorder = new LineBorder(defaultBorderColor, 1);
// public static final Border fancyPanelBorder = new CompoundBorder(
// // Outside border 1px bottom light color
// new MatteBorder(0, 0, 1, 0, Color.WHITE),
// // Border all around panel 1px dark grey
// defaultComponentBorder
// );
// public static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
//
// }
// Path: src/main/java/ch/picard/ppimapbuilder/ui/util/field/ListDeletableItem.java
import ch.picard.ppimapbuilder.ui.util.PMBUIStyle;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionListener;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.ui.util.field;
public class ListDeletableItem {
private final JPanel listPanel;
private final JScrollPane scrollPane;
public ListDeletableItem() {
scrollPane = new JScrollPane(listPanel = new JPanel()); | scrollPane.setViewportBorder(PMBUIStyle.emptyBorder); |
PPiMapBuilder/PPiMapBuilder | src/test/java/ch/picard/ppimapbuilder/data/protein/ortholog/client/cache/loader/InParanoidCacheLoaderTaskFactoryTest.java | // Path: src/test/java/ch/picard/ppimapbuilder/TestUtils.java
// public class TestUtils {
//
// private static final boolean deleteAtShutDown = false;
// private static final File baseTestOutputFolder = new File("test-output");
//
// public static File createTestOutputFolder(String preffix) {
// final File testFolderOutput = getTestOutputFolder(preffix + "-output-" + System.currentTimeMillis());
// testFolderOutput.mkdir();
//
// if(deleteAtShutDown) {
// Runtime.getRuntime().addShutdownHook(new Thread(){
// @Override
// public void run() {
// FileUtil.recursiveDelete(testFolderOutput);
// }
// });
// }
//
// return testFolderOutput;
// }
//
// public static File getBaseTestOutputFolder() {
// return baseTestOutputFolder;
// }
//
// public static File getTestOutputFolder(String folderName) {
// return new File(baseTestOutputFolder, folderName);
// }
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/data/organism/UserOrganismRepository.java
// public class UserOrganismRepository extends OrganismRepository {
//
// private static UserOrganismRepository _instance;
//
// public static UserOrganismRepository getInstance() {
// if (_instance == null)
// _instance = new UserOrganismRepository();
// return _instance;
// }
//
// private UserOrganismRepository(List<Organism> organismList) {
// super(organismList);
// }
// private UserOrganismRepository() {
// this(PMBSettings.getInstance().getOrganismList());
// }
//
// public static void resetToSettings() {
// _instance = new UserOrganismRepository();
// }
//
// public static ArrayList<Organism> getDefaultOrganismList() {
// ArrayList<Organism> organismList = new ArrayList<Organism>();
// organismList.add(new Organism("Homo sapiens", "HUMAN", "Human", 9606));
// organismList.add(new Organism("Arabidopsis thaliana", "ARATH", "Mouse-ear cress", 3702));
// organismList.add(new Organism("Caenorhabditis elegans", "CAEEL", "", 6239));
// organismList.add(new Organism("Drosophila melanogaster", "DROME", "Fruit fly", 7227));
// organismList.add(new Organism("Mus musculus", "MOUSE", "Mouse", 10090));
// organismList.add(new Organism("Saccharomyces cerevisiae (strain ATCC 204508 / S288c)", "YEAST", "Baker's yeast", 559292));
// organismList.add(new Organism("Schizosaccharomyces pombe (strain 972 / ATCC 24843)", "SCHPO", "Fission yeast", 284812));
// organismList.add(new Organism("Plasmodium falciparum (isolate 3D7)", "PLAF7", "", 36329));
// organismList.add(new Organism("Gallus gallus", "CHICK", "Chicken", 9031));
// return organismList;
// }
//
// public void removeOrganism(Organism o) {
// organisms.remove(o);
// PMBProteinOrthologCacheClient.getInstance().emptyCacheLinkedToOrganism(o);
// }
//
// public void addOrganism(String scientificName) {
// Organism orga = InParanoidOrganismRepository.getInstance().getOrganismByScientificName(scientificName);
// if (orga != null) {
// organisms.add(orga);
// }
// }
//
// public void removeOrganismExceptLastOne(String scientificName) {
// if (organisms.size() > 1)
// removeOrganism(getOrganismByScientificName(scientificName));
// else
// JOptionPane.showMessageDialog(null, "Please keep at least one organism", "Deletion impossible", JOptionPane.INFORMATION_MESSAGE);
// }
//
// }
| import java.util.List;
import ch.picard.ppimapbuilder.TestUtils;
import ch.picard.ppimapbuilder.data.organism.Organism;
import ch.picard.ppimapbuilder.data.organism.UserOrganismRepository;
import ch.picard.ppimapbuilder.data.settings.PMBSettings;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.Arrays; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.protein.ortholog.client.cache.loader;
public class InParanoidCacheLoaderTaskFactoryTest {
private static File testFolderOutput;
@BeforeClass
public static void before() throws IOException { | // Path: src/test/java/ch/picard/ppimapbuilder/TestUtils.java
// public class TestUtils {
//
// private static final boolean deleteAtShutDown = false;
// private static final File baseTestOutputFolder = new File("test-output");
//
// public static File createTestOutputFolder(String preffix) {
// final File testFolderOutput = getTestOutputFolder(preffix + "-output-" + System.currentTimeMillis());
// testFolderOutput.mkdir();
//
// if(deleteAtShutDown) {
// Runtime.getRuntime().addShutdownHook(new Thread(){
// @Override
// public void run() {
// FileUtil.recursiveDelete(testFolderOutput);
// }
// });
// }
//
// return testFolderOutput;
// }
//
// public static File getBaseTestOutputFolder() {
// return baseTestOutputFolder;
// }
//
// public static File getTestOutputFolder(String folderName) {
// return new File(baseTestOutputFolder, folderName);
// }
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/data/organism/UserOrganismRepository.java
// public class UserOrganismRepository extends OrganismRepository {
//
// private static UserOrganismRepository _instance;
//
// public static UserOrganismRepository getInstance() {
// if (_instance == null)
// _instance = new UserOrganismRepository();
// return _instance;
// }
//
// private UserOrganismRepository(List<Organism> organismList) {
// super(organismList);
// }
// private UserOrganismRepository() {
// this(PMBSettings.getInstance().getOrganismList());
// }
//
// public static void resetToSettings() {
// _instance = new UserOrganismRepository();
// }
//
// public static ArrayList<Organism> getDefaultOrganismList() {
// ArrayList<Organism> organismList = new ArrayList<Organism>();
// organismList.add(new Organism("Homo sapiens", "HUMAN", "Human", 9606));
// organismList.add(new Organism("Arabidopsis thaliana", "ARATH", "Mouse-ear cress", 3702));
// organismList.add(new Organism("Caenorhabditis elegans", "CAEEL", "", 6239));
// organismList.add(new Organism("Drosophila melanogaster", "DROME", "Fruit fly", 7227));
// organismList.add(new Organism("Mus musculus", "MOUSE", "Mouse", 10090));
// organismList.add(new Organism("Saccharomyces cerevisiae (strain ATCC 204508 / S288c)", "YEAST", "Baker's yeast", 559292));
// organismList.add(new Organism("Schizosaccharomyces pombe (strain 972 / ATCC 24843)", "SCHPO", "Fission yeast", 284812));
// organismList.add(new Organism("Plasmodium falciparum (isolate 3D7)", "PLAF7", "", 36329));
// organismList.add(new Organism("Gallus gallus", "CHICK", "Chicken", 9031));
// return organismList;
// }
//
// public void removeOrganism(Organism o) {
// organisms.remove(o);
// PMBProteinOrthologCacheClient.getInstance().emptyCacheLinkedToOrganism(o);
// }
//
// public void addOrganism(String scientificName) {
// Organism orga = InParanoidOrganismRepository.getInstance().getOrganismByScientificName(scientificName);
// if (orga != null) {
// organisms.add(orga);
// }
// }
//
// public void removeOrganismExceptLastOne(String scientificName) {
// if (organisms.size() > 1)
// removeOrganism(getOrganismByScientificName(scientificName));
// else
// JOptionPane.showMessageDialog(null, "Please keep at least one organism", "Deletion impossible", JOptionPane.INFORMATION_MESSAGE);
// }
//
// }
// Path: src/test/java/ch/picard/ppimapbuilder/data/protein/ortholog/client/cache/loader/InParanoidCacheLoaderTaskFactoryTest.java
import java.util.List;
import ch.picard.ppimapbuilder.TestUtils;
import ch.picard.ppimapbuilder.data.organism.Organism;
import ch.picard.ppimapbuilder.data.organism.UserOrganismRepository;
import ch.picard.ppimapbuilder.data.settings.PMBSettings;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.protein.ortholog.client.cache.loader;
public class InParanoidCacheLoaderTaskFactoryTest {
private static File testFolderOutput;
@BeforeClass
public static void before() throws IOException { | testFolderOutput = TestUtils.createTestOutputFolder(InParanoidCacheLoaderTaskFactoryTest.class.getSimpleName()); |
PPiMapBuilder/PPiMapBuilder | src/test/java/ch/picard/ppimapbuilder/data/protein/ortholog/client/cache/loader/InParanoidCacheLoaderTaskFactoryTest.java | // Path: src/test/java/ch/picard/ppimapbuilder/TestUtils.java
// public class TestUtils {
//
// private static final boolean deleteAtShutDown = false;
// private static final File baseTestOutputFolder = new File("test-output");
//
// public static File createTestOutputFolder(String preffix) {
// final File testFolderOutput = getTestOutputFolder(preffix + "-output-" + System.currentTimeMillis());
// testFolderOutput.mkdir();
//
// if(deleteAtShutDown) {
// Runtime.getRuntime().addShutdownHook(new Thread(){
// @Override
// public void run() {
// FileUtil.recursiveDelete(testFolderOutput);
// }
// });
// }
//
// return testFolderOutput;
// }
//
// public static File getBaseTestOutputFolder() {
// return baseTestOutputFolder;
// }
//
// public static File getTestOutputFolder(String folderName) {
// return new File(baseTestOutputFolder, folderName);
// }
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/data/organism/UserOrganismRepository.java
// public class UserOrganismRepository extends OrganismRepository {
//
// private static UserOrganismRepository _instance;
//
// public static UserOrganismRepository getInstance() {
// if (_instance == null)
// _instance = new UserOrganismRepository();
// return _instance;
// }
//
// private UserOrganismRepository(List<Organism> organismList) {
// super(organismList);
// }
// private UserOrganismRepository() {
// this(PMBSettings.getInstance().getOrganismList());
// }
//
// public static void resetToSettings() {
// _instance = new UserOrganismRepository();
// }
//
// public static ArrayList<Organism> getDefaultOrganismList() {
// ArrayList<Organism> organismList = new ArrayList<Organism>();
// organismList.add(new Organism("Homo sapiens", "HUMAN", "Human", 9606));
// organismList.add(new Organism("Arabidopsis thaliana", "ARATH", "Mouse-ear cress", 3702));
// organismList.add(new Organism("Caenorhabditis elegans", "CAEEL", "", 6239));
// organismList.add(new Organism("Drosophila melanogaster", "DROME", "Fruit fly", 7227));
// organismList.add(new Organism("Mus musculus", "MOUSE", "Mouse", 10090));
// organismList.add(new Organism("Saccharomyces cerevisiae (strain ATCC 204508 / S288c)", "YEAST", "Baker's yeast", 559292));
// organismList.add(new Organism("Schizosaccharomyces pombe (strain 972 / ATCC 24843)", "SCHPO", "Fission yeast", 284812));
// organismList.add(new Organism("Plasmodium falciparum (isolate 3D7)", "PLAF7", "", 36329));
// organismList.add(new Organism("Gallus gallus", "CHICK", "Chicken", 9031));
// return organismList;
// }
//
// public void removeOrganism(Organism o) {
// organisms.remove(o);
// PMBProteinOrthologCacheClient.getInstance().emptyCacheLinkedToOrganism(o);
// }
//
// public void addOrganism(String scientificName) {
// Organism orga = InParanoidOrganismRepository.getInstance().getOrganismByScientificName(scientificName);
// if (orga != null) {
// organisms.add(orga);
// }
// }
//
// public void removeOrganismExceptLastOne(String scientificName) {
// if (organisms.size() > 1)
// removeOrganism(getOrganismByScientificName(scientificName));
// else
// JOptionPane.showMessageDialog(null, "Please keep at least one organism", "Deletion impossible", JOptionPane.INFORMATION_MESSAGE);
// }
//
// }
| import java.util.List;
import ch.picard.ppimapbuilder.TestUtils;
import ch.picard.ppimapbuilder.data.organism.Organism;
import ch.picard.ppimapbuilder.data.organism.UserOrganismRepository;
import ch.picard.ppimapbuilder.data.settings.PMBSettings;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.Arrays; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.protein.ortholog.client.cache.loader;
public class InParanoidCacheLoaderTaskFactoryTest {
private static File testFolderOutput;
@BeforeClass
public static void before() throws IOException {
testFolderOutput = TestUtils.createTestOutputFolder(InParanoidCacheLoaderTaskFactoryTest.class.getSimpleName());
PMBSettings.getInstance().setOrthologCacheFolder(testFolderOutput);
}
@Test
public void testLoadInCache() throws Exception {
List<Organism> organisms = Arrays.asList( | // Path: src/test/java/ch/picard/ppimapbuilder/TestUtils.java
// public class TestUtils {
//
// private static final boolean deleteAtShutDown = false;
// private static final File baseTestOutputFolder = new File("test-output");
//
// public static File createTestOutputFolder(String preffix) {
// final File testFolderOutput = getTestOutputFolder(preffix + "-output-" + System.currentTimeMillis());
// testFolderOutput.mkdir();
//
// if(deleteAtShutDown) {
// Runtime.getRuntime().addShutdownHook(new Thread(){
// @Override
// public void run() {
// FileUtil.recursiveDelete(testFolderOutput);
// }
// });
// }
//
// return testFolderOutput;
// }
//
// public static File getBaseTestOutputFolder() {
// return baseTestOutputFolder;
// }
//
// public static File getTestOutputFolder(String folderName) {
// return new File(baseTestOutputFolder, folderName);
// }
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/data/organism/UserOrganismRepository.java
// public class UserOrganismRepository extends OrganismRepository {
//
// private static UserOrganismRepository _instance;
//
// public static UserOrganismRepository getInstance() {
// if (_instance == null)
// _instance = new UserOrganismRepository();
// return _instance;
// }
//
// private UserOrganismRepository(List<Organism> organismList) {
// super(organismList);
// }
// private UserOrganismRepository() {
// this(PMBSettings.getInstance().getOrganismList());
// }
//
// public static void resetToSettings() {
// _instance = new UserOrganismRepository();
// }
//
// public static ArrayList<Organism> getDefaultOrganismList() {
// ArrayList<Organism> organismList = new ArrayList<Organism>();
// organismList.add(new Organism("Homo sapiens", "HUMAN", "Human", 9606));
// organismList.add(new Organism("Arabidopsis thaliana", "ARATH", "Mouse-ear cress", 3702));
// organismList.add(new Organism("Caenorhabditis elegans", "CAEEL", "", 6239));
// organismList.add(new Organism("Drosophila melanogaster", "DROME", "Fruit fly", 7227));
// organismList.add(new Organism("Mus musculus", "MOUSE", "Mouse", 10090));
// organismList.add(new Organism("Saccharomyces cerevisiae (strain ATCC 204508 / S288c)", "YEAST", "Baker's yeast", 559292));
// organismList.add(new Organism("Schizosaccharomyces pombe (strain 972 / ATCC 24843)", "SCHPO", "Fission yeast", 284812));
// organismList.add(new Organism("Plasmodium falciparum (isolate 3D7)", "PLAF7", "", 36329));
// organismList.add(new Organism("Gallus gallus", "CHICK", "Chicken", 9031));
// return organismList;
// }
//
// public void removeOrganism(Organism o) {
// organisms.remove(o);
// PMBProteinOrthologCacheClient.getInstance().emptyCacheLinkedToOrganism(o);
// }
//
// public void addOrganism(String scientificName) {
// Organism orga = InParanoidOrganismRepository.getInstance().getOrganismByScientificName(scientificName);
// if (orga != null) {
// organisms.add(orga);
// }
// }
//
// public void removeOrganismExceptLastOne(String scientificName) {
// if (organisms.size() > 1)
// removeOrganism(getOrganismByScientificName(scientificName));
// else
// JOptionPane.showMessageDialog(null, "Please keep at least one organism", "Deletion impossible", JOptionPane.INFORMATION_MESSAGE);
// }
//
// }
// Path: src/test/java/ch/picard/ppimapbuilder/data/protein/ortholog/client/cache/loader/InParanoidCacheLoaderTaskFactoryTest.java
import java.util.List;
import ch.picard.ppimapbuilder.TestUtils;
import ch.picard.ppimapbuilder.data.organism.Organism;
import ch.picard.ppimapbuilder.data.organism.UserOrganismRepository;
import ch.picard.ppimapbuilder.data.settings.PMBSettings;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.protein.ortholog.client.cache.loader;
public class InParanoidCacheLoaderTaskFactoryTest {
private static File testFolderOutput;
@BeforeClass
public static void before() throws IOException {
testFolderOutput = TestUtils.createTestOutputFolder(InParanoidCacheLoaderTaskFactoryTest.class.getSimpleName());
PMBSettings.getInstance().setOrthologCacheFolder(testFolderOutput);
}
@Test
public void testLoadInCache() throws Exception {
List<Organism> organisms = Arrays.asList( | UserOrganismRepository.getInstance().getOrganismByTaxId(9606), |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/data/interaction/client/web/PsicquicRequest.java | // Path: src/main/java/ch/picard/ppimapbuilder/util/iterators/EmptyIterator.java
// public class EmptyIterator<T> implements Iterator<T> {
//
// @Override
// public boolean hasNext() {
// return false;
// }
//
// @Override
// public T next() {
// return null;
// }
//
// @Override
// public void remove() {
//
// }
//
// }
| import ch.picard.ppimapbuilder.util.concurrent.IteratorRequest;
import ch.picard.ppimapbuilder.util.iterators.EmptyIterator;
import org.hupo.psi.mi.psicquic.wsclient.PsicquicSimpleClient;
import psidev.psi.mi.tab.PsimiTabReader;
import psidev.psi.mi.tab.model.BinaryInteraction;
import java.io.IOException;
import java.util.Iterator; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.interaction.client.web;
public class PsicquicRequest implements IteratorRequest<BinaryInteraction> {
private final PsicquicSimpleClient client;
private final String query;
private final int firstResult;
private final int maxResults;
private final PsimiTabReader psimiTabReader;
private final static int MAX_TRY = 3;
protected PsicquicRequest(PsicquicSimpleClient client, String query, int firstResult, int maxResults) {
this.client = client;
this.query = query;
this.firstResult = firstResult;
this.maxResults = maxResults;
this.psimiTabReader = new PsimiTabReader();
}
@Override
public Iterator<BinaryInteraction> call() throws Exception {
int ntry = 0;
while (++ntry <= MAX_TRY) {
try {
return psimiTabReader.iterate(
client.getByQuery(
query,
PsicquicSimpleClient.MITAB25,
firstResult,
maxResults
)
);
} catch (IOException ignored) {}
} | // Path: src/main/java/ch/picard/ppimapbuilder/util/iterators/EmptyIterator.java
// public class EmptyIterator<T> implements Iterator<T> {
//
// @Override
// public boolean hasNext() {
// return false;
// }
//
// @Override
// public T next() {
// return null;
// }
//
// @Override
// public void remove() {
//
// }
//
// }
// Path: src/main/java/ch/picard/ppimapbuilder/data/interaction/client/web/PsicquicRequest.java
import ch.picard.ppimapbuilder.util.concurrent.IteratorRequest;
import ch.picard.ppimapbuilder.util.iterators.EmptyIterator;
import org.hupo.psi.mi.psicquic.wsclient.PsicquicSimpleClient;
import psidev.psi.mi.tab.PsimiTabReader;
import psidev.psi.mi.tab.model.BinaryInteraction;
import java.io.IOException;
import java.util.Iterator;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.interaction.client.web;
public class PsicquicRequest implements IteratorRequest<BinaryInteraction> {
private final PsicquicSimpleClient client;
private final String query;
private final int firstResult;
private final int maxResults;
private final PsimiTabReader psimiTabReader;
private final static int MAX_TRY = 3;
protected PsicquicRequest(PsicquicSimpleClient client, String query, int firstResult, int maxResults) {
this.client = client;
this.query = query;
this.firstResult = firstResult;
this.maxResults = maxResults;
this.psimiTabReader = new PsimiTabReader();
}
@Override
public Iterator<BinaryInteraction> call() throws Exception {
int ntry = 0;
while (++ntry <= MAX_TRY) {
try {
return psimiTabReader.iterate(
client.getByQuery(
query,
PsicquicSimpleClient.MITAB25,
firstResult,
maxResults
)
);
} catch (IOException ignored) {}
} | return new EmptyIterator<BinaryInteraction>(); |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/util/concurrent/ConcurrentFetcherIterator.java | // Path: src/main/java/ch/picard/ppimapbuilder/util/iterators/IteratorChain.java
// public class IteratorChain<E> implements Iterator<E> {
//
// /**
// * The chain of iterators
// */
// private final Queue<Iterator<? extends E>> iteratorChain = new LinkedList<Iterator<? extends E>>();
//
// /**
// * The current iterator
// */
// private Iterator<? extends E> currentIterator = null;
//
// /**
// * Construct an IteratorChain with no Iterators.
// * <p/>
// * You will normally use {@link #addIterator(Iterator)} to add some
// * iterators after using this constructor.
// */
// public IteratorChain() {
// super();
// }
//
// /**
// * Add an Iterator to the end of the chain
// *
// * @param iterator Iterator to add
// * @throws IllegalStateException if I've already started iterating
// * @throws NullPointerException if the iterator is null
// */
// public void addIterator(final Iterator<? extends E> iterator) {
// iteratorChain.add(iterator);
// }
//
// /**
// * Returns the remaining number of Iterators in the current IteratorChain.
// *
// * @return Iterator count
// */
// public int size() {
// return iteratorChain.size();
// }
//
// /**
// * Updates the current iterator field to ensure that the current Iterator is
// * not exhausted
// */
// protected void updateCurrentIterator() {
// if (currentIterator == null) {
// if (iteratorChain.isEmpty()) {
// currentIterator = new EmptyIterator<E>();
// } else {
// currentIterator = iteratorChain.remove();
// }
// // set last used iterator here, in case the user calls remove
// // before calling hasNext() or next() (although they shouldn't)
// }
//
// while (currentIterator.hasNext() == false && !iteratorChain.isEmpty()) {
// currentIterator = iteratorChain.remove();
// }
// }
//
// /**
// * Return true if any Iterator in the IteratorChain has a remaining element.
// *
// * @return true if elements remain
// */
// public boolean hasNext() {
// updateCurrentIterator();
// return currentIterator.hasNext();
// }
//
// /**
// * Returns the next Object of the current Iterator
// *
// * @return Object from the current Iterator
// * @throws java.util.NoSuchElementException if all the Iterators are
// * exhausted
// */
// public E next() {
// updateCurrentIterator();
// return currentIterator.next();
// }
//
// @Override
// public void remove() {}
//
// }
| import ch.picard.ppimapbuilder.util.iterators.IteratorChain;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit; | package ch.picard.ppimapbuilder.util.concurrent;
/**
* an Iterator producing a "stream" of object from a list of concurrent iterator requests
* @param <T>
*/
public class ConcurrentFetcherIterator<T> implements Iterator<T> {
private boolean canceled = false; | // Path: src/main/java/ch/picard/ppimapbuilder/util/iterators/IteratorChain.java
// public class IteratorChain<E> implements Iterator<E> {
//
// /**
// * The chain of iterators
// */
// private final Queue<Iterator<? extends E>> iteratorChain = new LinkedList<Iterator<? extends E>>();
//
// /**
// * The current iterator
// */
// private Iterator<? extends E> currentIterator = null;
//
// /**
// * Construct an IteratorChain with no Iterators.
// * <p/>
// * You will normally use {@link #addIterator(Iterator)} to add some
// * iterators after using this constructor.
// */
// public IteratorChain() {
// super();
// }
//
// /**
// * Add an Iterator to the end of the chain
// *
// * @param iterator Iterator to add
// * @throws IllegalStateException if I've already started iterating
// * @throws NullPointerException if the iterator is null
// */
// public void addIterator(final Iterator<? extends E> iterator) {
// iteratorChain.add(iterator);
// }
//
// /**
// * Returns the remaining number of Iterators in the current IteratorChain.
// *
// * @return Iterator count
// */
// public int size() {
// return iteratorChain.size();
// }
//
// /**
// * Updates the current iterator field to ensure that the current Iterator is
// * not exhausted
// */
// protected void updateCurrentIterator() {
// if (currentIterator == null) {
// if (iteratorChain.isEmpty()) {
// currentIterator = new EmptyIterator<E>();
// } else {
// currentIterator = iteratorChain.remove();
// }
// // set last used iterator here, in case the user calls remove
// // before calling hasNext() or next() (although they shouldn't)
// }
//
// while (currentIterator.hasNext() == false && !iteratorChain.isEmpty()) {
// currentIterator = iteratorChain.remove();
// }
// }
//
// /**
// * Return true if any Iterator in the IteratorChain has a remaining element.
// *
// * @return true if elements remain
// */
// public boolean hasNext() {
// updateCurrentIterator();
// return currentIterator.hasNext();
// }
//
// /**
// * Returns the next Object of the current Iterator
// *
// * @return Object from the current Iterator
// * @throws java.util.NoSuchElementException if all the Iterators are
// * exhausted
// */
// public E next() {
// updateCurrentIterator();
// return currentIterator.next();
// }
//
// @Override
// public void remove() {}
//
// }
// Path: src/main/java/ch/picard/ppimapbuilder/util/concurrent/ConcurrentFetcherIterator.java
import ch.picard.ppimapbuilder.util.iterators.IteratorChain;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
package ch.picard.ppimapbuilder.util.concurrent;
/**
* an Iterator producing a "stream" of object from a list of concurrent iterator requests
* @param <T>
*/
public class ConcurrentFetcherIterator<T> implements Iterator<T> {
private boolean canceled = false; | private final IteratorChain<T> innerIterator; |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/data/interaction/client/web/PsicquicRequestBuilder.java | // Path: src/main/java/ch/picard/ppimapbuilder/data/interaction/client/web/miql/MiQLParameterBuilder.java
// public class MiQLParameterBuilder extends AbstractMiQLQueryElement {
//
// public MiQLParameterBuilder(AbstractMiQLQueryElement value) {
// super(value);
// }
//
// public MiQLParameterBuilder(String value) {
// super(value);
// }
//
// public MiQLParameterBuilder(String name, String value) {
// this(name, (Object)value);
// }
//
// public MiQLParameterBuilder(String name, AbstractMiQLQueryElement value) {
// this(name, (Object)value);
// }
//
// public MiQLParameterBuilder(String name, Object value) {
// super(name+":");
//
// if(value instanceof AbstractMiQLQueryElement) add((AbstractMiQLQueryElement) value);
// else add(value.toString());
// }
// }
| import java.util.List;
import java.util.Set;
import ch.picard.ppimapbuilder.data.interaction.client.web.miql.MiQLExpressionBuilder;
import ch.picard.ppimapbuilder.data.interaction.client.web.miql.MiQLParameterBuilder;
import com.google.common.collect.Lists;
import org.hupo.psi.mi.psicquic.wsclient.PsicquicSimpleClient;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collection; | */
public PsicquicRequestBuilder addQuery(final String query) {
for (PsicquicSimpleClient client : clients) {
try {
long count = client.countByQuery(query);
estimatedInteractionsCount += count;
final int numberPages = (int) Math.ceil((double) count / (double) maxResultsPerPages);
for (int page = 0; page < numberPages; page++) {
final int firstResult = page * maxResultsPerPages;
requests.add(new PsicquicRequest(client, query, firstResult, maxResultsPerPages));
}
} catch (IOException e) {
requests.add(new PsicquicRequest(client, query, 0, Integer.MAX_VALUE));
}
}
return this;
}
public PsicquicRequestBuilder addQueries(List<String> queries) {
for (String query : queries) {
addQuery(query);
}
return this;
}
public PsicquicRequestBuilder addGetByTaxon(final Integer taxonId) {
MiQLExpressionBuilder query = new MiQLExpressionBuilder();
query.setRoot(true); | // Path: src/main/java/ch/picard/ppimapbuilder/data/interaction/client/web/miql/MiQLParameterBuilder.java
// public class MiQLParameterBuilder extends AbstractMiQLQueryElement {
//
// public MiQLParameterBuilder(AbstractMiQLQueryElement value) {
// super(value);
// }
//
// public MiQLParameterBuilder(String value) {
// super(value);
// }
//
// public MiQLParameterBuilder(String name, String value) {
// this(name, (Object)value);
// }
//
// public MiQLParameterBuilder(String name, AbstractMiQLQueryElement value) {
// this(name, (Object)value);
// }
//
// public MiQLParameterBuilder(String name, Object value) {
// super(name+":");
//
// if(value instanceof AbstractMiQLQueryElement) add((AbstractMiQLQueryElement) value);
// else add(value.toString());
// }
// }
// Path: src/main/java/ch/picard/ppimapbuilder/data/interaction/client/web/PsicquicRequestBuilder.java
import java.util.List;
import java.util.Set;
import ch.picard.ppimapbuilder.data.interaction.client.web.miql.MiQLExpressionBuilder;
import ch.picard.ppimapbuilder.data.interaction.client.web.miql.MiQLParameterBuilder;
import com.google.common.collect.Lists;
import org.hupo.psi.mi.psicquic.wsclient.PsicquicSimpleClient;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collection;
*/
public PsicquicRequestBuilder addQuery(final String query) {
for (PsicquicSimpleClient client : clients) {
try {
long count = client.countByQuery(query);
estimatedInteractionsCount += count;
final int numberPages = (int) Math.ceil((double) count / (double) maxResultsPerPages);
for (int page = 0; page < numberPages; page++) {
final int firstResult = page * maxResultsPerPages;
requests.add(new PsicquicRequest(client, query, firstResult, maxResultsPerPages));
}
} catch (IOException e) {
requests.add(new PsicquicRequest(client, query, 0, Integer.MAX_VALUE));
}
}
return this;
}
public PsicquicRequestBuilder addQueries(List<String> queries) {
for (String query : queries) {
addQuery(query);
}
return this;
}
public PsicquicRequestBuilder addGetByTaxon(final Integer taxonId) {
MiQLExpressionBuilder query = new MiQLExpressionBuilder();
query.setRoot(true); | query.add(new MiQLParameterBuilder("taxidA", taxonId)); |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/ui/querywindow/component/panel/CustomSplitPane.java | // Path: src/main/java/ch/picard/ppimapbuilder/ui/util/PMBUIStyle.java
// public class PMBUIStyle {
//
// private static Color defaultPanelColor = UIManager.getColor("Panel.background");
// private static float hsbVals[] = Color.RGBtoHSB(
// defaultPanelColor.getRed(),
// defaultPanelColor.getGreen(),
// defaultPanelColor.getBlue(),
// null
// );
//
// public static final Color blurActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color blurInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.95f);
//
// public static final Color focusActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color focusInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.84f);
//
// public static final Color defaultBorderColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.94f);
//
// public static final Border defaultComponentBorder = new LineBorder(defaultBorderColor, 1);
// public static final Border fancyPanelBorder = new CompoundBorder(
// // Outside border 1px bottom light color
// new MatteBorder(0, 0, 1, 0, Color.WHITE),
// // Border all around panel 1px dark grey
// defaultComponentBorder
// );
// public static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
//
// }
| import ch.picard.ppimapbuilder.ui.util.PMBUIStyle;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.MatteBorder;
import javax.swing.plaf.basic.BasicSplitPaneDivider;
import javax.swing.plaf.basic.BasicSplitPaneUI;
import java.awt.*;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.ui.querywindow.component.panel;
public class CustomSplitPane extends JSplitPane implements FocusListener {
private static final long serialVersionUID = 1L;
private final Border focusBorder;
private final Border blurBorder;
private final Color focusColor;
private final Color blurColor;
public CustomSplitPane(Color focusColor, Color blurColor) {
super(JSplitPane.HORIZONTAL_SPLIT, true);
setUI(new BasicSplitPaneUI(){
@Override
public BasicSplitPaneDivider createDefaultDivider() {
return new BasicSplitPaneDivider(this) {
@Override
public void paint(Graphics g) {
super.paint(g);
//g.setColor(bgColor);
//g.fillRect(0, 0, getSize().width, getSize().height);
Graphics2D g2d = (Graphics2D) g;
int h = 12;
int w = 2;
int x = (getWidth() - w) / 2;
int y = (getHeight() - h) / 2; | // Path: src/main/java/ch/picard/ppimapbuilder/ui/util/PMBUIStyle.java
// public class PMBUIStyle {
//
// private static Color defaultPanelColor = UIManager.getColor("Panel.background");
// private static float hsbVals[] = Color.RGBtoHSB(
// defaultPanelColor.getRed(),
// defaultPanelColor.getGreen(),
// defaultPanelColor.getBlue(),
// null
// );
//
// public static final Color blurActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color blurInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.95f);
//
// public static final Color focusActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color focusInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.84f);
//
// public static final Color defaultBorderColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.94f);
//
// public static final Border defaultComponentBorder = new LineBorder(defaultBorderColor, 1);
// public static final Border fancyPanelBorder = new CompoundBorder(
// // Outside border 1px bottom light color
// new MatteBorder(0, 0, 1, 0, Color.WHITE),
// // Border all around panel 1px dark grey
// defaultComponentBorder
// );
// public static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
//
// }
// Path: src/main/java/ch/picard/ppimapbuilder/ui/querywindow/component/panel/CustomSplitPane.java
import ch.picard.ppimapbuilder.ui.util.PMBUIStyle;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.MatteBorder;
import javax.swing.plaf.basic.BasicSplitPaneDivider;
import javax.swing.plaf.basic.BasicSplitPaneUI;
import java.awt.*;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.ui.querywindow.component.panel;
public class CustomSplitPane extends JSplitPane implements FocusListener {
private static final long serialVersionUID = 1L;
private final Border focusBorder;
private final Border blurBorder;
private final Color focusColor;
private final Color blurColor;
public CustomSplitPane(Color focusColor, Color blurColor) {
super(JSplitPane.HORIZONTAL_SPLIT, true);
setUI(new BasicSplitPaneUI(){
@Override
public BasicSplitPaneDivider createDefaultDivider() {
return new BasicSplitPaneDivider(this) {
@Override
public void paint(Graphics g) {
super.paint(g);
//g.setColor(bgColor);
//g.fillRect(0, 0, getSize().width, getSize().height);
Graphics2D g2d = (Graphics2D) g;
int h = 12;
int w = 2;
int x = (getWidth() - w) / 2;
int y = (getHeight() - h) / 2; | g2d.setColor(PMBUIStyle.defaultBorderColor); |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/ui/querywindow/component/panel/field/DatabaseSelectionPanel.java | // Path: src/main/java/ch/picard/ppimapbuilder/ui/util/PMBUIStyle.java
// public class PMBUIStyle {
//
// private static Color defaultPanelColor = UIManager.getColor("Panel.background");
// private static float hsbVals[] = Color.RGBtoHSB(
// defaultPanelColor.getRed(),
// defaultPanelColor.getGreen(),
// defaultPanelColor.getBlue(),
// null
// );
//
// public static final Color blurActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color blurInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.95f);
//
// public static final Color focusActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color focusInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.84f);
//
// public static final Color defaultBorderColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.94f);
//
// public static final Border defaultComponentBorder = new LineBorder(defaultBorderColor, 1);
// public static final Border fancyPanelBorder = new CompoundBorder(
// // Outside border 1px bottom light color
// new MatteBorder(0, 0, 1, 0, Color.WHITE),
// // Border all around panel 1px dark grey
// defaultComponentBorder
// );
// public static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
//
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/ui/util/label/HelpIcon.java
// public class HelpIcon extends JLabel{
// private static final long serialVersionUID = 1L;
//
// public HelpIcon(String message) {
// super();
// try {
// setIcon(new ImageIcon(HelpIcon.class.getResource("help.png")));
// } catch (Exception e) {
// setText("[?]");
// }
// setToolTipText(message);
// }
// }
| import java.util.Map.Entry;
import ch.picard.ppimapbuilder.data.interaction.client.web.PsicquicService;
import ch.picard.ppimapbuilder.data.settings.PMBSettings;
import ch.picard.ppimapbuilder.ui.util.PMBUIStyle;
import ch.picard.ppimapbuilder.ui.util.label.HelpIcon;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.util.List; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.ui.querywindow.component.panel.field;
public class DatabaseSelectionPanel extends JPanel {
private static final long serialVersionUID = 1L;
private final LinkedHashMap<PsicquicService, JCheckBox> databases;
private final JPanel panSourceDatabases;
public DatabaseSelectionPanel() {
setLayout(new MigLayout("ins 0", "[grow][]", "[][grow]"));
setOpaque(false);
// Source databases label
JLabel lblSourceDatabases = new JLabel("Source databases:");
add(lblSourceDatabases);
// Source databases Help Icon | // Path: src/main/java/ch/picard/ppimapbuilder/ui/util/PMBUIStyle.java
// public class PMBUIStyle {
//
// private static Color defaultPanelColor = UIManager.getColor("Panel.background");
// private static float hsbVals[] = Color.RGBtoHSB(
// defaultPanelColor.getRed(),
// defaultPanelColor.getGreen(),
// defaultPanelColor.getBlue(),
// null
// );
//
// public static final Color blurActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color blurInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.95f);
//
// public static final Color focusActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color focusInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.84f);
//
// public static final Color defaultBorderColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.94f);
//
// public static final Border defaultComponentBorder = new LineBorder(defaultBorderColor, 1);
// public static final Border fancyPanelBorder = new CompoundBorder(
// // Outside border 1px bottom light color
// new MatteBorder(0, 0, 1, 0, Color.WHITE),
// // Border all around panel 1px dark grey
// defaultComponentBorder
// );
// public static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
//
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/ui/util/label/HelpIcon.java
// public class HelpIcon extends JLabel{
// private static final long serialVersionUID = 1L;
//
// public HelpIcon(String message) {
// super();
// try {
// setIcon(new ImageIcon(HelpIcon.class.getResource("help.png")));
// } catch (Exception e) {
// setText("[?]");
// }
// setToolTipText(message);
// }
// }
// Path: src/main/java/ch/picard/ppimapbuilder/ui/querywindow/component/panel/field/DatabaseSelectionPanel.java
import java.util.Map.Entry;
import ch.picard.ppimapbuilder.data.interaction.client.web.PsicquicService;
import ch.picard.ppimapbuilder.data.settings.PMBSettings;
import ch.picard.ppimapbuilder.ui.util.PMBUIStyle;
import ch.picard.ppimapbuilder.ui.util.label.HelpIcon;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.util.List;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.ui.querywindow.component.panel.field;
public class DatabaseSelectionPanel extends JPanel {
private static final long serialVersionUID = 1L;
private final LinkedHashMap<PsicquicService, JCheckBox> databases;
private final JPanel panSourceDatabases;
public DatabaseSelectionPanel() {
setLayout(new MigLayout("ins 0", "[grow][]", "[][grow]"));
setOpaque(false);
// Source databases label
JLabel lblSourceDatabases = new JLabel("Source databases:");
add(lblSourceDatabases);
// Source databases Help Icon | JLabel lblHelpSourceDatabase = new HelpIcon("Select here the databases from which the interactions will be retrieved"); |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/ui/querywindow/component/panel/field/DatabaseSelectionPanel.java | // Path: src/main/java/ch/picard/ppimapbuilder/ui/util/PMBUIStyle.java
// public class PMBUIStyle {
//
// private static Color defaultPanelColor = UIManager.getColor("Panel.background");
// private static float hsbVals[] = Color.RGBtoHSB(
// defaultPanelColor.getRed(),
// defaultPanelColor.getGreen(),
// defaultPanelColor.getBlue(),
// null
// );
//
// public static final Color blurActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color blurInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.95f);
//
// public static final Color focusActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color focusInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.84f);
//
// public static final Color defaultBorderColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.94f);
//
// public static final Border defaultComponentBorder = new LineBorder(defaultBorderColor, 1);
// public static final Border fancyPanelBorder = new CompoundBorder(
// // Outside border 1px bottom light color
// new MatteBorder(0, 0, 1, 0, Color.WHITE),
// // Border all around panel 1px dark grey
// defaultComponentBorder
// );
// public static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
//
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/ui/util/label/HelpIcon.java
// public class HelpIcon extends JLabel{
// private static final long serialVersionUID = 1L;
//
// public HelpIcon(String message) {
// super();
// try {
// setIcon(new ImageIcon(HelpIcon.class.getResource("help.png")));
// } catch (Exception e) {
// setText("[?]");
// }
// setToolTipText(message);
// }
// }
| import java.util.Map.Entry;
import ch.picard.ppimapbuilder.data.interaction.client.web.PsicquicService;
import ch.picard.ppimapbuilder.data.settings.PMBSettings;
import ch.picard.ppimapbuilder.ui.util.PMBUIStyle;
import ch.picard.ppimapbuilder.ui.util.label.HelpIcon;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.util.List; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.ui.querywindow.component.panel.field;
public class DatabaseSelectionPanel extends JPanel {
private static final long serialVersionUID = 1L;
private final LinkedHashMap<PsicquicService, JCheckBox> databases;
private final JPanel panSourceDatabases;
public DatabaseSelectionPanel() {
setLayout(new MigLayout("ins 0", "[grow][]", "[][grow]"));
setOpaque(false);
// Source databases label
JLabel lblSourceDatabases = new JLabel("Source databases:");
add(lblSourceDatabases);
// Source databases Help Icon
JLabel lblHelpSourceDatabase = new HelpIcon("Select here the databases from which the interactions will be retrieved");
lblHelpSourceDatabase.setHorizontalAlignment(SwingConstants.RIGHT);
add(lblHelpSourceDatabase);
// Source databases scrollpane containing a panel that will contain checkbox at display
JScrollPane scrollPaneSourceDatabases = new JScrollPane(); | // Path: src/main/java/ch/picard/ppimapbuilder/ui/util/PMBUIStyle.java
// public class PMBUIStyle {
//
// private static Color defaultPanelColor = UIManager.getColor("Panel.background");
// private static float hsbVals[] = Color.RGBtoHSB(
// defaultPanelColor.getRed(),
// defaultPanelColor.getGreen(),
// defaultPanelColor.getBlue(),
// null
// );
//
// public static final Color blurActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color blurInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.95f);
//
// public static final Color focusActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color focusInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.84f);
//
// public static final Color defaultBorderColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.94f);
//
// public static final Border defaultComponentBorder = new LineBorder(defaultBorderColor, 1);
// public static final Border fancyPanelBorder = new CompoundBorder(
// // Outside border 1px bottom light color
// new MatteBorder(0, 0, 1, 0, Color.WHITE),
// // Border all around panel 1px dark grey
// defaultComponentBorder
// );
// public static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
//
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/ui/util/label/HelpIcon.java
// public class HelpIcon extends JLabel{
// private static final long serialVersionUID = 1L;
//
// public HelpIcon(String message) {
// super();
// try {
// setIcon(new ImageIcon(HelpIcon.class.getResource("help.png")));
// } catch (Exception e) {
// setText("[?]");
// }
// setToolTipText(message);
// }
// }
// Path: src/main/java/ch/picard/ppimapbuilder/ui/querywindow/component/panel/field/DatabaseSelectionPanel.java
import java.util.Map.Entry;
import ch.picard.ppimapbuilder.data.interaction.client.web.PsicquicService;
import ch.picard.ppimapbuilder.data.settings.PMBSettings;
import ch.picard.ppimapbuilder.ui.util.PMBUIStyle;
import ch.picard.ppimapbuilder.ui.util.label.HelpIcon;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.util.List;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.ui.querywindow.component.panel.field;
public class DatabaseSelectionPanel extends JPanel {
private static final long serialVersionUID = 1L;
private final LinkedHashMap<PsicquicService, JCheckBox> databases;
private final JPanel panSourceDatabases;
public DatabaseSelectionPanel() {
setLayout(new MigLayout("ins 0", "[grow][]", "[][grow]"));
setOpaque(false);
// Source databases label
JLabel lblSourceDatabases = new JLabel("Source databases:");
add(lblSourceDatabases);
// Source databases Help Icon
JLabel lblHelpSourceDatabase = new HelpIcon("Select here the databases from which the interactions will be retrieved");
lblHelpSourceDatabase.setHorizontalAlignment(SwingConstants.RIGHT);
add(lblHelpSourceDatabase);
// Source databases scrollpane containing a panel that will contain checkbox at display
JScrollPane scrollPaneSourceDatabases = new JScrollPane(); | scrollPaneSourceDatabases.setBorder(PMBUIStyle.fancyPanelBorder); |
PPiMapBuilder/PPiMapBuilder | src/test/java/ch/picard/ppimapbuilder/TestUtils.java | // Path: src/main/java/ch/picard/ppimapbuilder/util/io/FileUtil.java
// public class FileUtil {
// public static void recursiveDelete(File file) {
// if (!file.exists())
// return;
// if (file.isDirectory()) {
// for (File f : file.listFiles()) {
// recursiveDelete(f);
// }
// }
// file.delete();
// }
//
// public static String getHumanReadableFileSize(File file) {
// return FileUtils.byteCountToDisplaySize(
// file.exists() ?
// getFileSizeRecursive(file) :
// 0
// );
// }
//
// private static long getFileSizeRecursive(File file) {
// if (file == null || !file.exists())
// return 0l;
// else {
// if (file.isDirectory()) {
// long cumul = 0l;
// for (File f : file.listFiles()) {
// cumul += getFileSizeRecursive(f);
// }
// return cumul;
// } else {
// return file.length();
// }
// }
// }
// }
| import java.io.File;
import ch.picard.ppimapbuilder.util.io.FileUtil; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder;
public class TestUtils {
private static final boolean deleteAtShutDown = false;
private static final File baseTestOutputFolder = new File("test-output");
public static File createTestOutputFolder(String preffix) {
final File testFolderOutput = getTestOutputFolder(preffix + "-output-" + System.currentTimeMillis());
testFolderOutput.mkdir();
if(deleteAtShutDown) {
Runtime.getRuntime().addShutdownHook(new Thread(){
@Override
public void run() { | // Path: src/main/java/ch/picard/ppimapbuilder/util/io/FileUtil.java
// public class FileUtil {
// public static void recursiveDelete(File file) {
// if (!file.exists())
// return;
// if (file.isDirectory()) {
// for (File f : file.listFiles()) {
// recursiveDelete(f);
// }
// }
// file.delete();
// }
//
// public static String getHumanReadableFileSize(File file) {
// return FileUtils.byteCountToDisplaySize(
// file.exists() ?
// getFileSizeRecursive(file) :
// 0
// );
// }
//
// private static long getFileSizeRecursive(File file) {
// if (file == null || !file.exists())
// return 0l;
// else {
// if (file.isDirectory()) {
// long cumul = 0l;
// for (File f : file.listFiles()) {
// cumul += getFileSizeRecursive(f);
// }
// return cumul;
// } else {
// return file.length();
// }
// }
// }
// }
// Path: src/test/java/ch/picard/ppimapbuilder/TestUtils.java
import java.io.File;
import ch.picard.ppimapbuilder.util.io.FileUtil;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder;
public class TestUtils {
private static final boolean deleteAtShutDown = false;
private static final File baseTestOutputFolder = new File("test-output");
public static File createTestOutputFolder(String preffix) {
final File testFolderOutput = getTestOutputFolder(preffix + "-output-" + System.currentTimeMillis());
testFolderOutput.mkdir();
if(deleteAtShutDown) {
Runtime.getRuntime().addShutdownHook(new Thread(){
@Override
public void run() { | FileUtil.recursiveDelete(testFolderOutput); |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/ui/querywindow/component/panel/field/OtherOrganismSelectionPanel.java | // Path: src/main/java/ch/picard/ppimapbuilder/ui/util/PMBUIStyle.java
// public class PMBUIStyle {
//
// private static Color defaultPanelColor = UIManager.getColor("Panel.background");
// private static float hsbVals[] = Color.RGBtoHSB(
// defaultPanelColor.getRed(),
// defaultPanelColor.getGreen(),
// defaultPanelColor.getBlue(),
// null
// );
//
// public static final Color blurActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color blurInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.95f);
//
// public static final Color focusActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color focusInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.84f);
//
// public static final Color defaultBorderColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.94f);
//
// public static final Border defaultComponentBorder = new LineBorder(defaultBorderColor, 1);
// public static final Border fancyPanelBorder = new CompoundBorder(
// // Outside border 1px bottom light color
// new MatteBorder(0, 0, 1, 0, Color.WHITE),
// // Border all around panel 1px dark grey
// defaultComponentBorder
// );
// public static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
//
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/ui/util/label/HelpIcon.java
// public class HelpIcon extends JLabel{
// private static final long serialVersionUID = 1L;
//
// public HelpIcon(String message) {
// super();
// try {
// setIcon(new ImageIcon(HelpIcon.class.getResource("help.png")));
// } catch (Exception e) {
// setText("[?]");
// }
// setToolTipText(message);
// }
// }
| import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import ch.picard.ppimapbuilder.data.organism.Organism;
import ch.picard.ppimapbuilder.ui.util.PMBUIStyle;
import ch.picard.ppimapbuilder.ui.util.label.HelpIcon;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import java.awt.*; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.ui.querywindow.component.panel.field;
public class OtherOrganismSelectionPanel extends JPanel {
private static final long serialVersionUID = 1L;
private final LinkedHashMap<Organism, JCheckBox> organismsCb;
private final JPanel panSourceOtherOrganisms;
private Organism disabledOrganism = null;
public OtherOrganismSelectionPanel() {
setLayout(new MigLayout("ins 0", "[grow][]", "[][grow]"));
setOpaque(false);
// Other organisms label
JLabel lblHomologOrganism = new JLabel("Other organisms:");
add(lblHomologOrganism);
// Other organisms Help Icon | // Path: src/main/java/ch/picard/ppimapbuilder/ui/util/PMBUIStyle.java
// public class PMBUIStyle {
//
// private static Color defaultPanelColor = UIManager.getColor("Panel.background");
// private static float hsbVals[] = Color.RGBtoHSB(
// defaultPanelColor.getRed(),
// defaultPanelColor.getGreen(),
// defaultPanelColor.getBlue(),
// null
// );
//
// public static final Color blurActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color blurInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.95f);
//
// public static final Color focusActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color focusInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.84f);
//
// public static final Color defaultBorderColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.94f);
//
// public static final Border defaultComponentBorder = new LineBorder(defaultBorderColor, 1);
// public static final Border fancyPanelBorder = new CompoundBorder(
// // Outside border 1px bottom light color
// new MatteBorder(0, 0, 1, 0, Color.WHITE),
// // Border all around panel 1px dark grey
// defaultComponentBorder
// );
// public static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
//
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/ui/util/label/HelpIcon.java
// public class HelpIcon extends JLabel{
// private static final long serialVersionUID = 1L;
//
// public HelpIcon(String message) {
// super();
// try {
// setIcon(new ImageIcon(HelpIcon.class.getResource("help.png")));
// } catch (Exception e) {
// setText("[?]");
// }
// setToolTipText(message);
// }
// }
// Path: src/main/java/ch/picard/ppimapbuilder/ui/querywindow/component/panel/field/OtherOrganismSelectionPanel.java
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import ch.picard.ppimapbuilder.data.organism.Organism;
import ch.picard.ppimapbuilder.ui.util.PMBUIStyle;
import ch.picard.ppimapbuilder.ui.util.label.HelpIcon;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import java.awt.*;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.ui.querywindow.component.panel.field;
public class OtherOrganismSelectionPanel extends JPanel {
private static final long serialVersionUID = 1L;
private final LinkedHashMap<Organism, JCheckBox> organismsCb;
private final JPanel panSourceOtherOrganisms;
private Organism disabledOrganism = null;
public OtherOrganismSelectionPanel() {
setLayout(new MigLayout("ins 0", "[grow][]", "[][grow]"));
setOpaque(false);
// Other organisms label
JLabel lblHomologOrganism = new JLabel("Other organisms:");
add(lblHomologOrganism);
// Other organisms Help Icon | JLabel lblHelpOtherOrganism = new HelpIcon("Select here the other organism in which you want to search homologous interactions"); |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/ui/querywindow/component/panel/field/OtherOrganismSelectionPanel.java | // Path: src/main/java/ch/picard/ppimapbuilder/ui/util/PMBUIStyle.java
// public class PMBUIStyle {
//
// private static Color defaultPanelColor = UIManager.getColor("Panel.background");
// private static float hsbVals[] = Color.RGBtoHSB(
// defaultPanelColor.getRed(),
// defaultPanelColor.getGreen(),
// defaultPanelColor.getBlue(),
// null
// );
//
// public static final Color blurActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color blurInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.95f);
//
// public static final Color focusActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color focusInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.84f);
//
// public static final Color defaultBorderColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.94f);
//
// public static final Border defaultComponentBorder = new LineBorder(defaultBorderColor, 1);
// public static final Border fancyPanelBorder = new CompoundBorder(
// // Outside border 1px bottom light color
// new MatteBorder(0, 0, 1, 0, Color.WHITE),
// // Border all around panel 1px dark grey
// defaultComponentBorder
// );
// public static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
//
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/ui/util/label/HelpIcon.java
// public class HelpIcon extends JLabel{
// private static final long serialVersionUID = 1L;
//
// public HelpIcon(String message) {
// super();
// try {
// setIcon(new ImageIcon(HelpIcon.class.getResource("help.png")));
// } catch (Exception e) {
// setText("[?]");
// }
// setToolTipText(message);
// }
// }
| import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import ch.picard.ppimapbuilder.data.organism.Organism;
import ch.picard.ppimapbuilder.ui.util.PMBUIStyle;
import ch.picard.ppimapbuilder.ui.util.label.HelpIcon;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import java.awt.*; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.ui.querywindow.component.panel.field;
public class OtherOrganismSelectionPanel extends JPanel {
private static final long serialVersionUID = 1L;
private final LinkedHashMap<Organism, JCheckBox> organismsCb;
private final JPanel panSourceOtherOrganisms;
private Organism disabledOrganism = null;
public OtherOrganismSelectionPanel() {
setLayout(new MigLayout("ins 0", "[grow][]", "[][grow]"));
setOpaque(false);
// Other organisms label
JLabel lblHomologOrganism = new JLabel("Other organisms:");
add(lblHomologOrganism);
// Other organisms Help Icon
JLabel lblHelpOtherOrganism = new HelpIcon("Select here the other organism in which you want to search homologous interactions");
lblHelpOtherOrganism.setHorizontalAlignment(SwingConstants.RIGHT);
add(lblHelpOtherOrganism);
// Other organisms scrollpane containing a panel that will contain checkbox at display
JScrollPane scrollPaneOtherOrganisms = new JScrollPane(); | // Path: src/main/java/ch/picard/ppimapbuilder/ui/util/PMBUIStyle.java
// public class PMBUIStyle {
//
// private static Color defaultPanelColor = UIManager.getColor("Panel.background");
// private static float hsbVals[] = Color.RGBtoHSB(
// defaultPanelColor.getRed(),
// defaultPanelColor.getGreen(),
// defaultPanelColor.getBlue(),
// null
// );
//
// public static final Color blurActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color blurInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.95f);
//
// public static final Color focusActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color focusInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.84f);
//
// public static final Color defaultBorderColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.94f);
//
// public static final Border defaultComponentBorder = new LineBorder(defaultBorderColor, 1);
// public static final Border fancyPanelBorder = new CompoundBorder(
// // Outside border 1px bottom light color
// new MatteBorder(0, 0, 1, 0, Color.WHITE),
// // Border all around panel 1px dark grey
// defaultComponentBorder
// );
// public static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
//
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/ui/util/label/HelpIcon.java
// public class HelpIcon extends JLabel{
// private static final long serialVersionUID = 1L;
//
// public HelpIcon(String message) {
// super();
// try {
// setIcon(new ImageIcon(HelpIcon.class.getResource("help.png")));
// } catch (Exception e) {
// setText("[?]");
// }
// setToolTipText(message);
// }
// }
// Path: src/main/java/ch/picard/ppimapbuilder/ui/querywindow/component/panel/field/OtherOrganismSelectionPanel.java
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import ch.picard.ppimapbuilder.data.organism.Organism;
import ch.picard.ppimapbuilder.ui.util.PMBUIStyle;
import ch.picard.ppimapbuilder.ui.util.label.HelpIcon;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import java.awt.*;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.ui.querywindow.component.panel.field;
public class OtherOrganismSelectionPanel extends JPanel {
private static final long serialVersionUID = 1L;
private final LinkedHashMap<Organism, JCheckBox> organismsCb;
private final JPanel panSourceOtherOrganisms;
private Organism disabledOrganism = null;
public OtherOrganismSelectionPanel() {
setLayout(new MigLayout("ins 0", "[grow][]", "[][grow]"));
setOpaque(false);
// Other organisms label
JLabel lblHomologOrganism = new JLabel("Other organisms:");
add(lblHomologOrganism);
// Other organisms Help Icon
JLabel lblHelpOtherOrganism = new HelpIcon("Select here the other organism in which you want to search homologous interactions");
lblHelpOtherOrganism.setHorizontalAlignment(SwingConstants.RIGHT);
add(lblHelpOtherOrganism);
// Other organisms scrollpane containing a panel that will contain checkbox at display
JScrollPane scrollPaneOtherOrganisms = new JScrollPane(); | scrollPaneOtherOrganisms.setViewportBorder(PMBUIStyle.emptyBorder); |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/data/protein/ortholog/client/AbstractProteinOrthologClient.java | // Path: src/main/java/ch/picard/ppimapbuilder/data/protein/ProteinUtils.java
// public class ProteinUtils {
//
// public static Set<Protein> newProteins(final Set<String> identifiers, final Organism organism) {
// final Set<Protein> out = new HashSet<Protein>();
// for(String id : identifiers)
// out.add(new Protein(id, organism));
// return out;
// }
//
// /**
// * Transform a Collection of Protein to a Collection of UniProt ID
// */
// public static Collection<String> asIdentifiers(final Collection<? extends Protein> proteins) {
// return asIdentifiers(new HashSet<Protein>(proteins));
// }
//
// /**
// * Transform a Set of Protein to a Collection of UniProt ID
// */
// public static Collection<String> asIdentifiers(final Set<? extends Protein> proteins) {
// final Set<String> out = new HashSet<String>();
// for (Protein protein : proteins)
// out.add(protein.getUniProtId());
// return out;
// }
//
// /**
// * Making sure a protein entry is from a specific organism. Will change the entry organism if the entry don't have
// * exactly the same organism as specified but is from the same species (differences can come from strains).
// */
// public static UniProtEntry correctEntryOrganism(UniProtEntry originalEntry, Organism organism) {
// if (
// !originalEntry.getOrganism().equals(organism) &&
// originalEntry.getOrganism().sameSpecies(organism)
// ) {
// return new UniProtEntry.Builder(originalEntry)
// .setOrganism(organism)
// .build();
// }
// return originalEntry;
// }
//
// /**
// * @author Kevin Gravouil
// */
// public static class UniProtId {
//
// /**
// * Uniprot ID pattern. According to
// * http://www.ebi.ac.uk/miriam/main/export/xml/
// */
// private final static Pattern pattern = Pattern.compile("([OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2})([\\-\\.]\\w+)?");
//
// /**
// * Test if a given string matches the Uniprot ID pattern (authorizing extension like "-1" or "-PRO_XXXXXX").
// */
// public static boolean isValid(String uniprotId) {
// Matcher matcher = pattern.matcher(uniprotId);
// return matcher.matches();
// }
//
// /**
// * Test if a given string matches the strict Uniprot ID pattern (no extension authorized)
// */
// public static boolean isStrict(String uniprotId) {
// Matcher matcher = pattern.matcher(uniprotId);
// return matcher.matches() && uniprotId.equals(matcher.group(1));
// }
//
// /**
// * Extract strict UniProt ID from a string
// */
// public static String extractStrictUniProtId(String string) {
// Matcher matcher = pattern.matcher(string);
// if(matcher.matches())
// return matcher.group(1);
// return null;
// }
//
// }
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/data/protein/ortholog/OrthologScoredProtein.java
// public class OrthologScoredProtein extends Protein {
//
// private static final long serialVersionUID = 1L;
//
// private final Double score;
//
// public OrthologScoredProtein(Protein protein, Double score) {
// super(protein.getUniProtId(), protein.getOrganism());
// this.score = score;
// }
//
// public Double getScore() {
// return score;
// }
//
// }
| import ch.picard.ppimapbuilder.data.organism.Organism;
import ch.picard.ppimapbuilder.data.protein.Protein;
import ch.picard.ppimapbuilder.data.protein.ProteinUtils;
import ch.picard.ppimapbuilder.data.protein.ortholog.OrthologGroup;
import ch.picard.ppimapbuilder.data.protein.ortholog.OrthologScoredProtein;
import java.util.ArrayList;
import java.util.List; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.protein.ortholog.client;
public abstract class AbstractProteinOrthologClient implements ProteinOrthologClient {
@Override | // Path: src/main/java/ch/picard/ppimapbuilder/data/protein/ProteinUtils.java
// public class ProteinUtils {
//
// public static Set<Protein> newProteins(final Set<String> identifiers, final Organism organism) {
// final Set<Protein> out = new HashSet<Protein>();
// for(String id : identifiers)
// out.add(new Protein(id, organism));
// return out;
// }
//
// /**
// * Transform a Collection of Protein to a Collection of UniProt ID
// */
// public static Collection<String> asIdentifiers(final Collection<? extends Protein> proteins) {
// return asIdentifiers(new HashSet<Protein>(proteins));
// }
//
// /**
// * Transform a Set of Protein to a Collection of UniProt ID
// */
// public static Collection<String> asIdentifiers(final Set<? extends Protein> proteins) {
// final Set<String> out = new HashSet<String>();
// for (Protein protein : proteins)
// out.add(protein.getUniProtId());
// return out;
// }
//
// /**
// * Making sure a protein entry is from a specific organism. Will change the entry organism if the entry don't have
// * exactly the same organism as specified but is from the same species (differences can come from strains).
// */
// public static UniProtEntry correctEntryOrganism(UniProtEntry originalEntry, Organism organism) {
// if (
// !originalEntry.getOrganism().equals(organism) &&
// originalEntry.getOrganism().sameSpecies(organism)
// ) {
// return new UniProtEntry.Builder(originalEntry)
// .setOrganism(organism)
// .build();
// }
// return originalEntry;
// }
//
// /**
// * @author Kevin Gravouil
// */
// public static class UniProtId {
//
// /**
// * Uniprot ID pattern. According to
// * http://www.ebi.ac.uk/miriam/main/export/xml/
// */
// private final static Pattern pattern = Pattern.compile("([OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2})([\\-\\.]\\w+)?");
//
// /**
// * Test if a given string matches the Uniprot ID pattern (authorizing extension like "-1" or "-PRO_XXXXXX").
// */
// public static boolean isValid(String uniprotId) {
// Matcher matcher = pattern.matcher(uniprotId);
// return matcher.matches();
// }
//
// /**
// * Test if a given string matches the strict Uniprot ID pattern (no extension authorized)
// */
// public static boolean isStrict(String uniprotId) {
// Matcher matcher = pattern.matcher(uniprotId);
// return matcher.matches() && uniprotId.equals(matcher.group(1));
// }
//
// /**
// * Extract strict UniProt ID from a string
// */
// public static String extractStrictUniProtId(String string) {
// Matcher matcher = pattern.matcher(string);
// if(matcher.matches())
// return matcher.group(1);
// return null;
// }
//
// }
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/data/protein/ortholog/OrthologScoredProtein.java
// public class OrthologScoredProtein extends Protein {
//
// private static final long serialVersionUID = 1L;
//
// private final Double score;
//
// public OrthologScoredProtein(Protein protein, Double score) {
// super(protein.getUniProtId(), protein.getOrganism());
// this.score = score;
// }
//
// public Double getScore() {
// return score;
// }
//
// }
// Path: src/main/java/ch/picard/ppimapbuilder/data/protein/ortholog/client/AbstractProteinOrthologClient.java
import ch.picard.ppimapbuilder.data.organism.Organism;
import ch.picard.ppimapbuilder.data.protein.Protein;
import ch.picard.ppimapbuilder.data.protein.ProteinUtils;
import ch.picard.ppimapbuilder.data.protein.ortholog.OrthologGroup;
import ch.picard.ppimapbuilder.data.protein.ortholog.OrthologScoredProtein;
import java.util.ArrayList;
import java.util.List;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.protein.ortholog.client;
public abstract class AbstractProteinOrthologClient implements ProteinOrthologClient {
@Override | public List<OrthologScoredProtein> getOrtholog(Protein protein, Organism organism, Double score) throws Exception { |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/data/protein/ortholog/client/AbstractProteinOrthologClient.java | // Path: src/main/java/ch/picard/ppimapbuilder/data/protein/ProteinUtils.java
// public class ProteinUtils {
//
// public static Set<Protein> newProteins(final Set<String> identifiers, final Organism organism) {
// final Set<Protein> out = new HashSet<Protein>();
// for(String id : identifiers)
// out.add(new Protein(id, organism));
// return out;
// }
//
// /**
// * Transform a Collection of Protein to a Collection of UniProt ID
// */
// public static Collection<String> asIdentifiers(final Collection<? extends Protein> proteins) {
// return asIdentifiers(new HashSet<Protein>(proteins));
// }
//
// /**
// * Transform a Set of Protein to a Collection of UniProt ID
// */
// public static Collection<String> asIdentifiers(final Set<? extends Protein> proteins) {
// final Set<String> out = new HashSet<String>();
// for (Protein protein : proteins)
// out.add(protein.getUniProtId());
// return out;
// }
//
// /**
// * Making sure a protein entry is from a specific organism. Will change the entry organism if the entry don't have
// * exactly the same organism as specified but is from the same species (differences can come from strains).
// */
// public static UniProtEntry correctEntryOrganism(UniProtEntry originalEntry, Organism organism) {
// if (
// !originalEntry.getOrganism().equals(organism) &&
// originalEntry.getOrganism().sameSpecies(organism)
// ) {
// return new UniProtEntry.Builder(originalEntry)
// .setOrganism(organism)
// .build();
// }
// return originalEntry;
// }
//
// /**
// * @author Kevin Gravouil
// */
// public static class UniProtId {
//
// /**
// * Uniprot ID pattern. According to
// * http://www.ebi.ac.uk/miriam/main/export/xml/
// */
// private final static Pattern pattern = Pattern.compile("([OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2})([\\-\\.]\\w+)?");
//
// /**
// * Test if a given string matches the Uniprot ID pattern (authorizing extension like "-1" or "-PRO_XXXXXX").
// */
// public static boolean isValid(String uniprotId) {
// Matcher matcher = pattern.matcher(uniprotId);
// return matcher.matches();
// }
//
// /**
// * Test if a given string matches the strict Uniprot ID pattern (no extension authorized)
// */
// public static boolean isStrict(String uniprotId) {
// Matcher matcher = pattern.matcher(uniprotId);
// return matcher.matches() && uniprotId.equals(matcher.group(1));
// }
//
// /**
// * Extract strict UniProt ID from a string
// */
// public static String extractStrictUniProtId(String string) {
// Matcher matcher = pattern.matcher(string);
// if(matcher.matches())
// return matcher.group(1);
// return null;
// }
//
// }
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/data/protein/ortholog/OrthologScoredProtein.java
// public class OrthologScoredProtein extends Protein {
//
// private static final long serialVersionUID = 1L;
//
// private final Double score;
//
// public OrthologScoredProtein(Protein protein, Double score) {
// super(protein.getUniProtId(), protein.getOrganism());
// this.score = score;
// }
//
// public Double getScore() {
// return score;
// }
//
// }
| import ch.picard.ppimapbuilder.data.organism.Organism;
import ch.picard.ppimapbuilder.data.protein.Protein;
import ch.picard.ppimapbuilder.data.protein.ProteinUtils;
import ch.picard.ppimapbuilder.data.protein.ortholog.OrthologGroup;
import ch.picard.ppimapbuilder.data.protein.ortholog.OrthologScoredProtein;
import java.util.ArrayList;
import java.util.List; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.protein.ortholog.client;
public abstract class AbstractProteinOrthologClient implements ProteinOrthologClient {
@Override
public List<OrthologScoredProtein> getOrtholog(Protein protein, Organism organism, Double score) throws Exception {
OrthologGroup group = getOrthologGroup(protein, organism);
| // Path: src/main/java/ch/picard/ppimapbuilder/data/protein/ProteinUtils.java
// public class ProteinUtils {
//
// public static Set<Protein> newProteins(final Set<String> identifiers, final Organism organism) {
// final Set<Protein> out = new HashSet<Protein>();
// for(String id : identifiers)
// out.add(new Protein(id, organism));
// return out;
// }
//
// /**
// * Transform a Collection of Protein to a Collection of UniProt ID
// */
// public static Collection<String> asIdentifiers(final Collection<? extends Protein> proteins) {
// return asIdentifiers(new HashSet<Protein>(proteins));
// }
//
// /**
// * Transform a Set of Protein to a Collection of UniProt ID
// */
// public static Collection<String> asIdentifiers(final Set<? extends Protein> proteins) {
// final Set<String> out = new HashSet<String>();
// for (Protein protein : proteins)
// out.add(protein.getUniProtId());
// return out;
// }
//
// /**
// * Making sure a protein entry is from a specific organism. Will change the entry organism if the entry don't have
// * exactly the same organism as specified but is from the same species (differences can come from strains).
// */
// public static UniProtEntry correctEntryOrganism(UniProtEntry originalEntry, Organism organism) {
// if (
// !originalEntry.getOrganism().equals(organism) &&
// originalEntry.getOrganism().sameSpecies(organism)
// ) {
// return new UniProtEntry.Builder(originalEntry)
// .setOrganism(organism)
// .build();
// }
// return originalEntry;
// }
//
// /**
// * @author Kevin Gravouil
// */
// public static class UniProtId {
//
// /**
// * Uniprot ID pattern. According to
// * http://www.ebi.ac.uk/miriam/main/export/xml/
// */
// private final static Pattern pattern = Pattern.compile("([OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2})([\\-\\.]\\w+)?");
//
// /**
// * Test if a given string matches the Uniprot ID pattern (authorizing extension like "-1" or "-PRO_XXXXXX").
// */
// public static boolean isValid(String uniprotId) {
// Matcher matcher = pattern.matcher(uniprotId);
// return matcher.matches();
// }
//
// /**
// * Test if a given string matches the strict Uniprot ID pattern (no extension authorized)
// */
// public static boolean isStrict(String uniprotId) {
// Matcher matcher = pattern.matcher(uniprotId);
// return matcher.matches() && uniprotId.equals(matcher.group(1));
// }
//
// /**
// * Extract strict UniProt ID from a string
// */
// public static String extractStrictUniProtId(String string) {
// Matcher matcher = pattern.matcher(string);
// if(matcher.matches())
// return matcher.group(1);
// return null;
// }
//
// }
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/data/protein/ortholog/OrthologScoredProtein.java
// public class OrthologScoredProtein extends Protein {
//
// private static final long serialVersionUID = 1L;
//
// private final Double score;
//
// public OrthologScoredProtein(Protein protein, Double score) {
// super(protein.getUniProtId(), protein.getOrganism());
// this.score = score;
// }
//
// public Double getScore() {
// return score;
// }
//
// }
// Path: src/main/java/ch/picard/ppimapbuilder/data/protein/ortholog/client/AbstractProteinOrthologClient.java
import ch.picard.ppimapbuilder.data.organism.Organism;
import ch.picard.ppimapbuilder.data.protein.Protein;
import ch.picard.ppimapbuilder.data.protein.ProteinUtils;
import ch.picard.ppimapbuilder.data.protein.ortholog.OrthologGroup;
import ch.picard.ppimapbuilder.data.protein.ortholog.OrthologScoredProtein;
import java.util.ArrayList;
import java.util.List;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.protein.ortholog.client;
public abstract class AbstractProteinOrthologClient implements ProteinOrthologClient {
@Override
public List<OrthologScoredProtein> getOrtholog(Protein protein, Organism organism, Double score) throws Exception {
OrthologGroup group = getOrthologGroup(protein, organism);
| if (group == null && !ProteinUtils.UniProtId.isStrict(protein.getUniProtId())) { |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/data/organism/OrganismUtils.java | // Path: src/main/java/ch/picard/ppimapbuilder/data/Pair.java
// public class Pair<T> implements Comparable<Pair<T>> {
//
// private final T first;
// private final T second;
//
// public Pair(List<T> elems) {
// this(elems.get(0), elems.get(1));
// }
//
// public Pair(T first, T second) {
// this.first = first;
// this.second = second;
// }
//
// public T getFirst() {
// return first;
// }
//
// public T getSecond() {
// return second;
// }
//
// public boolean isNotNull() {
// return first != null && second != null;
// }
//
// public boolean isEmpty() {
// return first == null && second == null;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(first.hashCode(), -1, second.hashCode());
// }
//
// @Override
// public boolean equals(Object other) {
// if(other instanceof Pair){
// Pair otherPair = (Pair) other;
//
// return (
// (otherPair.first == null && first == null) ||
// (otherPair.first != null && otherPair.first.equals(first))
// )
// &&
// (
// (otherPair.second == null && second == null) ||
// (otherPair.second != null && otherPair.second.equals(second))
// );
// }
// else return false;
// }
//
// @Override
// public String toString() {
// return "Pair["+first.toString()+", "+second.toString()+"]";
// }
//
// @Override
// public int compareTo(Pair<T> o) {
// return toString().compareTo(o.toString());
// }
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/data/PairUtils.java
// public class PairUtils {
//
// /**
// * Creates pair combination of a Set of elements
// * @param elements Set of elements to combine to one an other
// * @param selfCombination if true, pairs of duplicate will be added in the list of combinations
// * @param orderedPairs if true and if the elements are Comparable, the combination pairs will be ascending ordered
// */
// @SuppressWarnings("unchecked")
// public static <T> Set<Pair<T>> createCombinations(Set<T> elements, boolean selfCombination, boolean orderedPairs) {
// final ArrayList<T> list = new ArrayList<T>(elements);
//
// T A, B;
// final Set<Pair<T>> combinations = new HashSet<Pair<T>>();
// for (int i = 0, length = list.size(); i < length; i++) {
// A = list.get(i);
//
// if(selfCombination)
// combinations.add(new Pair<T>(A, A));
//
// for (int j = i + 1; j < length; j++) {
// B = list.get(j);
//
// if(orderedPairs && A instanceof Comparable && ((Comparable) A).compareTo(B) > 0)
// combinations.add(new Pair<T>(B, A));
// else
// combinations.add(new Pair<T>(A, B));
// }
// }
//
// return combinations;
// }
//
// }
| import ch.picard.ppimapbuilder.data.Pair;
import ch.picard.ppimapbuilder.data.PairUtils;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.organism;
public class OrganismUtils {
private static final Pattern pattern = Pattern.compile("\\(.*\\)");
/**
* Creates pair combination of organisms using an organism list.
*/ | // Path: src/main/java/ch/picard/ppimapbuilder/data/Pair.java
// public class Pair<T> implements Comparable<Pair<T>> {
//
// private final T first;
// private final T second;
//
// public Pair(List<T> elems) {
// this(elems.get(0), elems.get(1));
// }
//
// public Pair(T first, T second) {
// this.first = first;
// this.second = second;
// }
//
// public T getFirst() {
// return first;
// }
//
// public T getSecond() {
// return second;
// }
//
// public boolean isNotNull() {
// return first != null && second != null;
// }
//
// public boolean isEmpty() {
// return first == null && second == null;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(first.hashCode(), -1, second.hashCode());
// }
//
// @Override
// public boolean equals(Object other) {
// if(other instanceof Pair){
// Pair otherPair = (Pair) other;
//
// return (
// (otherPair.first == null && first == null) ||
// (otherPair.first != null && otherPair.first.equals(first))
// )
// &&
// (
// (otherPair.second == null && second == null) ||
// (otherPair.second != null && otherPair.second.equals(second))
// );
// }
// else return false;
// }
//
// @Override
// public String toString() {
// return "Pair["+first.toString()+", "+second.toString()+"]";
// }
//
// @Override
// public int compareTo(Pair<T> o) {
// return toString().compareTo(o.toString());
// }
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/data/PairUtils.java
// public class PairUtils {
//
// /**
// * Creates pair combination of a Set of elements
// * @param elements Set of elements to combine to one an other
// * @param selfCombination if true, pairs of duplicate will be added in the list of combinations
// * @param orderedPairs if true and if the elements are Comparable, the combination pairs will be ascending ordered
// */
// @SuppressWarnings("unchecked")
// public static <T> Set<Pair<T>> createCombinations(Set<T> elements, boolean selfCombination, boolean orderedPairs) {
// final ArrayList<T> list = new ArrayList<T>(elements);
//
// T A, B;
// final Set<Pair<T>> combinations = new HashSet<Pair<T>>();
// for (int i = 0, length = list.size(); i < length; i++) {
// A = list.get(i);
//
// if(selfCombination)
// combinations.add(new Pair<T>(A, A));
//
// for (int j = i + 1; j < length; j++) {
// B = list.get(j);
//
// if(orderedPairs && A instanceof Comparable && ((Comparable) A).compareTo(B) > 0)
// combinations.add(new Pair<T>(B, A));
// else
// combinations.add(new Pair<T>(A, B));
// }
// }
//
// return combinations;
// }
//
// }
// Path: src/main/java/ch/picard/ppimapbuilder/data/organism/OrganismUtils.java
import ch.picard.ppimapbuilder.data.Pair;
import ch.picard.ppimapbuilder.data.PairUtils;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.organism;
public class OrganismUtils {
private static final Pattern pattern = Pattern.compile("\\(.*\\)");
/**
* Creates pair combination of organisms using an organism list.
*/ | public static Set<Pair<Organism>> createCombinations(List<Organism> organisms) { |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/data/organism/OrganismUtils.java | // Path: src/main/java/ch/picard/ppimapbuilder/data/Pair.java
// public class Pair<T> implements Comparable<Pair<T>> {
//
// private final T first;
// private final T second;
//
// public Pair(List<T> elems) {
// this(elems.get(0), elems.get(1));
// }
//
// public Pair(T first, T second) {
// this.first = first;
// this.second = second;
// }
//
// public T getFirst() {
// return first;
// }
//
// public T getSecond() {
// return second;
// }
//
// public boolean isNotNull() {
// return first != null && second != null;
// }
//
// public boolean isEmpty() {
// return first == null && second == null;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(first.hashCode(), -1, second.hashCode());
// }
//
// @Override
// public boolean equals(Object other) {
// if(other instanceof Pair){
// Pair otherPair = (Pair) other;
//
// return (
// (otherPair.first == null && first == null) ||
// (otherPair.first != null && otherPair.first.equals(first))
// )
// &&
// (
// (otherPair.second == null && second == null) ||
// (otherPair.second != null && otherPair.second.equals(second))
// );
// }
// else return false;
// }
//
// @Override
// public String toString() {
// return "Pair["+first.toString()+", "+second.toString()+"]";
// }
//
// @Override
// public int compareTo(Pair<T> o) {
// return toString().compareTo(o.toString());
// }
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/data/PairUtils.java
// public class PairUtils {
//
// /**
// * Creates pair combination of a Set of elements
// * @param elements Set of elements to combine to one an other
// * @param selfCombination if true, pairs of duplicate will be added in the list of combinations
// * @param orderedPairs if true and if the elements are Comparable, the combination pairs will be ascending ordered
// */
// @SuppressWarnings("unchecked")
// public static <T> Set<Pair<T>> createCombinations(Set<T> elements, boolean selfCombination, boolean orderedPairs) {
// final ArrayList<T> list = new ArrayList<T>(elements);
//
// T A, B;
// final Set<Pair<T>> combinations = new HashSet<Pair<T>>();
// for (int i = 0, length = list.size(); i < length; i++) {
// A = list.get(i);
//
// if(selfCombination)
// combinations.add(new Pair<T>(A, A));
//
// for (int j = i + 1; j < length; j++) {
// B = list.get(j);
//
// if(orderedPairs && A instanceof Comparable && ((Comparable) A).compareTo(B) > 0)
// combinations.add(new Pair<T>(B, A));
// else
// combinations.add(new Pair<T>(A, B));
// }
// }
//
// return combinations;
// }
//
// }
| import ch.picard.ppimapbuilder.data.Pair;
import ch.picard.ppimapbuilder.data.PairUtils;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.organism;
public class OrganismUtils {
private static final Pattern pattern = Pattern.compile("\\(.*\\)");
/**
* Creates pair combination of organisms using an organism list.
*/
public static Set<Pair<Organism>> createCombinations(List<Organism> organisms) { | // Path: src/main/java/ch/picard/ppimapbuilder/data/Pair.java
// public class Pair<T> implements Comparable<Pair<T>> {
//
// private final T first;
// private final T second;
//
// public Pair(List<T> elems) {
// this(elems.get(0), elems.get(1));
// }
//
// public Pair(T first, T second) {
// this.first = first;
// this.second = second;
// }
//
// public T getFirst() {
// return first;
// }
//
// public T getSecond() {
// return second;
// }
//
// public boolean isNotNull() {
// return first != null && second != null;
// }
//
// public boolean isEmpty() {
// return first == null && second == null;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(first.hashCode(), -1, second.hashCode());
// }
//
// @Override
// public boolean equals(Object other) {
// if(other instanceof Pair){
// Pair otherPair = (Pair) other;
//
// return (
// (otherPair.first == null && first == null) ||
// (otherPair.first != null && otherPair.first.equals(first))
// )
// &&
// (
// (otherPair.second == null && second == null) ||
// (otherPair.second != null && otherPair.second.equals(second))
// );
// }
// else return false;
// }
//
// @Override
// public String toString() {
// return "Pair["+first.toString()+", "+second.toString()+"]";
// }
//
// @Override
// public int compareTo(Pair<T> o) {
// return toString().compareTo(o.toString());
// }
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/data/PairUtils.java
// public class PairUtils {
//
// /**
// * Creates pair combination of a Set of elements
// * @param elements Set of elements to combine to one an other
// * @param selfCombination if true, pairs of duplicate will be added in the list of combinations
// * @param orderedPairs if true and if the elements are Comparable, the combination pairs will be ascending ordered
// */
// @SuppressWarnings("unchecked")
// public static <T> Set<Pair<T>> createCombinations(Set<T> elements, boolean selfCombination, boolean orderedPairs) {
// final ArrayList<T> list = new ArrayList<T>(elements);
//
// T A, B;
// final Set<Pair<T>> combinations = new HashSet<Pair<T>>();
// for (int i = 0, length = list.size(); i < length; i++) {
// A = list.get(i);
//
// if(selfCombination)
// combinations.add(new Pair<T>(A, A));
//
// for (int j = i + 1; j < length; j++) {
// B = list.get(j);
//
// if(orderedPairs && A instanceof Comparable && ((Comparable) A).compareTo(B) > 0)
// combinations.add(new Pair<T>(B, A));
// else
// combinations.add(new Pair<T>(A, B));
// }
// }
//
// return combinations;
// }
//
// }
// Path: src/main/java/ch/picard/ppimapbuilder/data/organism/OrganismUtils.java
import ch.picard.ppimapbuilder.data.Pair;
import ch.picard.ppimapbuilder.data.PairUtils;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.organism;
public class OrganismUtils {
private static final Pattern pattern = Pattern.compile("\\(.*\\)");
/**
* Creates pair combination of organisms using an organism list.
*/
public static Set<Pair<Organism>> createCombinations(List<Organism> organisms) { | return PairUtils.createCombinations(new HashSet<Organism>(organisms), false, true); |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/data/interaction/client/web/filter/ProgressMonitoringInteractionFilter.java | // Path: src/main/java/ch/picard/ppimapbuilder/util/ProgressMonitor.java
// public interface ProgressMonitor {
// public void setProgress(double v);
// }
| import ch.picard.ppimapbuilder.util.ProgressMonitor;
import psidev.psi.mi.tab.model.BinaryInteraction; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.interaction.client.web.filter;
public class ProgressMonitoringInteractionFilter extends InteractionFilter {
private final int estimatedNumberOfInteraction; | // Path: src/main/java/ch/picard/ppimapbuilder/util/ProgressMonitor.java
// public interface ProgressMonitor {
// public void setProgress(double v);
// }
// Path: src/main/java/ch/picard/ppimapbuilder/data/interaction/client/web/filter/ProgressMonitoringInteractionFilter.java
import ch.picard.ppimapbuilder.util.ProgressMonitor;
import psidev.psi.mi.tab.model.BinaryInteraction;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.interaction.client.web.filter;
public class ProgressMonitoringInteractionFilter extends InteractionFilter {
private final int estimatedNumberOfInteraction; | private final ProgressMonitor progressMonitor; |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/data/interaction/client/web/filter/UniProtInteractorFilter.java | // Path: src/main/java/ch/picard/ppimapbuilder/data/protein/ProteinUtils.java
// public class ProteinUtils {
//
// public static Set<Protein> newProteins(final Set<String> identifiers, final Organism organism) {
// final Set<Protein> out = new HashSet<Protein>();
// for(String id : identifiers)
// out.add(new Protein(id, organism));
// return out;
// }
//
// /**
// * Transform a Collection of Protein to a Collection of UniProt ID
// */
// public static Collection<String> asIdentifiers(final Collection<? extends Protein> proteins) {
// return asIdentifiers(new HashSet<Protein>(proteins));
// }
//
// /**
// * Transform a Set of Protein to a Collection of UniProt ID
// */
// public static Collection<String> asIdentifiers(final Set<? extends Protein> proteins) {
// final Set<String> out = new HashSet<String>();
// for (Protein protein : proteins)
// out.add(protein.getUniProtId());
// return out;
// }
//
// /**
// * Making sure a protein entry is from a specific organism. Will change the entry organism if the entry don't have
// * exactly the same organism as specified but is from the same species (differences can come from strains).
// */
// public static UniProtEntry correctEntryOrganism(UniProtEntry originalEntry, Organism organism) {
// if (
// !originalEntry.getOrganism().equals(organism) &&
// originalEntry.getOrganism().sameSpecies(organism)
// ) {
// return new UniProtEntry.Builder(originalEntry)
// .setOrganism(organism)
// .build();
// }
// return originalEntry;
// }
//
// /**
// * @author Kevin Gravouil
// */
// public static class UniProtId {
//
// /**
// * Uniprot ID pattern. According to
// * http://www.ebi.ac.uk/miriam/main/export/xml/
// */
// private final static Pattern pattern = Pattern.compile("([OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2})([\\-\\.]\\w+)?");
//
// /**
// * Test if a given string matches the Uniprot ID pattern (authorizing extension like "-1" or "-PRO_XXXXXX").
// */
// public static boolean isValid(String uniprotId) {
// Matcher matcher = pattern.matcher(uniprotId);
// return matcher.matches();
// }
//
// /**
// * Test if a given string matches the strict Uniprot ID pattern (no extension authorized)
// */
// public static boolean isStrict(String uniprotId) {
// Matcher matcher = pattern.matcher(uniprotId);
// return matcher.matches() && uniprotId.equals(matcher.group(1));
// }
//
// /**
// * Extract strict UniProt ID from a string
// */
// public static String extractStrictUniProtId(String string) {
// Matcher matcher = pattern.matcher(string);
// if(matcher.matches())
// return matcher.group(1);
// return null;
// }
//
// }
// }
| import ch.picard.ppimapbuilder.data.protein.ProteinUtils;
import psidev.psi.mi.tab.model.CrossReference;
import psidev.psi.mi.tab.model.Interactor;
import java.util.ArrayList;
import java.util.List; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.interaction.client.web.filter;
public final class UniProtInteractorFilter extends InteractorFilter {
@Override
public boolean isValidInteractor(Interactor interactor) {
final List<CrossReference> ids = interactor.getIdentifiers();
ids.addAll(interactor.getAlternativeIdentifiers());
if (ids.size() == 1 && !ids.get(0).getDatabase().equals("uniprotkb"))
return false;
CrossReference uniprot = null;
boolean hasUniprot = false;
for (CrossReference ref : ids) {
hasUniprot = hasUniprot || (
ref.getDatabase().equals("uniprotkb") // Is UniProt
&& | // Path: src/main/java/ch/picard/ppimapbuilder/data/protein/ProteinUtils.java
// public class ProteinUtils {
//
// public static Set<Protein> newProteins(final Set<String> identifiers, final Organism organism) {
// final Set<Protein> out = new HashSet<Protein>();
// for(String id : identifiers)
// out.add(new Protein(id, organism));
// return out;
// }
//
// /**
// * Transform a Collection of Protein to a Collection of UniProt ID
// */
// public static Collection<String> asIdentifiers(final Collection<? extends Protein> proteins) {
// return asIdentifiers(new HashSet<Protein>(proteins));
// }
//
// /**
// * Transform a Set of Protein to a Collection of UniProt ID
// */
// public static Collection<String> asIdentifiers(final Set<? extends Protein> proteins) {
// final Set<String> out = new HashSet<String>();
// for (Protein protein : proteins)
// out.add(protein.getUniProtId());
// return out;
// }
//
// /**
// * Making sure a protein entry is from a specific organism. Will change the entry organism if the entry don't have
// * exactly the same organism as specified but is from the same species (differences can come from strains).
// */
// public static UniProtEntry correctEntryOrganism(UniProtEntry originalEntry, Organism organism) {
// if (
// !originalEntry.getOrganism().equals(organism) &&
// originalEntry.getOrganism().sameSpecies(organism)
// ) {
// return new UniProtEntry.Builder(originalEntry)
// .setOrganism(organism)
// .build();
// }
// return originalEntry;
// }
//
// /**
// * @author Kevin Gravouil
// */
// public static class UniProtId {
//
// /**
// * Uniprot ID pattern. According to
// * http://www.ebi.ac.uk/miriam/main/export/xml/
// */
// private final static Pattern pattern = Pattern.compile("([OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2})([\\-\\.]\\w+)?");
//
// /**
// * Test if a given string matches the Uniprot ID pattern (authorizing extension like "-1" or "-PRO_XXXXXX").
// */
// public static boolean isValid(String uniprotId) {
// Matcher matcher = pattern.matcher(uniprotId);
// return matcher.matches();
// }
//
// /**
// * Test if a given string matches the strict Uniprot ID pattern (no extension authorized)
// */
// public static boolean isStrict(String uniprotId) {
// Matcher matcher = pattern.matcher(uniprotId);
// return matcher.matches() && uniprotId.equals(matcher.group(1));
// }
//
// /**
// * Extract strict UniProt ID from a string
// */
// public static String extractStrictUniProtId(String string) {
// Matcher matcher = pattern.matcher(string);
// if(matcher.matches())
// return matcher.group(1);
// return null;
// }
//
// }
// }
// Path: src/main/java/ch/picard/ppimapbuilder/data/interaction/client/web/filter/UniProtInteractorFilter.java
import ch.picard.ppimapbuilder.data.protein.ProteinUtils;
import psidev.psi.mi.tab.model.CrossReference;
import psidev.psi.mi.tab.model.Interactor;
import java.util.ArrayList;
import java.util.List;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.interaction.client.web.filter;
public final class UniProtInteractorFilter extends InteractorFilter {
@Override
public boolean isValidInteractor(Interactor interactor) {
final List<CrossReference> ids = interactor.getIdentifiers();
ids.addAll(interactor.getAlternativeIdentifiers());
if (ids.size() == 1 && !ids.get(0).getDatabase().equals("uniprotkb"))
return false;
CrossReference uniprot = null;
boolean hasUniprot = false;
for (CrossReference ref : ids) {
hasUniprot = hasUniprot || (
ref.getDatabase().equals("uniprotkb") // Is UniProt
&& | ProteinUtils.UniProtId.isValid(ref.getIdentifier()) // Valid UniProt |
PPiMapBuilder/PPiMapBuilder | src/test/java/ch/picard/ppimapbuilder/data/ontology/goslim/GOSlimOBOParserTest.java | // Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/GeneOntologyTerm.java
// public class GeneOntologyTerm extends OntologyTerm implements JSONable, Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private final String term;
// private final GeneOntologyCategory category;
// public static final int TERM_LENGTH = 10;
//
// public GeneOntologyTerm(String identifier) {
// this(identifier, "", null);
// }
//
// public GeneOntologyTerm(String identifier, String term, char category) {
// this(identifier, term, GeneOntologyCategory.getByLetter(category));
// }
//
// public GeneOntologyTerm(String identifier, String term, GeneOntologyCategory category) {
// super(identifier);
// this.term = term;
// this.category = category;
// }
//
// public String getTerm() {
// return term;
// }
//
// public GeneOntologyCategory getCategory() {
// return category;
// }
//
// @Override
// public String toString() {
// return getIdentifier();
// }
//
// @Override
// public String toJSON() {
// JsonObject out = new JsonObject();
// out.add("id", getIdentifier());
// out.add("term", term);
// return out.toString();
// }
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/GeneOntologyTermSet.java
// public class GeneOntologyTermSet extends HashSet<GeneOntologyTerm> {
//
// private static final long serialVersionUID = 1L;
//
// public GeneOntologyTermSet() {
// super();
// }
//
// public GeneOntologyTermSet(Collection<GeneOntologyTerm> terms) {
// super(terms);
// }
//
// public GeneOntologyTermSet getByCategory(GeneOntologyCategory category) {
// GeneOntologyTermSet result = new GeneOntologyTermSet();
// for (GeneOntologyTerm geneOntologyTerm : this) {
// if(geneOntologyTerm.getCategory().equals(category))
// result.add(geneOntologyTerm);
// }
// return result;
// }
//
// public List<String> asStringList() {
// ArrayList<String> list = new ArrayList<String>();
// for (GeneOntologyTerm go : this)
// list.add(go.toString());
// return list;
// }
// }
| import ch.picard.ppimapbuilder.data.ontology.GeneOntologyTerm;
import ch.picard.ppimapbuilder.data.ontology.GeneOntologyTermSet;
import junit.framework.Assert;
import org.junit.Test;
import java.io.InputStream; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.ontology.goslim;
public class GOSlimOBOParserTest {
@Test
public void testParseOBOFile() throws Exception {
GOSlim expected = new GOSlim("oboFileTest"); | // Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/GeneOntologyTerm.java
// public class GeneOntologyTerm extends OntologyTerm implements JSONable, Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private final String term;
// private final GeneOntologyCategory category;
// public static final int TERM_LENGTH = 10;
//
// public GeneOntologyTerm(String identifier) {
// this(identifier, "", null);
// }
//
// public GeneOntologyTerm(String identifier, String term, char category) {
// this(identifier, term, GeneOntologyCategory.getByLetter(category));
// }
//
// public GeneOntologyTerm(String identifier, String term, GeneOntologyCategory category) {
// super(identifier);
// this.term = term;
// this.category = category;
// }
//
// public String getTerm() {
// return term;
// }
//
// public GeneOntologyCategory getCategory() {
// return category;
// }
//
// @Override
// public String toString() {
// return getIdentifier();
// }
//
// @Override
// public String toJSON() {
// JsonObject out = new JsonObject();
// out.add("id", getIdentifier());
// out.add("term", term);
// return out.toString();
// }
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/GeneOntologyTermSet.java
// public class GeneOntologyTermSet extends HashSet<GeneOntologyTerm> {
//
// private static final long serialVersionUID = 1L;
//
// public GeneOntologyTermSet() {
// super();
// }
//
// public GeneOntologyTermSet(Collection<GeneOntologyTerm> terms) {
// super(terms);
// }
//
// public GeneOntologyTermSet getByCategory(GeneOntologyCategory category) {
// GeneOntologyTermSet result = new GeneOntologyTermSet();
// for (GeneOntologyTerm geneOntologyTerm : this) {
// if(geneOntologyTerm.getCategory().equals(category))
// result.add(geneOntologyTerm);
// }
// return result;
// }
//
// public List<String> asStringList() {
// ArrayList<String> list = new ArrayList<String>();
// for (GeneOntologyTerm go : this)
// list.add(go.toString());
// return list;
// }
// }
// Path: src/test/java/ch/picard/ppimapbuilder/data/ontology/goslim/GOSlimOBOParserTest.java
import ch.picard.ppimapbuilder.data.ontology.GeneOntologyTerm;
import ch.picard.ppimapbuilder.data.ontology.GeneOntologyTermSet;
import junit.framework.Assert;
import org.junit.Test;
import java.io.InputStream;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.ontology.goslim;
public class GOSlimOBOParserTest {
@Test
public void testParseOBOFile() throws Exception {
GOSlim expected = new GOSlim("oboFileTest"); | expected.add(new GeneOntologyTerm("GO:0005975", "carbohydrate metabolic process", 'P')); |
PPiMapBuilder/PPiMapBuilder | src/test/java/ch/picard/ppimapbuilder/data/ontology/goslim/GOSlimOBOParserTest.java | // Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/GeneOntologyTerm.java
// public class GeneOntologyTerm extends OntologyTerm implements JSONable, Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private final String term;
// private final GeneOntologyCategory category;
// public static final int TERM_LENGTH = 10;
//
// public GeneOntologyTerm(String identifier) {
// this(identifier, "", null);
// }
//
// public GeneOntologyTerm(String identifier, String term, char category) {
// this(identifier, term, GeneOntologyCategory.getByLetter(category));
// }
//
// public GeneOntologyTerm(String identifier, String term, GeneOntologyCategory category) {
// super(identifier);
// this.term = term;
// this.category = category;
// }
//
// public String getTerm() {
// return term;
// }
//
// public GeneOntologyCategory getCategory() {
// return category;
// }
//
// @Override
// public String toString() {
// return getIdentifier();
// }
//
// @Override
// public String toJSON() {
// JsonObject out = new JsonObject();
// out.add("id", getIdentifier());
// out.add("term", term);
// return out.toString();
// }
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/GeneOntologyTermSet.java
// public class GeneOntologyTermSet extends HashSet<GeneOntologyTerm> {
//
// private static final long serialVersionUID = 1L;
//
// public GeneOntologyTermSet() {
// super();
// }
//
// public GeneOntologyTermSet(Collection<GeneOntologyTerm> terms) {
// super(terms);
// }
//
// public GeneOntologyTermSet getByCategory(GeneOntologyCategory category) {
// GeneOntologyTermSet result = new GeneOntologyTermSet();
// for (GeneOntologyTerm geneOntologyTerm : this) {
// if(geneOntologyTerm.getCategory().equals(category))
// result.add(geneOntologyTerm);
// }
// return result;
// }
//
// public List<String> asStringList() {
// ArrayList<String> list = new ArrayList<String>();
// for (GeneOntologyTerm go : this)
// list.add(go.toString());
// return list;
// }
// }
| import ch.picard.ppimapbuilder.data.ontology.GeneOntologyTerm;
import ch.picard.ppimapbuilder.data.ontology.GeneOntologyTermSet;
import junit.framework.Assert;
import org.junit.Test;
import java.io.InputStream; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.ontology.goslim;
public class GOSlimOBOParserTest {
@Test
public void testParseOBOFile() throws Exception {
GOSlim expected = new GOSlim("oboFileTest");
expected.add(new GeneOntologyTerm("GO:0005975", "carbohydrate metabolic process", 'P'));
expected.add(new GeneOntologyTerm("GO:0006091", "generation of precursor metabolites and energy", 'P'));
expected.add(new GeneOntologyTerm("GO:0006260", "DNA replication", 'P'));
expected.add(new GeneOntologyTerm("GO:0006281", "DNA repair", 'P'));
expected.add(new GeneOntologyTerm("GO:0006355", "regulation of transcription, DNA-templated", 'P'));
expected.add(new GeneOntologyTerm("GO:0006399", "tRNA metabolic process", 'P'));
expected.add(new GeneOntologyTerm("GO:0006457", "protein folding", 'P'));
expected.add(new GeneOntologyTerm("GO:0006461", "protein complex assembly", 'P'));
expected.add(new GeneOntologyTerm("GO:0006486", "protein glycosylation", 'P'));
expected.add(new GeneOntologyTerm("GO:0006914", "autophagy", 'P'));
expected.add(new GeneOntologyTerm("GO:0007005", "mitochondrion organization", 'P'));
expected.add(new GeneOntologyTerm("GO:0007010", "cytoskeleton organization", 'P'));
expected.add(new GeneOntologyTerm("GO:0007031", "peroxisome organization", 'P'));
expected.add(new GeneOntologyTerm("GO:0007033", "vacuole organization", 'P'));
expected.add(new GeneOntologyTerm("GO:0007034", "vacuolar transport", 'P'));
expected.add(new GeneOntologyTerm("GO:0007059", "chromosome segregation", 'P'));
expected.add(new GeneOntologyTerm("GO:0007155", "cell adhesion", 'P'));
expected.add(new GeneOntologyTerm("GO:0007163", "establishment or maintenance of cell polarity", 'P'));
expected.add(new GeneOntologyTerm("GO:0007346", "regulation of mitotic cell cycle", 'P'));
expected.add(new GeneOntologyTerm("GO:0008150", "biological_process", 'P'));
expected.add(new GeneOntologyTerm("GO:0016071", "mRNA metabolic process", 'P'));
InputStream oboFile = getClass().getResourceAsStream("oboFileTest.obo"); | // Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/GeneOntologyTerm.java
// public class GeneOntologyTerm extends OntologyTerm implements JSONable, Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private final String term;
// private final GeneOntologyCategory category;
// public static final int TERM_LENGTH = 10;
//
// public GeneOntologyTerm(String identifier) {
// this(identifier, "", null);
// }
//
// public GeneOntologyTerm(String identifier, String term, char category) {
// this(identifier, term, GeneOntologyCategory.getByLetter(category));
// }
//
// public GeneOntologyTerm(String identifier, String term, GeneOntologyCategory category) {
// super(identifier);
// this.term = term;
// this.category = category;
// }
//
// public String getTerm() {
// return term;
// }
//
// public GeneOntologyCategory getCategory() {
// return category;
// }
//
// @Override
// public String toString() {
// return getIdentifier();
// }
//
// @Override
// public String toJSON() {
// JsonObject out = new JsonObject();
// out.add("id", getIdentifier());
// out.add("term", term);
// return out.toString();
// }
// }
//
// Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/GeneOntologyTermSet.java
// public class GeneOntologyTermSet extends HashSet<GeneOntologyTerm> {
//
// private static final long serialVersionUID = 1L;
//
// public GeneOntologyTermSet() {
// super();
// }
//
// public GeneOntologyTermSet(Collection<GeneOntologyTerm> terms) {
// super(terms);
// }
//
// public GeneOntologyTermSet getByCategory(GeneOntologyCategory category) {
// GeneOntologyTermSet result = new GeneOntologyTermSet();
// for (GeneOntologyTerm geneOntologyTerm : this) {
// if(geneOntologyTerm.getCategory().equals(category))
// result.add(geneOntologyTerm);
// }
// return result;
// }
//
// public List<String> asStringList() {
// ArrayList<String> list = new ArrayList<String>();
// for (GeneOntologyTerm go : this)
// list.add(go.toString());
// return list;
// }
// }
// Path: src/test/java/ch/picard/ppimapbuilder/data/ontology/goslim/GOSlimOBOParserTest.java
import ch.picard.ppimapbuilder.data.ontology.GeneOntologyTerm;
import ch.picard.ppimapbuilder.data.ontology.GeneOntologyTermSet;
import junit.framework.Assert;
import org.junit.Test;
import java.io.InputStream;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.ontology.goslim;
public class GOSlimOBOParserTest {
@Test
public void testParseOBOFile() throws Exception {
GOSlim expected = new GOSlim("oboFileTest");
expected.add(new GeneOntologyTerm("GO:0005975", "carbohydrate metabolic process", 'P'));
expected.add(new GeneOntologyTerm("GO:0006091", "generation of precursor metabolites and energy", 'P'));
expected.add(new GeneOntologyTerm("GO:0006260", "DNA replication", 'P'));
expected.add(new GeneOntologyTerm("GO:0006281", "DNA repair", 'P'));
expected.add(new GeneOntologyTerm("GO:0006355", "regulation of transcription, DNA-templated", 'P'));
expected.add(new GeneOntologyTerm("GO:0006399", "tRNA metabolic process", 'P'));
expected.add(new GeneOntologyTerm("GO:0006457", "protein folding", 'P'));
expected.add(new GeneOntologyTerm("GO:0006461", "protein complex assembly", 'P'));
expected.add(new GeneOntologyTerm("GO:0006486", "protein glycosylation", 'P'));
expected.add(new GeneOntologyTerm("GO:0006914", "autophagy", 'P'));
expected.add(new GeneOntologyTerm("GO:0007005", "mitochondrion organization", 'P'));
expected.add(new GeneOntologyTerm("GO:0007010", "cytoskeleton organization", 'P'));
expected.add(new GeneOntologyTerm("GO:0007031", "peroxisome organization", 'P'));
expected.add(new GeneOntologyTerm("GO:0007033", "vacuole organization", 'P'));
expected.add(new GeneOntologyTerm("GO:0007034", "vacuolar transport", 'P'));
expected.add(new GeneOntologyTerm("GO:0007059", "chromosome segregation", 'P'));
expected.add(new GeneOntologyTerm("GO:0007155", "cell adhesion", 'P'));
expected.add(new GeneOntologyTerm("GO:0007163", "establishment or maintenance of cell polarity", 'P'));
expected.add(new GeneOntologyTerm("GO:0007346", "regulation of mitotic cell cycle", 'P'));
expected.add(new GeneOntologyTerm("GO:0008150", "biological_process", 'P'));
expected.add(new GeneOntologyTerm("GO:0016071", "mRNA metabolic process", 'P'));
InputStream oboFile = getClass().getResourceAsStream("oboFileTest.obo"); | GeneOntologyTermSet actual = GOSlimOBOParser.parseOBOFile(oboFile, "oboFileTest"); |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/data/ontology/goslim/GOSlimRepository.java | // Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/GeneOntologyTermSet.java
// public class GeneOntologyTermSet extends HashSet<GeneOntologyTerm> {
//
// private static final long serialVersionUID = 1L;
//
// public GeneOntologyTermSet() {
// super();
// }
//
// public GeneOntologyTermSet(Collection<GeneOntologyTerm> terms) {
// super(terms);
// }
//
// public GeneOntologyTermSet getByCategory(GeneOntologyCategory category) {
// GeneOntologyTermSet result = new GeneOntologyTermSet();
// for (GeneOntologyTerm geneOntologyTerm : this) {
// if(geneOntologyTerm.getCategory().equals(category))
// result.add(geneOntologyTerm);
// }
// return result;
// }
//
// public List<String> asStringList() {
// ArrayList<String> list = new ArrayList<String>();
// for (GeneOntologyTerm go : this)
// list.add(go.toString());
// return list;
// }
// }
| import ch.picard.ppimapbuilder.data.ontology.GeneOntologyTermSet;
import ch.picard.ppimapbuilder.data.settings.PMBSettings;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map; | /*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.ontology.goslim;
public class GOSlimRepository {
private static GOSlimRepository _instance;
public static GOSlimRepository getInstance() {
if(_instance == null)
_instance = new GOSlimRepository();
return _instance;
}
private final Map<String, GOSlim> goSlims;
private GOSlimRepository() {
this.goSlims = new HashMap<String, GOSlim>();
for(GOSlim geneOntologyTermSet : PMBSettings.getInstance().getGoSlimList())
this.goSlims.put(geneOntologyTermSet.getName(), geneOntologyTermSet);
}
public boolean addGOSlim(GOSlim goSlim) {
if(goSlims.containsKey(goSlim.getName()))
return false;
goSlims.put(goSlim.getName(), goSlim);
return true;
}
| // Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/GeneOntologyTermSet.java
// public class GeneOntologyTermSet extends HashSet<GeneOntologyTerm> {
//
// private static final long serialVersionUID = 1L;
//
// public GeneOntologyTermSet() {
// super();
// }
//
// public GeneOntologyTermSet(Collection<GeneOntologyTerm> terms) {
// super(terms);
// }
//
// public GeneOntologyTermSet getByCategory(GeneOntologyCategory category) {
// GeneOntologyTermSet result = new GeneOntologyTermSet();
// for (GeneOntologyTerm geneOntologyTerm : this) {
// if(geneOntologyTerm.getCategory().equals(category))
// result.add(geneOntologyTerm);
// }
// return result;
// }
//
// public List<String> asStringList() {
// ArrayList<String> list = new ArrayList<String>();
// for (GeneOntologyTerm go : this)
// list.add(go.toString());
// return list;
// }
// }
// Path: src/main/java/ch/picard/ppimapbuilder/data/ontology/goslim/GOSlimRepository.java
import ch.picard.ppimapbuilder.data.ontology.GeneOntologyTermSet;
import ch.picard.ppimapbuilder.data.settings.PMBSettings;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/*
* This file is part of PPiMapBuilder.
*
* PPiMapBuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPiMapBuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PPiMapBuilder. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Echeverria P.C., Dupuis P., Cornut G., Gravouil K., Kieffer A., Picard D.
*
*/
package ch.picard.ppimapbuilder.data.ontology.goslim;
public class GOSlimRepository {
private static GOSlimRepository _instance;
public static GOSlimRepository getInstance() {
if(_instance == null)
_instance = new GOSlimRepository();
return _instance;
}
private final Map<String, GOSlim> goSlims;
private GOSlimRepository() {
this.goSlims = new HashMap<String, GOSlim>();
for(GOSlim geneOntologyTermSet : PMBSettings.getInstance().getGoSlimList())
this.goSlims.put(geneOntologyTermSet.getName(), geneOntologyTermSet);
}
public boolean addGOSlim(GOSlim goSlim) {
if(goSlims.containsKey(goSlim.getName()))
return false;
goSlims.put(goSlim.getName(), goSlim);
return true;
}
| public GeneOntologyTermSet getGOSlim(String name) { |
PPiMapBuilder/PPiMapBuilder | src/main/java/ch/picard/ppimapbuilder/ui/util/tabpanel/TabButton.java | // Path: src/main/java/ch/picard/ppimapbuilder/ui/util/PMBUIStyle.java
// public class PMBUIStyle {
//
// private static Color defaultPanelColor = UIManager.getColor("Panel.background");
// private static float hsbVals[] = Color.RGBtoHSB(
// defaultPanelColor.getRed(),
// defaultPanelColor.getGreen(),
// defaultPanelColor.getBlue(),
// null
// );
//
// public static final Color blurActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color blurInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.95f);
//
// public static final Color focusActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color focusInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.84f);
//
// public static final Color defaultBorderColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.94f);
//
// public static final Border defaultComponentBorder = new LineBorder(defaultBorderColor, 1);
// public static final Border fancyPanelBorder = new CompoundBorder(
// // Outside border 1px bottom light color
// new MatteBorder(0, 0, 1, 0, Color.WHITE),
// // Border all around panel 1px dark grey
// defaultComponentBorder
// );
// public static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
//
// }
| import ch.picard.ppimapbuilder.ui.util.FocusPropagator;
import ch.picard.ppimapbuilder.ui.util.PMBUIStyle;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.MatteBorder;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener; | package ch.picard.ppimapbuilder.ui.util.tabpanel;
class TabButton<T extends TabContent> extends JButton implements FocusListener {
private final boolean first;
private boolean active = false;
private boolean focused = true;
| // Path: src/main/java/ch/picard/ppimapbuilder/ui/util/PMBUIStyle.java
// public class PMBUIStyle {
//
// private static Color defaultPanelColor = UIManager.getColor("Panel.background");
// private static float hsbVals[] = Color.RGBtoHSB(
// defaultPanelColor.getRed(),
// defaultPanelColor.getGreen(),
// defaultPanelColor.getBlue(),
// null
// );
//
// public static final Color blurActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color blurInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.95f);
//
// public static final Color focusActiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.97f);
// public static final Color focusInactiveTabColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.84f);
//
// public static final Color defaultBorderColor = Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2] *= 0.94f);
//
// public static final Border defaultComponentBorder = new LineBorder(defaultBorderColor, 1);
// public static final Border fancyPanelBorder = new CompoundBorder(
// // Outside border 1px bottom light color
// new MatteBorder(0, 0, 1, 0, Color.WHITE),
// // Border all around panel 1px dark grey
// defaultComponentBorder
// );
// public static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
//
// }
// Path: src/main/java/ch/picard/ppimapbuilder/ui/util/tabpanel/TabButton.java
import ch.picard.ppimapbuilder.ui.util.FocusPropagator;
import ch.picard.ppimapbuilder.ui.util.PMBUIStyle;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.MatteBorder;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
package ch.picard.ppimapbuilder.ui.util.tabpanel;
class TabButton<T extends TabContent> extends JButton implements FocusListener {
private final boolean first;
private boolean active = false;
private boolean focused = true;
| private Border bottomBorder = new MatteBorder(0, 0, 1, 0, PMBUIStyle.defaultBorderColor); |
spotify/dns-java | src/main/java/com/spotify/dns/MeteredDnsSrvResolver.java | // Path: src/main/java/com/spotify/dns/statistics/DnsReporter.java
// public interface DnsReporter {
// /**
// * Report resolve timing.
// * @return A new timing context.
// */
// DnsTimingContext resolveTimer();
//
// /**
// * Report that an empty response has been received from a resolve.
// */
// void reportEmpty();
//
// /**
// * Report that a resolve resulting in a failure.
// * @param error The exception causing the failure.
// */
// void reportFailure(Throwable error);
// }
//
// Path: src/main/java/com/spotify/dns/statistics/DnsTimingContext.java
// @FunctionalInterface
// public interface DnsTimingContext {
// void stop();
// }
| import static com.google.common.base.Throwables.throwIfUnchecked;
import static java.util.Objects.requireNonNull;
import com.spotify.dns.statistics.DnsReporter;
import com.spotify.dns.statistics.DnsTimingContext;
import java.util.List;
import java.util.concurrent.CompletionStage; | /*
* Copyright (c) 2015 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.spotify.dns;
/**
* Tracks metrics for DnsSrvResolver calls.
*/
class MeteredDnsSrvResolver implements DnsSrvResolver {
private final DnsSrvResolver delegate; | // Path: src/main/java/com/spotify/dns/statistics/DnsReporter.java
// public interface DnsReporter {
// /**
// * Report resolve timing.
// * @return A new timing context.
// */
// DnsTimingContext resolveTimer();
//
// /**
// * Report that an empty response has been received from a resolve.
// */
// void reportEmpty();
//
// /**
// * Report that a resolve resulting in a failure.
// * @param error The exception causing the failure.
// */
// void reportFailure(Throwable error);
// }
//
// Path: src/main/java/com/spotify/dns/statistics/DnsTimingContext.java
// @FunctionalInterface
// public interface DnsTimingContext {
// void stop();
// }
// Path: src/main/java/com/spotify/dns/MeteredDnsSrvResolver.java
import static com.google.common.base.Throwables.throwIfUnchecked;
import static java.util.Objects.requireNonNull;
import com.spotify.dns.statistics.DnsReporter;
import com.spotify.dns.statistics.DnsTimingContext;
import java.util.List;
import java.util.concurrent.CompletionStage;
/*
* Copyright (c) 2015 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.spotify.dns;
/**
* Tracks metrics for DnsSrvResolver calls.
*/
class MeteredDnsSrvResolver implements DnsSrvResolver {
private final DnsSrvResolver delegate; | private final DnsReporter reporter; |
spotify/dns-java | src/main/java/com/spotify/dns/MeteredDnsSrvResolver.java | // Path: src/main/java/com/spotify/dns/statistics/DnsReporter.java
// public interface DnsReporter {
// /**
// * Report resolve timing.
// * @return A new timing context.
// */
// DnsTimingContext resolveTimer();
//
// /**
// * Report that an empty response has been received from a resolve.
// */
// void reportEmpty();
//
// /**
// * Report that a resolve resulting in a failure.
// * @param error The exception causing the failure.
// */
// void reportFailure(Throwable error);
// }
//
// Path: src/main/java/com/spotify/dns/statistics/DnsTimingContext.java
// @FunctionalInterface
// public interface DnsTimingContext {
// void stop();
// }
| import static com.google.common.base.Throwables.throwIfUnchecked;
import static java.util.Objects.requireNonNull;
import com.spotify.dns.statistics.DnsReporter;
import com.spotify.dns.statistics.DnsTimingContext;
import java.util.List;
import java.util.concurrent.CompletionStage; | /*
* Copyright (c) 2015 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.spotify.dns;
/**
* Tracks metrics for DnsSrvResolver calls.
*/
class MeteredDnsSrvResolver implements DnsSrvResolver {
private final DnsSrvResolver delegate;
private final DnsReporter reporter;
MeteredDnsSrvResolver(DnsSrvResolver delegate, DnsReporter reporter) {
this.delegate = requireNonNull(delegate, "delegate");
this.reporter = requireNonNull(reporter, "reporter");
}
@Override
public List<LookupResult> resolve(String fqdn) {
// Only catch and report RuntimeException to avoid Error's since that would
// most likely only aggravate any condition that causes them to be thrown.
| // Path: src/main/java/com/spotify/dns/statistics/DnsReporter.java
// public interface DnsReporter {
// /**
// * Report resolve timing.
// * @return A new timing context.
// */
// DnsTimingContext resolveTimer();
//
// /**
// * Report that an empty response has been received from a resolve.
// */
// void reportEmpty();
//
// /**
// * Report that a resolve resulting in a failure.
// * @param error The exception causing the failure.
// */
// void reportFailure(Throwable error);
// }
//
// Path: src/main/java/com/spotify/dns/statistics/DnsTimingContext.java
// @FunctionalInterface
// public interface DnsTimingContext {
// void stop();
// }
// Path: src/main/java/com/spotify/dns/MeteredDnsSrvResolver.java
import static com.google.common.base.Throwables.throwIfUnchecked;
import static java.util.Objects.requireNonNull;
import com.spotify.dns.statistics.DnsReporter;
import com.spotify.dns.statistics.DnsTimingContext;
import java.util.List;
import java.util.concurrent.CompletionStage;
/*
* Copyright (c) 2015 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.spotify.dns;
/**
* Tracks metrics for DnsSrvResolver calls.
*/
class MeteredDnsSrvResolver implements DnsSrvResolver {
private final DnsSrvResolver delegate;
private final DnsReporter reporter;
MeteredDnsSrvResolver(DnsSrvResolver delegate, DnsReporter reporter) {
this.delegate = requireNonNull(delegate, "delegate");
this.reporter = requireNonNull(reporter, "reporter");
}
@Override
public List<LookupResult> resolve(String fqdn) {
// Only catch and report RuntimeException to avoid Error's since that would
// most likely only aggravate any condition that causes them to be thrown.
| final DnsTimingContext resolveTimer = reporter.resolveTimer(); |
spotify/dns-java | src/main/java/com/spotify/dns/DnsSrvResolvers.java | // Path: src/main/java/com/spotify/dns/statistics/DnsReporter.java
// public interface DnsReporter {
// /**
// * Report resolve timing.
// * @return A new timing context.
// */
// DnsTimingContext resolveTimer();
//
// /**
// * Report that an empty response has been received from a resolve.
// */
// void reportEmpty();
//
// /**
// * Report that a resolve resulting in a failure.
// * @param error The exception causing the failure.
// */
// void reportFailure(Throwable error);
// }
| import static java.util.concurrent.TimeUnit.HOURS;
import static java.util.concurrent.TimeUnit.SECONDS;
import com.spotify.dns.statistics.DnsReporter;
import java.net.UnknownHostException;
import java.time.Duration;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ForkJoinPool;
import org.xbill.DNS.ExtendedResolver;
import org.xbill.DNS.Resolver; | /*
* Copyright (c) 2015 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.spotify.dns;
/**
* Provides builders for configuring and instantiating {@link DnsSrvResolver}s.
*/
public final class DnsSrvResolvers {
private static final int DEFAULT_DNS_TIMEOUT_SECONDS = 5;
private static final int DEFAULT_RETENTION_DURATION_HOURS = 2;
public static DnsSrvResolverBuilder newBuilder() {
return new DnsSrvResolverBuilder();
}
public static final class DnsSrvResolverBuilder {
| // Path: src/main/java/com/spotify/dns/statistics/DnsReporter.java
// public interface DnsReporter {
// /**
// * Report resolve timing.
// * @return A new timing context.
// */
// DnsTimingContext resolveTimer();
//
// /**
// * Report that an empty response has been received from a resolve.
// */
// void reportEmpty();
//
// /**
// * Report that a resolve resulting in a failure.
// * @param error The exception causing the failure.
// */
// void reportFailure(Throwable error);
// }
// Path: src/main/java/com/spotify/dns/DnsSrvResolvers.java
import static java.util.concurrent.TimeUnit.HOURS;
import static java.util.concurrent.TimeUnit.SECONDS;
import com.spotify.dns.statistics.DnsReporter;
import java.net.UnknownHostException;
import java.time.Duration;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ForkJoinPool;
import org.xbill.DNS.ExtendedResolver;
import org.xbill.DNS.Resolver;
/*
* Copyright (c) 2015 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.spotify.dns;
/**
* Provides builders for configuring and instantiating {@link DnsSrvResolver}s.
*/
public final class DnsSrvResolvers {
private static final int DEFAULT_DNS_TIMEOUT_SECONDS = 5;
private static final int DEFAULT_RETENTION_DURATION_HOURS = 2;
public static DnsSrvResolverBuilder newBuilder() {
return new DnsSrvResolverBuilder();
}
public static final class DnsSrvResolverBuilder {
| private final DnsReporter reporter; |
spotify/dns-java | src/test/java/com/spotify/dns/RetainingDnsSrvResolverTest.java | // Path: src/test/java/com/spotify/dns/DnsTestUtil.java
// static List<LookupResult> nodes(String... nodeNames) {
// return Stream.of(nodeNames)
// .map(input -> LookupResult.create(input, 8080, 1, 2, 999))
// .collect(Collectors.toList());
// }
| import org.junit.rules.ExpectedException;
import static com.spotify.dns.DnsTestUtil.nodes;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test; | /*
* Copyright (c) 2015 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.spotify.dns;
public class RetainingDnsSrvResolverTest {
private static final String FQDN = "heythere";
private static final long RETENTION_TIME_MILLIS = 50L;
RetainingDnsSrvResolver resolver;
DnsSrvResolver delegate;
List<LookupResult> nodes1;
List<LookupResult> nodes2;
@Rule
public ExpectedException thrown = ExpectedException.none();
@Before
public void setUp() {
delegate = mock(DnsSrvResolver.class);
resolver = new RetainingDnsSrvResolver(delegate, RETENTION_TIME_MILLIS);
| // Path: src/test/java/com/spotify/dns/DnsTestUtil.java
// static List<LookupResult> nodes(String... nodeNames) {
// return Stream.of(nodeNames)
// .map(input -> LookupResult.create(input, 8080, 1, 2, 999))
// .collect(Collectors.toList());
// }
// Path: src/test/java/com/spotify/dns/RetainingDnsSrvResolverTest.java
import org.junit.rules.ExpectedException;
import static com.spotify.dns.DnsTestUtil.nodes;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
/*
* Copyright (c) 2015 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.spotify.dns;
public class RetainingDnsSrvResolverTest {
private static final String FQDN = "heythere";
private static final long RETENTION_TIME_MILLIS = 50L;
RetainingDnsSrvResolver resolver;
DnsSrvResolver delegate;
List<LookupResult> nodes1;
List<LookupResult> nodes2;
@Rule
public ExpectedException thrown = ExpectedException.none();
@Before
public void setUp() {
delegate = mock(DnsSrvResolver.class);
resolver = new RetainingDnsSrvResolver(delegate, RETENTION_TIME_MILLIS);
| nodes1 = nodes("noden1", "noden2"); |
spotify/dns-java | src/test/java/com/spotify/dns/DnsSrvResolversIT.java | // Path: src/main/java/com/spotify/dns/statistics/DnsReporter.java
// public interface DnsReporter {
// /**
// * Report resolve timing.
// * @return A new timing context.
// */
// DnsTimingContext resolveTimer();
//
// /**
// * Report that an empty response has been received from a resolve.
// */
// void reportEmpty();
//
// /**
// * Report that a resolve resulting in a failure.
// * @param error The exception causing the failure.
// */
// void reportFailure(Throwable error);
// }
//
// Path: src/main/java/com/spotify/dns/statistics/DnsTimingContext.java
// @FunctionalInterface
// public interface DnsTimingContext {
// void stop();
// }
| import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.jayway.awaitility.Awaitility;
import com.spotify.dns.statistics.DnsReporter;
import com.spotify.dns.statistics.DnsTimingContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.xbill.DNS.SimpleResolver; | }
@Test
public void shouldReturnResultsForValidQuery() throws ExecutionException, InterruptedException {
assertThat(resolver.resolve("_spotify-client._tcp.spotify.com").isEmpty(), is(false));
assertThat(resolver.resolveAsync("_spotify-client._tcp.spotify.com").toCompletableFuture().get().isEmpty(), is(false));
}
@Test
public void testCorrectSequenceOfNotifications() {
ChangeNotifier<LookupResult> notifier = ChangeNotifiers.aggregate(
DnsSrvWatchers.newBuilder(resolver)
.polling(100, TimeUnit.MILLISECONDS)
.build().watch("_spotify-client._tcp.spotify.com"));
final List<String> changes = Collections.synchronizedList(new ArrayList<>());
notifier.setListener(changeNotification -> {
Set<LookupResult> current = changeNotification.current();
if (!ChangeNotifiers.isInitialEmptyData(current)) {
changes.add(current.isEmpty() ? "empty" : "data");
}
}, true);
assertThat(changes, Matchers.empty());
Awaitility.await().atMost(2, TimeUnit.SECONDS).until(() -> changes.size() >= 1);
assertThat(changes, containsInAnyOrder("data"));
}
@Test
public void shouldTrackMetricsWhenToldTo() throws ExecutionException, InterruptedException { | // Path: src/main/java/com/spotify/dns/statistics/DnsReporter.java
// public interface DnsReporter {
// /**
// * Report resolve timing.
// * @return A new timing context.
// */
// DnsTimingContext resolveTimer();
//
// /**
// * Report that an empty response has been received from a resolve.
// */
// void reportEmpty();
//
// /**
// * Report that a resolve resulting in a failure.
// * @param error The exception causing the failure.
// */
// void reportFailure(Throwable error);
// }
//
// Path: src/main/java/com/spotify/dns/statistics/DnsTimingContext.java
// @FunctionalInterface
// public interface DnsTimingContext {
// void stop();
// }
// Path: src/test/java/com/spotify/dns/DnsSrvResolversIT.java
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.jayway.awaitility.Awaitility;
import com.spotify.dns.statistics.DnsReporter;
import com.spotify.dns.statistics.DnsTimingContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.xbill.DNS.SimpleResolver;
}
@Test
public void shouldReturnResultsForValidQuery() throws ExecutionException, InterruptedException {
assertThat(resolver.resolve("_spotify-client._tcp.spotify.com").isEmpty(), is(false));
assertThat(resolver.resolveAsync("_spotify-client._tcp.spotify.com").toCompletableFuture().get().isEmpty(), is(false));
}
@Test
public void testCorrectSequenceOfNotifications() {
ChangeNotifier<LookupResult> notifier = ChangeNotifiers.aggregate(
DnsSrvWatchers.newBuilder(resolver)
.polling(100, TimeUnit.MILLISECONDS)
.build().watch("_spotify-client._tcp.spotify.com"));
final List<String> changes = Collections.synchronizedList(new ArrayList<>());
notifier.setListener(changeNotification -> {
Set<LookupResult> current = changeNotification.current();
if (!ChangeNotifiers.isInitialEmptyData(current)) {
changes.add(current.isEmpty() ? "empty" : "data");
}
}, true);
assertThat(changes, Matchers.empty());
Awaitility.await().atMost(2, TimeUnit.SECONDS).until(() -> changes.size() >= 1);
assertThat(changes, containsInAnyOrder("data"));
}
@Test
public void shouldTrackMetricsWhenToldTo() throws ExecutionException, InterruptedException { | final DnsReporter reporter = mock(DnsReporter.class); |
spotify/dns-java | src/test/java/com/spotify/dns/DnsSrvResolversIT.java | // Path: src/main/java/com/spotify/dns/statistics/DnsReporter.java
// public interface DnsReporter {
// /**
// * Report resolve timing.
// * @return A new timing context.
// */
// DnsTimingContext resolveTimer();
//
// /**
// * Report that an empty response has been received from a resolve.
// */
// void reportEmpty();
//
// /**
// * Report that a resolve resulting in a failure.
// * @param error The exception causing the failure.
// */
// void reportFailure(Throwable error);
// }
//
// Path: src/main/java/com/spotify/dns/statistics/DnsTimingContext.java
// @FunctionalInterface
// public interface DnsTimingContext {
// void stop();
// }
| import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.jayway.awaitility.Awaitility;
import com.spotify.dns.statistics.DnsReporter;
import com.spotify.dns.statistics.DnsTimingContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.xbill.DNS.SimpleResolver; |
@Test
public void shouldReturnResultsForValidQuery() throws ExecutionException, InterruptedException {
assertThat(resolver.resolve("_spotify-client._tcp.spotify.com").isEmpty(), is(false));
assertThat(resolver.resolveAsync("_spotify-client._tcp.spotify.com").toCompletableFuture().get().isEmpty(), is(false));
}
@Test
public void testCorrectSequenceOfNotifications() {
ChangeNotifier<LookupResult> notifier = ChangeNotifiers.aggregate(
DnsSrvWatchers.newBuilder(resolver)
.polling(100, TimeUnit.MILLISECONDS)
.build().watch("_spotify-client._tcp.spotify.com"));
final List<String> changes = Collections.synchronizedList(new ArrayList<>());
notifier.setListener(changeNotification -> {
Set<LookupResult> current = changeNotification.current();
if (!ChangeNotifiers.isInitialEmptyData(current)) {
changes.add(current.isEmpty() ? "empty" : "data");
}
}, true);
assertThat(changes, Matchers.empty());
Awaitility.await().atMost(2, TimeUnit.SECONDS).until(() -> changes.size() >= 1);
assertThat(changes, containsInAnyOrder("data"));
}
@Test
public void shouldTrackMetricsWhenToldTo() throws ExecutionException, InterruptedException {
final DnsReporter reporter = mock(DnsReporter.class); | // Path: src/main/java/com/spotify/dns/statistics/DnsReporter.java
// public interface DnsReporter {
// /**
// * Report resolve timing.
// * @return A new timing context.
// */
// DnsTimingContext resolveTimer();
//
// /**
// * Report that an empty response has been received from a resolve.
// */
// void reportEmpty();
//
// /**
// * Report that a resolve resulting in a failure.
// * @param error The exception causing the failure.
// */
// void reportFailure(Throwable error);
// }
//
// Path: src/main/java/com/spotify/dns/statistics/DnsTimingContext.java
// @FunctionalInterface
// public interface DnsTimingContext {
// void stop();
// }
// Path: src/test/java/com/spotify/dns/DnsSrvResolversIT.java
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.jayway.awaitility.Awaitility;
import com.spotify.dns.statistics.DnsReporter;
import com.spotify.dns.statistics.DnsTimingContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.xbill.DNS.SimpleResolver;
@Test
public void shouldReturnResultsForValidQuery() throws ExecutionException, InterruptedException {
assertThat(resolver.resolve("_spotify-client._tcp.spotify.com").isEmpty(), is(false));
assertThat(resolver.resolveAsync("_spotify-client._tcp.spotify.com").toCompletableFuture().get().isEmpty(), is(false));
}
@Test
public void testCorrectSequenceOfNotifications() {
ChangeNotifier<LookupResult> notifier = ChangeNotifiers.aggregate(
DnsSrvWatchers.newBuilder(resolver)
.polling(100, TimeUnit.MILLISECONDS)
.build().watch("_spotify-client._tcp.spotify.com"));
final List<String> changes = Collections.synchronizedList(new ArrayList<>());
notifier.setListener(changeNotification -> {
Set<LookupResult> current = changeNotification.current();
if (!ChangeNotifiers.isInitialEmptyData(current)) {
changes.add(current.isEmpty() ? "empty" : "data");
}
}, true);
assertThat(changes, Matchers.empty());
Awaitility.await().atMost(2, TimeUnit.SECONDS).until(() -> changes.size() >= 1);
assertThat(changes, containsInAnyOrder("data"));
}
@Test
public void shouldTrackMetricsWhenToldTo() throws ExecutionException, InterruptedException {
final DnsReporter reporter = mock(DnsReporter.class); | final DnsTimingContext timingReporter = mock(DnsTimingContext.class); |
spotify/dns-java | src/test/java/com/spotify/dns/MeteredDnsSrvResolverTest.java | // Path: src/main/java/com/spotify/dns/statistics/DnsReporter.java
// public interface DnsReporter {
// /**
// * Report resolve timing.
// * @return A new timing context.
// */
// DnsTimingContext resolveTimer();
//
// /**
// * Report that an empty response has been received from a resolve.
// */
// void reportEmpty();
//
// /**
// * Report that a resolve resulting in a failure.
// * @param error The exception causing the failure.
// */
// void reportFailure(Throwable error);
// }
//
// Path: src/main/java/com/spotify/dns/statistics/DnsTimingContext.java
// @FunctionalInterface
// public interface DnsTimingContext {
// void stop();
// }
| import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.spotify.dns.statistics.DnsReporter;
import com.spotify.dns.statistics.DnsTimingContext;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import org.junit.After; | /*
* Copyright (c) 2015 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.spotify.dns;
public class MeteredDnsSrvResolverTest {
private static final String FQDN = "nånting";
private static final RuntimeException RUNTIME_EXCEPTION = new RuntimeException();
private static final Error ERROR = new Error();
@SuppressWarnings("unchecked")
private static final List<LookupResult> EMPTY = mock(List.class);
@SuppressWarnings("unchecked")
private static final List<LookupResult> NOT_EMPTY = mock(List.class);
static {
when(EMPTY.isEmpty()).thenReturn(true);
when(NOT_EMPTY.isEmpty()).thenReturn(false);
}
private DnsSrvResolver delegate; | // Path: src/main/java/com/spotify/dns/statistics/DnsReporter.java
// public interface DnsReporter {
// /**
// * Report resolve timing.
// * @return A new timing context.
// */
// DnsTimingContext resolveTimer();
//
// /**
// * Report that an empty response has been received from a resolve.
// */
// void reportEmpty();
//
// /**
// * Report that a resolve resulting in a failure.
// * @param error The exception causing the failure.
// */
// void reportFailure(Throwable error);
// }
//
// Path: src/main/java/com/spotify/dns/statistics/DnsTimingContext.java
// @FunctionalInterface
// public interface DnsTimingContext {
// void stop();
// }
// Path: src/test/java/com/spotify/dns/MeteredDnsSrvResolverTest.java
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.spotify.dns.statistics.DnsReporter;
import com.spotify.dns.statistics.DnsTimingContext;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import org.junit.After;
/*
* Copyright (c) 2015 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.spotify.dns;
public class MeteredDnsSrvResolverTest {
private static final String FQDN = "nånting";
private static final RuntimeException RUNTIME_EXCEPTION = new RuntimeException();
private static final Error ERROR = new Error();
@SuppressWarnings("unchecked")
private static final List<LookupResult> EMPTY = mock(List.class);
@SuppressWarnings("unchecked")
private static final List<LookupResult> NOT_EMPTY = mock(List.class);
static {
when(EMPTY.isEmpty()).thenReturn(true);
when(NOT_EMPTY.isEmpty()).thenReturn(false);
}
private DnsSrvResolver delegate; | private DnsReporter reporter; |
spotify/dns-java | src/test/java/com/spotify/dns/MeteredDnsSrvResolverTest.java | // Path: src/main/java/com/spotify/dns/statistics/DnsReporter.java
// public interface DnsReporter {
// /**
// * Report resolve timing.
// * @return A new timing context.
// */
// DnsTimingContext resolveTimer();
//
// /**
// * Report that an empty response has been received from a resolve.
// */
// void reportEmpty();
//
// /**
// * Report that a resolve resulting in a failure.
// * @param error The exception causing the failure.
// */
// void reportFailure(Throwable error);
// }
//
// Path: src/main/java/com/spotify/dns/statistics/DnsTimingContext.java
// @FunctionalInterface
// public interface DnsTimingContext {
// void stop();
// }
| import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.spotify.dns.statistics.DnsReporter;
import com.spotify.dns.statistics.DnsTimingContext;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import org.junit.After; | /*
* Copyright (c) 2015 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.spotify.dns;
public class MeteredDnsSrvResolverTest {
private static final String FQDN = "nånting";
private static final RuntimeException RUNTIME_EXCEPTION = new RuntimeException();
private static final Error ERROR = new Error();
@SuppressWarnings("unchecked")
private static final List<LookupResult> EMPTY = mock(List.class);
@SuppressWarnings("unchecked")
private static final List<LookupResult> NOT_EMPTY = mock(List.class);
static {
when(EMPTY.isEmpty()).thenReturn(true);
when(NOT_EMPTY.isEmpty()).thenReturn(false);
}
private DnsSrvResolver delegate;
private DnsReporter reporter; | // Path: src/main/java/com/spotify/dns/statistics/DnsReporter.java
// public interface DnsReporter {
// /**
// * Report resolve timing.
// * @return A new timing context.
// */
// DnsTimingContext resolveTimer();
//
// /**
// * Report that an empty response has been received from a resolve.
// */
// void reportEmpty();
//
// /**
// * Report that a resolve resulting in a failure.
// * @param error The exception causing the failure.
// */
// void reportFailure(Throwable error);
// }
//
// Path: src/main/java/com/spotify/dns/statistics/DnsTimingContext.java
// @FunctionalInterface
// public interface DnsTimingContext {
// void stop();
// }
// Path: src/test/java/com/spotify/dns/MeteredDnsSrvResolverTest.java
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.spotify.dns.statistics.DnsReporter;
import com.spotify.dns.statistics.DnsTimingContext;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import org.junit.After;
/*
* Copyright (c) 2015 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.spotify.dns;
public class MeteredDnsSrvResolverTest {
private static final String FQDN = "nånting";
private static final RuntimeException RUNTIME_EXCEPTION = new RuntimeException();
private static final Error ERROR = new Error();
@SuppressWarnings("unchecked")
private static final List<LookupResult> EMPTY = mock(List.class);
@SuppressWarnings("unchecked")
private static final List<LookupResult> NOT_EMPTY = mock(List.class);
static {
when(EMPTY.isEmpty()).thenReturn(true);
when(NOT_EMPTY.isEmpty()).thenReturn(false);
}
private DnsSrvResolver delegate;
private DnsReporter reporter; | private DnsTimingContext timingReporter; |
jsevellec/cassandra-unit | cassandra-unit/src/test/java/org/cassandraunit/CQLDataLoadTestWithJunitRule.java | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/ClassPathCQLDataSet.java
// public class ClassPathCQLDataSet extends AbstractCQLDataSet implements CQLDataSet {
//
// public ClassPathCQLDataSet(String dataSetLocation) {
// super(dataSetLocation, true, true, null);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation) {
// super(dataSetLocation, keyspaceCreation, true);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, String keyspaceName) {
// super(dataSetLocation, true, true , keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, true, keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, keyspaceName);
// }
//
// @Override
// protected InputStream getInputDataSetLocation(String dataSetLocation) {
// return this.getClass().getResourceAsStream("/" + dataSetLocation);
// }
// }
| import com.datastax.oss.driver.api.core.cql.ResultSet;
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.Rule;
import org.junit.Test;
import static org.junit.Assert.assertEquals; | package org.cassandraunit;
/**
*
* @author Jeremy Sevellec
*
*/
public class CQLDataLoadTestWithJunitRule {
@Rule | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/ClassPathCQLDataSet.java
// public class ClassPathCQLDataSet extends AbstractCQLDataSet implements CQLDataSet {
//
// public ClassPathCQLDataSet(String dataSetLocation) {
// super(dataSetLocation, true, true, null);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation) {
// super(dataSetLocation, keyspaceCreation, true);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, String keyspaceName) {
// super(dataSetLocation, true, true , keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, true, keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, keyspaceName);
// }
//
// @Override
// protected InputStream getInputDataSetLocation(String dataSetLocation) {
// return this.getClass().getResourceAsStream("/" + dataSetLocation);
// }
// }
// Path: cassandra-unit/src/test/java/org/cassandraunit/CQLDataLoadTestWithJunitRule.java
import com.datastax.oss.driver.api.core.cql.ResultSet;
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.Rule;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
package org.cassandraunit;
/**
*
* @author Jeremy Sevellec
*
*/
public class CQLDataLoadTestWithJunitRule {
@Rule | public CassandraCQLUnit cassandraCQLUnit = new CassandraCQLUnit(new ClassPathCQLDataSet("cql/simple.cql", "mykeyspace")); |
jsevellec/cassandra-unit | cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/AbstractCQLDataSet.java | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/CQLDataSet.java
// public interface CQLDataSet {
//
// List<String> getCQLStatements();
//
// String getKeyspaceName();
//
// boolean isKeyspaceCreation();
//
// boolean isKeyspaceDeletion();
// }
//
// Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/ParseException.java
// public class ParseException extends RuntimeException {
//
// public ParseException(Throwable e) {
// super(e);
// }
//
// public ParseException(String message) {
// super(message);
// }
// }
| import org.cassandraunit.dataset.CQLDataSet;
import org.cassandraunit.dataset.ParseException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.stream.Collectors; | package org.cassandraunit.dataset.cql;
/**
* @author Jeremy Sevellec
*/
public abstract class AbstractCQLDataSet implements CQLDataSet {
public static final String END_OF_STATEMENT_DELIMITER = ";";
private String dataSetLocation = null;
private String keyspaceName = null;
private boolean keyspaceCreation = true;
private boolean keyspaceDeletion = true;
public AbstractCQLDataSet(String dataSetLocation) {
this.dataSetLocation = dataSetLocation;
}
public AbstractCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
this(dataSetLocation, keyspaceCreation, keyspaceDeletion, null);
}
public AbstractCQLDataSet(String dataSetLocation, String keyspaceName) {
this(dataSetLocation, true, true, keyspaceName);
}
public AbstractCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
if (getInputDataSetLocation(dataSetLocation) == null) { | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/CQLDataSet.java
// public interface CQLDataSet {
//
// List<String> getCQLStatements();
//
// String getKeyspaceName();
//
// boolean isKeyspaceCreation();
//
// boolean isKeyspaceDeletion();
// }
//
// Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/ParseException.java
// public class ParseException extends RuntimeException {
//
// public ParseException(Throwable e) {
// super(e);
// }
//
// public ParseException(String message) {
// super(message);
// }
// }
// Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/AbstractCQLDataSet.java
import org.cassandraunit.dataset.CQLDataSet;
import org.cassandraunit.dataset.ParseException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.stream.Collectors;
package org.cassandraunit.dataset.cql;
/**
* @author Jeremy Sevellec
*/
public abstract class AbstractCQLDataSet implements CQLDataSet {
public static final String END_OF_STATEMENT_DELIMITER = ";";
private String dataSetLocation = null;
private String keyspaceName = null;
private boolean keyspaceCreation = true;
private boolean keyspaceDeletion = true;
public AbstractCQLDataSet(String dataSetLocation) {
this.dataSetLocation = dataSetLocation;
}
public AbstractCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
this(dataSetLocation, keyspaceCreation, keyspaceDeletion, null);
}
public AbstractCQLDataSet(String dataSetLocation, String keyspaceName) {
this(dataSetLocation, true, true, keyspaceName);
}
public AbstractCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
if (getInputDataSetLocation(dataSetLocation) == null) { | throw new ParseException("Dataset not found"); |
jsevellec/cassandra-unit | cassandra-unit/src/test/java/org/cassandraunit/CQLDataLoadTestWithMultiLineCQLStatements.java | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/ClassPathCQLDataSet.java
// public class ClassPathCQLDataSet extends AbstractCQLDataSet implements CQLDataSet {
//
// public ClassPathCQLDataSet(String dataSetLocation) {
// super(dataSetLocation, true, true, null);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation) {
// super(dataSetLocation, keyspaceCreation, true);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, String keyspaceName) {
// super(dataSetLocation, true, true , keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, true, keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, keyspaceName);
// }
//
// @Override
// protected InputStream getInputDataSetLocation(String dataSetLocation) {
// return this.getClass().getResourceAsStream("/" + dataSetLocation);
// }
// }
| import com.datastax.oss.driver.api.core.cql.ResultSet;
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.Rule;
import org.junit.Test;
import static org.junit.Assert.assertEquals; | package org.cassandraunit;
/**
*
* @author Jeremy Sevellec
*
*/
public class CQLDataLoadTestWithMultiLineCQLStatements {
@Rule | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/ClassPathCQLDataSet.java
// public class ClassPathCQLDataSet extends AbstractCQLDataSet implements CQLDataSet {
//
// public ClassPathCQLDataSet(String dataSetLocation) {
// super(dataSetLocation, true, true, null);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation) {
// super(dataSetLocation, keyspaceCreation, true);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, String keyspaceName) {
// super(dataSetLocation, true, true , keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, true, keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, keyspaceName);
// }
//
// @Override
// protected InputStream getInputDataSetLocation(String dataSetLocation) {
// return this.getClass().getResourceAsStream("/" + dataSetLocation);
// }
// }
// Path: cassandra-unit/src/test/java/org/cassandraunit/CQLDataLoadTestWithMultiLineCQLStatements.java
import com.datastax.oss.driver.api.core.cql.ResultSet;
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.Rule;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
package org.cassandraunit;
/**
*
* @author Jeremy Sevellec
*
*/
public class CQLDataLoadTestWithMultiLineCQLStatements {
@Rule | public CassandraCQLUnit cassandraCQLUnit = new CassandraCQLUnit(new ClassPathCQLDataSet("cql/multiLineStatements.cql", "mykeyspace")); |
jsevellec/cassandra-unit | cassandra-unit/src/test/java/org/cassandraunit/CQLDataLoadTestWithNoKeyspaceDeletion.java | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/ClassPathCQLDataSet.java
// public class ClassPathCQLDataSet extends AbstractCQLDataSet implements CQLDataSet {
//
// public ClassPathCQLDataSet(String dataSetLocation) {
// super(dataSetLocation, true, true, null);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation) {
// super(dataSetLocation, keyspaceCreation, true);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, String keyspaceName) {
// super(dataSetLocation, true, true , keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, true, keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, keyspaceName);
// }
//
// @Override
// protected InputStream getInputDataSetLocation(String dataSetLocation) {
// return this.getClass().getResourceAsStream("/" + dataSetLocation);
// }
// }
| import com.datastax.oss.driver.api.core.cql.ResultSet;
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.Rule;
import org.junit.Test;
import static org.junit.Assert.assertEquals; | package org.cassandraunit;
public class CQLDataLoadTestWithNoKeyspaceDeletion {
@Rule | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/ClassPathCQLDataSet.java
// public class ClassPathCQLDataSet extends AbstractCQLDataSet implements CQLDataSet {
//
// public ClassPathCQLDataSet(String dataSetLocation) {
// super(dataSetLocation, true, true, null);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation) {
// super(dataSetLocation, keyspaceCreation, true);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, String keyspaceName) {
// super(dataSetLocation, true, true , keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, true, keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, keyspaceName);
// }
//
// @Override
// protected InputStream getInputDataSetLocation(String dataSetLocation) {
// return this.getClass().getResourceAsStream("/" + dataSetLocation);
// }
// }
// Path: cassandra-unit/src/test/java/org/cassandraunit/CQLDataLoadTestWithNoKeyspaceDeletion.java
import com.datastax.oss.driver.api.core.cql.ResultSet;
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.Rule;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
package org.cassandraunit;
public class CQLDataLoadTestWithNoKeyspaceDeletion {
@Rule | public CassandraCQLUnit cassandraCQLUnit = new CassandraCQLUnit(new ClassPathCQLDataSet("cql/simple.cql", true, false, "mykeyspace")); |
jsevellec/cassandra-unit | cassandra-unit/src/test/java/org/cassandraunit/dataset/cql/ClasspathCQLDataSetTest.java | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/CQLDataSet.java
// public interface CQLDataSet {
//
// List<String> getCQLStatements();
//
// String getKeyspaceName();
//
// boolean isKeyspaceCreation();
//
// boolean isKeyspaceDeletion();
// }
//
// Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/ParseException.java
// public class ParseException extends RuntimeException {
//
// public ParseException(Throwable e) {
// super(e);
// }
//
// public ParseException(String message) {
// super(message);
// }
// }
| import org.cassandraunit.dataset.CQLDataSet;
import org.cassandraunit.dataset.ParseException;
import org.junit.Test;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; | package org.cassandraunit.dataset.cql;
/**
* @author Jeremy Sevellec
*/
public class ClasspathCQLDataSetTest {
@Test
public void shouldGetACQLDataSet() {
| // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/CQLDataSet.java
// public interface CQLDataSet {
//
// List<String> getCQLStatements();
//
// String getKeyspaceName();
//
// boolean isKeyspaceCreation();
//
// boolean isKeyspaceDeletion();
// }
//
// Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/ParseException.java
// public class ParseException extends RuntimeException {
//
// public ParseException(Throwable e) {
// super(e);
// }
//
// public ParseException(String message) {
// super(message);
// }
// }
// Path: cassandra-unit/src/test/java/org/cassandraunit/dataset/cql/ClasspathCQLDataSetTest.java
import org.cassandraunit.dataset.CQLDataSet;
import org.cassandraunit.dataset.ParseException;
import org.junit.Test;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
package org.cassandraunit.dataset.cql;
/**
* @author Jeremy Sevellec
*/
public class ClasspathCQLDataSetTest {
@Test
public void shouldGetACQLDataSet() {
| CQLDataSet dataSet = new ClassPathCQLDataSet("cql/simple.cql"); |
jsevellec/cassandra-unit | cassandra-unit/src/test/java/org/cassandraunit/dataset/cql/ClasspathCQLDataSetTest.java | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/CQLDataSet.java
// public interface CQLDataSet {
//
// List<String> getCQLStatements();
//
// String getKeyspaceName();
//
// boolean isKeyspaceCreation();
//
// boolean isKeyspaceDeletion();
// }
//
// Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/ParseException.java
// public class ParseException extends RuntimeException {
//
// public ParseException(Throwable e) {
// super(e);
// }
//
// public ParseException(String message) {
// super(message);
// }
// }
| import org.cassandraunit.dataset.CQLDataSet;
import org.cassandraunit.dataset.ParseException;
import org.junit.Test;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; | package org.cassandraunit.dataset.cql;
/**
* @author Jeremy Sevellec
*/
public class ClasspathCQLDataSetTest {
@Test
public void shouldGetACQLDataSet() {
CQLDataSet dataSet = new ClassPathCQLDataSet("cql/simple.cql");
assertThat(dataSet, notNullValue());
}
@Test
public void shouldNotGetACQLDataSetBecauseNull() {
try {
CQLDataSet dataSet = new ClassPathCQLDataSet(null);
fail(); | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/CQLDataSet.java
// public interface CQLDataSet {
//
// List<String> getCQLStatements();
//
// String getKeyspaceName();
//
// boolean isKeyspaceCreation();
//
// boolean isKeyspaceDeletion();
// }
//
// Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/ParseException.java
// public class ParseException extends RuntimeException {
//
// public ParseException(Throwable e) {
// super(e);
// }
//
// public ParseException(String message) {
// super(message);
// }
// }
// Path: cassandra-unit/src/test/java/org/cassandraunit/dataset/cql/ClasspathCQLDataSetTest.java
import org.cassandraunit.dataset.CQLDataSet;
import org.cassandraunit.dataset.ParseException;
import org.junit.Test;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
package org.cassandraunit.dataset.cql;
/**
* @author Jeremy Sevellec
*/
public class ClasspathCQLDataSetTest {
@Test
public void shouldGetACQLDataSet() {
CQLDataSet dataSet = new ClassPathCQLDataSet("cql/simple.cql");
assertThat(dataSet, notNullValue());
}
@Test
public void shouldNotGetACQLDataSetBecauseNull() {
try {
CQLDataSet dataSet = new ClassPathCQLDataSet(null);
fail(); | } catch (ParseException e) { |
jsevellec/cassandra-unit | cassandra-unit/src/test/java/org/cassandraunit/CQLDataLoadTestWithReadTimeout.java | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/ClassPathCQLDataSet.java
// public class ClassPathCQLDataSet extends AbstractCQLDataSet implements CQLDataSet {
//
// public ClassPathCQLDataSet(String dataSetLocation) {
// super(dataSetLocation, true, true, null);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation) {
// super(dataSetLocation, keyspaceCreation, true);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, String keyspaceName) {
// super(dataSetLocation, true, true , keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, true, keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, keyspaceName);
// }
//
// @Override
// protected InputStream getInputDataSetLocation(String dataSetLocation) {
// return this.getClass().getResourceAsStream("/" + dataSetLocation);
// }
// }
| import com.datastax.oss.driver.api.core.cql.ResultSet;
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.Rule;
import org.junit.Test;
import static org.junit.Assert.assertEquals; | package org.cassandraunit;
/**
*
* @author Jeremy Sevellec
*
*/
public class CQLDataLoadTestWithReadTimeout {
private static final int READ_TIMEOUT_VALUE = 15000;
@Rule | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/ClassPathCQLDataSet.java
// public class ClassPathCQLDataSet extends AbstractCQLDataSet implements CQLDataSet {
//
// public ClassPathCQLDataSet(String dataSetLocation) {
// super(dataSetLocation, true, true, null);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation) {
// super(dataSetLocation, keyspaceCreation, true);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, String keyspaceName) {
// super(dataSetLocation, true, true , keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, true, keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, keyspaceName);
// }
//
// @Override
// protected InputStream getInputDataSetLocation(String dataSetLocation) {
// return this.getClass().getResourceAsStream("/" + dataSetLocation);
// }
// }
// Path: cassandra-unit/src/test/java/org/cassandraunit/CQLDataLoadTestWithReadTimeout.java
import com.datastax.oss.driver.api.core.cql.ResultSet;
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.Rule;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
package org.cassandraunit;
/**
*
* @author Jeremy Sevellec
*
*/
public class CQLDataLoadTestWithReadTimeout {
private static final int READ_TIMEOUT_VALUE = 15000;
@Rule | public CassandraCQLUnit cassandraCQLUnit = new CassandraCQLUnit(new ClassPathCQLDataSet("cql/simple.cql", |
jsevellec/cassandra-unit | cassandra-unit/src/main/java/org/cassandraunit/CQLDataLoader.java | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/CQLDataSet.java
// public interface CQLDataSet {
//
// List<String> getCQLStatements();
//
// String getKeyspaceName();
//
// boolean isKeyspaceCreation();
//
// boolean isKeyspaceDeletion();
// }
//
// Path: cassandra-unit/src/main/java/org/cassandraunit/utils/CqlOperations.java
// public class CqlOperations {
//
// private static final Logger log = LoggerFactory.getLogger(CqlOperations.class);
//
// public static Consumer<String> execute(CqlSession session) {
// return query -> {
// log.debug("executing : {}", query);
// session.execute(query);
// };
// }
//
// public static Consumer<String> use(CqlSession session) {
// return keyspace -> session.execute("USE " + keyspace);
// }
//
// public static Consumer<String> truncateTable(CqlSession session) {
// return fullyQualifiedTable -> session.execute("truncate table " + fullyQualifiedTable);
// }
//
// public static Consumer<String> dropKeyspace(CqlSession session) {
// return keyspace -> execute(session).accept("DROP KEYSPACE IF EXISTS " + keyspace);
// }
//
// public static Consumer<String> createKeyspace(CqlSession session) {
// return keyspace -> execute(session).accept("CREATE KEYSPACE IF NOT EXISTS " + keyspace + " WITH replication={'class' : 'SimpleStrategy', 'replication_factor':1} AND durable_writes = false");
// }
// }
| import com.datastax.oss.driver.api.core.CqlSession;
import org.cassandraunit.dataset.CQLDataSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.cassandraunit.utils.CqlOperations.*; | package org.cassandraunit;
/**
* @author Marcin Szymaniuk
* @author Jeremy Sevellec
*/
public class CQLDataLoader {
private static final Logger log = LoggerFactory.getLogger(CQLDataLoader.class);
public static final String DEFAULT_KEYSPACE_NAME = "cassandraunitkeyspace";
public CqlSession getSession() {
return session;
}
private final CqlSession session;
public CQLDataLoader(CqlSession session) {
this.session = session;
}
| // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/CQLDataSet.java
// public interface CQLDataSet {
//
// List<String> getCQLStatements();
//
// String getKeyspaceName();
//
// boolean isKeyspaceCreation();
//
// boolean isKeyspaceDeletion();
// }
//
// Path: cassandra-unit/src/main/java/org/cassandraunit/utils/CqlOperations.java
// public class CqlOperations {
//
// private static final Logger log = LoggerFactory.getLogger(CqlOperations.class);
//
// public static Consumer<String> execute(CqlSession session) {
// return query -> {
// log.debug("executing : {}", query);
// session.execute(query);
// };
// }
//
// public static Consumer<String> use(CqlSession session) {
// return keyspace -> session.execute("USE " + keyspace);
// }
//
// public static Consumer<String> truncateTable(CqlSession session) {
// return fullyQualifiedTable -> session.execute("truncate table " + fullyQualifiedTable);
// }
//
// public static Consumer<String> dropKeyspace(CqlSession session) {
// return keyspace -> execute(session).accept("DROP KEYSPACE IF EXISTS " + keyspace);
// }
//
// public static Consumer<String> createKeyspace(CqlSession session) {
// return keyspace -> execute(session).accept("CREATE KEYSPACE IF NOT EXISTS " + keyspace + " WITH replication={'class' : 'SimpleStrategy', 'replication_factor':1} AND durable_writes = false");
// }
// }
// Path: cassandra-unit/src/main/java/org/cassandraunit/CQLDataLoader.java
import com.datastax.oss.driver.api.core.CqlSession;
import org.cassandraunit.dataset.CQLDataSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.cassandraunit.utils.CqlOperations.*;
package org.cassandraunit;
/**
* @author Marcin Szymaniuk
* @author Jeremy Sevellec
*/
public class CQLDataLoader {
private static final Logger log = LoggerFactory.getLogger(CQLDataLoader.class);
public static final String DEFAULT_KEYSPACE_NAME = "cassandraunitkeyspace";
public CqlSession getSession() {
return session;
}
private final CqlSession session;
public CQLDataLoader(CqlSession session) {
this.session = session;
}
| public void load(CQLDataSet dataSet) { |
jsevellec/cassandra-unit | cassandra-unit/src/test/java/org/cassandraunit/CQLDataLoadTestWithBlankLineEndings.java | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/ClassPathCQLDataSet.java
// public class ClassPathCQLDataSet extends AbstractCQLDataSet implements CQLDataSet {
//
// public ClassPathCQLDataSet(String dataSetLocation) {
// super(dataSetLocation, true, true, null);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation) {
// super(dataSetLocation, keyspaceCreation, true);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, String keyspaceName) {
// super(dataSetLocation, true, true , keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, true, keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, keyspaceName);
// }
//
// @Override
// protected InputStream getInputDataSetLocation(String dataSetLocation) {
// return this.getClass().getResourceAsStream("/" + dataSetLocation);
// }
// }
| import com.datastax.oss.driver.api.core.cql.ResultSet;
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.Rule;
import org.junit.Test;
import static org.junit.Assert.assertEquals; | package org.cassandraunit;
/**
*
* @author Laurent Liger
*
*/
public class CQLDataLoadTestWithBlankLineEndings {
@Rule | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/ClassPathCQLDataSet.java
// public class ClassPathCQLDataSet extends AbstractCQLDataSet implements CQLDataSet {
//
// public ClassPathCQLDataSet(String dataSetLocation) {
// super(dataSetLocation, true, true, null);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation) {
// super(dataSetLocation, keyspaceCreation, true);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, String keyspaceName) {
// super(dataSetLocation, true, true , keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, true, keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, keyspaceName);
// }
//
// @Override
// protected InputStream getInputDataSetLocation(String dataSetLocation) {
// return this.getClass().getResourceAsStream("/" + dataSetLocation);
// }
// }
// Path: cassandra-unit/src/test/java/org/cassandraunit/CQLDataLoadTestWithBlankLineEndings.java
import com.datastax.oss.driver.api.core.cql.ResultSet;
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.Rule;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
package org.cassandraunit;
/**
*
* @author Laurent Liger
*
*/
public class CQLDataLoadTestWithBlankLineEndings {
@Rule | public CassandraCQLUnit cassandraCQLUnit = new CassandraCQLUnit(new ClassPathCQLDataSet("cql/statementsWithBlankEndings.cql", "mykeyspace")); |
jsevellec/cassandra-unit | cassandra-unit/src/test/java/org/cassandraunit/CQLDataLoadTestWithClassInheritance.java | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/CQLDataSet.java
// public interface CQLDataSet {
//
// List<String> getCQLStatements();
//
// String getKeyspaceName();
//
// boolean isKeyspaceCreation();
//
// boolean isKeyspaceDeletion();
// }
//
// Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/ClassPathCQLDataSet.java
// public class ClassPathCQLDataSet extends AbstractCQLDataSet implements CQLDataSet {
//
// public ClassPathCQLDataSet(String dataSetLocation) {
// super(dataSetLocation, true, true, null);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation) {
// super(dataSetLocation, keyspaceCreation, true);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, String keyspaceName) {
// super(dataSetLocation, true, true , keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, true, keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, keyspaceName);
// }
//
// @Override
// protected InputStream getInputDataSetLocation(String dataSetLocation) {
// return this.getClass().getResourceAsStream("/" + dataSetLocation);
// }
// }
| import com.datastax.oss.driver.api.core.cql.ResultSet;
import org.cassandraunit.dataset.CQLDataSet;
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.Test;
import static org.junit.Assert.assertEquals; | package org.cassandraunit;
/**
*
* @author Marcin Szymaniuk
* @author Jeremy Sevellec
*
*/
public class CQLDataLoadTestWithClassInheritance extends AbstractCassandraUnit4CQLTestCase {
@Override | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/CQLDataSet.java
// public interface CQLDataSet {
//
// List<String> getCQLStatements();
//
// String getKeyspaceName();
//
// boolean isKeyspaceCreation();
//
// boolean isKeyspaceDeletion();
// }
//
// Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/ClassPathCQLDataSet.java
// public class ClassPathCQLDataSet extends AbstractCQLDataSet implements CQLDataSet {
//
// public ClassPathCQLDataSet(String dataSetLocation) {
// super(dataSetLocation, true, true, null);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation) {
// super(dataSetLocation, keyspaceCreation, true);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, String keyspaceName) {
// super(dataSetLocation, true, true , keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, true, keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, keyspaceName);
// }
//
// @Override
// protected InputStream getInputDataSetLocation(String dataSetLocation) {
// return this.getClass().getResourceAsStream("/" + dataSetLocation);
// }
// }
// Path: cassandra-unit/src/test/java/org/cassandraunit/CQLDataLoadTestWithClassInheritance.java
import com.datastax.oss.driver.api.core.cql.ResultSet;
import org.cassandraunit.dataset.CQLDataSet;
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
package org.cassandraunit;
/**
*
* @author Marcin Szymaniuk
* @author Jeremy Sevellec
*
*/
public class CQLDataLoadTestWithClassInheritance extends AbstractCassandraUnit4CQLTestCase {
@Override | public CQLDataSet getDataSet() { |
jsevellec/cassandra-unit | cassandra-unit/src/test/java/org/cassandraunit/CQLDataLoadTestWithClassInheritance.java | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/CQLDataSet.java
// public interface CQLDataSet {
//
// List<String> getCQLStatements();
//
// String getKeyspaceName();
//
// boolean isKeyspaceCreation();
//
// boolean isKeyspaceDeletion();
// }
//
// Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/ClassPathCQLDataSet.java
// public class ClassPathCQLDataSet extends AbstractCQLDataSet implements CQLDataSet {
//
// public ClassPathCQLDataSet(String dataSetLocation) {
// super(dataSetLocation, true, true, null);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation) {
// super(dataSetLocation, keyspaceCreation, true);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, String keyspaceName) {
// super(dataSetLocation, true, true , keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, true, keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, keyspaceName);
// }
//
// @Override
// protected InputStream getInputDataSetLocation(String dataSetLocation) {
// return this.getClass().getResourceAsStream("/" + dataSetLocation);
// }
// }
| import com.datastax.oss.driver.api.core.cql.ResultSet;
import org.cassandraunit.dataset.CQLDataSet;
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.Test;
import static org.junit.Assert.assertEquals; | package org.cassandraunit;
/**
*
* @author Marcin Szymaniuk
* @author Jeremy Sevellec
*
*/
public class CQLDataLoadTestWithClassInheritance extends AbstractCassandraUnit4CQLTestCase {
@Override
public CQLDataSet getDataSet() { | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/CQLDataSet.java
// public interface CQLDataSet {
//
// List<String> getCQLStatements();
//
// String getKeyspaceName();
//
// boolean isKeyspaceCreation();
//
// boolean isKeyspaceDeletion();
// }
//
// Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/ClassPathCQLDataSet.java
// public class ClassPathCQLDataSet extends AbstractCQLDataSet implements CQLDataSet {
//
// public ClassPathCQLDataSet(String dataSetLocation) {
// super(dataSetLocation, true, true, null);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation) {
// super(dataSetLocation, keyspaceCreation, true);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, String keyspaceName) {
// super(dataSetLocation, true, true , keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, true, keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, keyspaceName);
// }
//
// @Override
// protected InputStream getInputDataSetLocation(String dataSetLocation) {
// return this.getClass().getResourceAsStream("/" + dataSetLocation);
// }
// }
// Path: cassandra-unit/src/test/java/org/cassandraunit/CQLDataLoadTestWithClassInheritance.java
import com.datastax.oss.driver.api.core.cql.ResultSet;
import org.cassandraunit.dataset.CQLDataSet;
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
package org.cassandraunit;
/**
*
* @author Marcin Szymaniuk
* @author Jeremy Sevellec
*
*/
public class CQLDataLoadTestWithClassInheritance extends AbstractCassandraUnit4CQLTestCase {
@Override
public CQLDataSet getDataSet() { | return new ClassPathCQLDataSet("cql/simple.cql", "mykeyspace"); |
jsevellec/cassandra-unit | cassandra-unit/src/test/java/org/cassandraunit/CQLDataLoadTestWithNoKeyspaceCreation.java | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/ClassPathCQLDataSet.java
// public class ClassPathCQLDataSet extends AbstractCQLDataSet implements CQLDataSet {
//
// public ClassPathCQLDataSet(String dataSetLocation) {
// super(dataSetLocation, true, true, null);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation) {
// super(dataSetLocation, keyspaceCreation, true);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, String keyspaceName) {
// super(dataSetLocation, true, true , keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, true, keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, keyspaceName);
// }
//
// @Override
// protected InputStream getInputDataSetLocation(String dataSetLocation) {
// return this.getClass().getResourceAsStream("/" + dataSetLocation);
// }
// }
| import com.datastax.oss.driver.api.core.cql.ResultSet;
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.Rule;
import org.junit.Test;
import static org.junit.Assert.assertEquals; | package org.cassandraunit;
/**
*
* @author Jeremy Sevellec
*
*/
public class CQLDataLoadTestWithNoKeyspaceCreation {
@Rule | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/ClassPathCQLDataSet.java
// public class ClassPathCQLDataSet extends AbstractCQLDataSet implements CQLDataSet {
//
// public ClassPathCQLDataSet(String dataSetLocation) {
// super(dataSetLocation, true, true, null);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation) {
// super(dataSetLocation, keyspaceCreation, true);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, String keyspaceName) {
// super(dataSetLocation, true, true , keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, true, keyspaceName);
// }
//
// public ClassPathCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, keyspaceName);
// }
//
// @Override
// protected InputStream getInputDataSetLocation(String dataSetLocation) {
// return this.getClass().getResourceAsStream("/" + dataSetLocation);
// }
// }
// Path: cassandra-unit/src/test/java/org/cassandraunit/CQLDataLoadTestWithNoKeyspaceCreation.java
import com.datastax.oss.driver.api.core.cql.ResultSet;
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.Rule;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
package org.cassandraunit;
/**
*
* @author Jeremy Sevellec
*
*/
public class CQLDataLoadTestWithNoKeyspaceCreation {
@Rule | public CassandraCQLUnit cassandraCQLUnit = new CassandraCQLUnit(new ClassPathCQLDataSet("cql/simpleWithKeyspaceCreation.cql", false, "mykeyspace")); |
jsevellec/cassandra-unit | cassandra-unit/src/test/java/org/cassandraunit/dataset/cql/FileCQLDataSetTest.java | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/CQLDataSet.java
// public interface CQLDataSet {
//
// List<String> getCQLStatements();
//
// String getKeyspaceName();
//
// boolean isKeyspaceCreation();
//
// boolean isKeyspaceDeletion();
// }
//
// Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/ParseException.java
// public class ParseException extends RuntimeException {
//
// public ParseException(Throwable e) {
// super(e);
// }
//
// public ParseException(String message) {
// super(message);
// }
// }
| import org.cassandraunit.dataset.AbstractFileDataSetTest;
import org.cassandraunit.dataset.CQLDataSet;
import org.cassandraunit.dataset.ParseException;
import org.junit.Test;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; | package org.cassandraunit.dataset.cql;
/**
*
* @author Jeremy Sevellec
*
*/
public class FileCQLDataSetTest extends AbstractFileDataSetTest {
@Override
public String getDataSetClasspathRessource() {
return "/cql/simple.cql";
}
@Test
public void shouldGetACQLDataSet() {
| // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/CQLDataSet.java
// public interface CQLDataSet {
//
// List<String> getCQLStatements();
//
// String getKeyspaceName();
//
// boolean isKeyspaceCreation();
//
// boolean isKeyspaceDeletion();
// }
//
// Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/ParseException.java
// public class ParseException extends RuntimeException {
//
// public ParseException(Throwable e) {
// super(e);
// }
//
// public ParseException(String message) {
// super(message);
// }
// }
// Path: cassandra-unit/src/test/java/org/cassandraunit/dataset/cql/FileCQLDataSetTest.java
import org.cassandraunit.dataset.AbstractFileDataSetTest;
import org.cassandraunit.dataset.CQLDataSet;
import org.cassandraunit.dataset.ParseException;
import org.junit.Test;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
package org.cassandraunit.dataset.cql;
/**
*
* @author Jeremy Sevellec
*
*/
public class FileCQLDataSetTest extends AbstractFileDataSetTest {
@Override
public String getDataSetClasspathRessource() {
return "/cql/simple.cql";
}
@Test
public void shouldGetACQLDataSet() {
| CQLDataSet dataSet = new FileCQLDataSet(super.targetDataSetPathFileName); |
jsevellec/cassandra-unit | cassandra-unit/src/test/java/org/cassandraunit/dataset/cql/FileCQLDataSetTest.java | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/CQLDataSet.java
// public interface CQLDataSet {
//
// List<String> getCQLStatements();
//
// String getKeyspaceName();
//
// boolean isKeyspaceCreation();
//
// boolean isKeyspaceDeletion();
// }
//
// Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/ParseException.java
// public class ParseException extends RuntimeException {
//
// public ParseException(Throwable e) {
// super(e);
// }
//
// public ParseException(String message) {
// super(message);
// }
// }
| import org.cassandraunit.dataset.AbstractFileDataSetTest;
import org.cassandraunit.dataset.CQLDataSet;
import org.cassandraunit.dataset.ParseException;
import org.junit.Test;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; | package org.cassandraunit.dataset.cql;
/**
*
* @author Jeremy Sevellec
*
*/
public class FileCQLDataSetTest extends AbstractFileDataSetTest {
@Override
public String getDataSetClasspathRessource() {
return "/cql/simple.cql";
}
@Test
public void shouldGetACQLDataSet() {
CQLDataSet dataSet = new FileCQLDataSet(super.targetDataSetPathFileName);
assertThat(dataSet, notNullValue());
}
@Test
public void shouldNotGetACQLDataSetBecauseNull() {
try {
CQLDataSet dataSet = new FileCQLDataSet(null);
fail(); | // Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/CQLDataSet.java
// public interface CQLDataSet {
//
// List<String> getCQLStatements();
//
// String getKeyspaceName();
//
// boolean isKeyspaceCreation();
//
// boolean isKeyspaceDeletion();
// }
//
// Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/ParseException.java
// public class ParseException extends RuntimeException {
//
// public ParseException(Throwable e) {
// super(e);
// }
//
// public ParseException(String message) {
// super(message);
// }
// }
// Path: cassandra-unit/src/test/java/org/cassandraunit/dataset/cql/FileCQLDataSetTest.java
import org.cassandraunit.dataset.AbstractFileDataSetTest;
import org.cassandraunit.dataset.CQLDataSet;
import org.cassandraunit.dataset.ParseException;
import org.junit.Test;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
package org.cassandraunit.dataset.cql;
/**
*
* @author Jeremy Sevellec
*
*/
public class FileCQLDataSetTest extends AbstractFileDataSetTest {
@Override
public String getDataSetClasspathRessource() {
return "/cql/simple.cql";
}
@Test
public void shouldGetACQLDataSet() {
CQLDataSet dataSet = new FileCQLDataSet(super.targetDataSetPathFileName);
assertThat(dataSet, notNullValue());
}
@Test
public void shouldNotGetACQLDataSetBecauseNull() {
try {
CQLDataSet dataSet = new FileCQLDataSet(null);
fail(); | } catch (ParseException e) { |
jsevellec/cassandra-unit | cassandra-unit/src/main/java/org/cassandraunit/cli/CassandraUnitCommandLineLoader.java | // Path: cassandra-unit/src/main/java/org/cassandraunit/CQLDataLoader.java
// public class CQLDataLoader {
//
// private static final Logger log = LoggerFactory.getLogger(CQLDataLoader.class);
// public static final String DEFAULT_KEYSPACE_NAME = "cassandraunitkeyspace";
//
// public CqlSession getSession() {
// return session;
// }
//
// private final CqlSession session;
//
// public CQLDataLoader(CqlSession session) {
// this.session = session;
// }
//
// public void load(CQLDataSet dataSet) {
// initKeyspaceContext(session, dataSet);
//
// log.debug("loading data");
// dataSet.getCQLStatements().stream()
// .forEach(execute(session));
//
// if (dataSet.getKeyspaceName() != null) {
// use(session).accept(dataSet.getKeyspaceName());
// }
// }
//
// private void initKeyspaceContext(CqlSession session, CQLDataSet dataSet) {
// String keyspaceName = DEFAULT_KEYSPACE_NAME;
// if (dataSet.getKeyspaceName() != null) {
// keyspaceName = dataSet.getKeyspaceName();
// }
//
// log.debug("initKeyspaceContext : keyspaceDeletion={} keyspaceCreation={} ;keyspaceName={}",
// dataSet.isKeyspaceDeletion(), dataSet.isKeyspaceCreation(), keyspaceName);
//
// if (dataSet.isKeyspaceDeletion()) {
// dropKeyspace(session).accept(keyspaceName);
// }
//
// if (dataSet.isKeyspaceCreation()) {
// createKeyspace(session).accept(keyspaceName);
// use(session).accept(keyspaceName);
// }
// }
// }
//
// Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/FileCQLDataSet.java
// public class FileCQLDataSet extends AbstractCQLDataSet implements CQLDataSet {
//
// public FileCQLDataSet(String dataSetLocation) {
// super(dataSetLocation, true, true, null);
// }
//
// public FileCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, null);
// }
//
// public FileCQLDataSet(String dataSetLocation, String keyspaceName) {
// super(dataSetLocation, true, true, keyspaceName);
// }
//
// public FileCQLDataSet(String dataSetLocation, boolean keyspaceCreation) {
// super(dataSetLocation, keyspaceCreation, true, null);
// }
//
// public FileCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, keyspaceName);
// }
//
// @Override
// protected InputStream getInputDataSetLocation(String dataSetLocation) {
// if (dataSetLocation == null) {
// return null;
// }
// try {
// return new FileInputStream(dataSetLocation);
// } catch (FileNotFoundException e) {
// return null;
// }
// }
// }
| import com.datastax.oss.driver.api.core.CqlSession;
import org.apache.commons.cli.*;
import org.apache.commons.lang3.StringUtils;
import org.cassandraunit.CQLDataLoader;
import org.cassandraunit.dataset.cql.FileCQLDataSet;
import java.net.InetSocketAddress; | exit = true;
}
return exit;
}
protected static void load() {
System.out.println("Start Loading...");
String host = commandLine.getOptionValue("h");
String port = commandLine.getOptionValue("p");
String file = commandLine.getOptionValue("f");
String fileExtension = StringUtils.substringAfterLast(file, ".");
if (CQL_FILE_EXTENSION.equals(fileExtension)) {
cqlDataSetLoad(host, port, file);
} else {
otherTypeOfDataSetLoad(host, port, file);
}
System.out.println("Loading completed");
}
private static void otherTypeOfDataSetLoad(String host, String port, String file) {
CqlSession session = CqlSession.builder()
.addContactPoint(new InetSocketAddress(host, Integer.parseInt(port)))
.withLocalDatacenter("datacenter1")
.build();
| // Path: cassandra-unit/src/main/java/org/cassandraunit/CQLDataLoader.java
// public class CQLDataLoader {
//
// private static final Logger log = LoggerFactory.getLogger(CQLDataLoader.class);
// public static final String DEFAULT_KEYSPACE_NAME = "cassandraunitkeyspace";
//
// public CqlSession getSession() {
// return session;
// }
//
// private final CqlSession session;
//
// public CQLDataLoader(CqlSession session) {
// this.session = session;
// }
//
// public void load(CQLDataSet dataSet) {
// initKeyspaceContext(session, dataSet);
//
// log.debug("loading data");
// dataSet.getCQLStatements().stream()
// .forEach(execute(session));
//
// if (dataSet.getKeyspaceName() != null) {
// use(session).accept(dataSet.getKeyspaceName());
// }
// }
//
// private void initKeyspaceContext(CqlSession session, CQLDataSet dataSet) {
// String keyspaceName = DEFAULT_KEYSPACE_NAME;
// if (dataSet.getKeyspaceName() != null) {
// keyspaceName = dataSet.getKeyspaceName();
// }
//
// log.debug("initKeyspaceContext : keyspaceDeletion={} keyspaceCreation={} ;keyspaceName={}",
// dataSet.isKeyspaceDeletion(), dataSet.isKeyspaceCreation(), keyspaceName);
//
// if (dataSet.isKeyspaceDeletion()) {
// dropKeyspace(session).accept(keyspaceName);
// }
//
// if (dataSet.isKeyspaceCreation()) {
// createKeyspace(session).accept(keyspaceName);
// use(session).accept(keyspaceName);
// }
// }
// }
//
// Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/FileCQLDataSet.java
// public class FileCQLDataSet extends AbstractCQLDataSet implements CQLDataSet {
//
// public FileCQLDataSet(String dataSetLocation) {
// super(dataSetLocation, true, true, null);
// }
//
// public FileCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, null);
// }
//
// public FileCQLDataSet(String dataSetLocation, String keyspaceName) {
// super(dataSetLocation, true, true, keyspaceName);
// }
//
// public FileCQLDataSet(String dataSetLocation, boolean keyspaceCreation) {
// super(dataSetLocation, keyspaceCreation, true, null);
// }
//
// public FileCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, keyspaceName);
// }
//
// @Override
// protected InputStream getInputDataSetLocation(String dataSetLocation) {
// if (dataSetLocation == null) {
// return null;
// }
// try {
// return new FileInputStream(dataSetLocation);
// } catch (FileNotFoundException e) {
// return null;
// }
// }
// }
// Path: cassandra-unit/src/main/java/org/cassandraunit/cli/CassandraUnitCommandLineLoader.java
import com.datastax.oss.driver.api.core.CqlSession;
import org.apache.commons.cli.*;
import org.apache.commons.lang3.StringUtils;
import org.cassandraunit.CQLDataLoader;
import org.cassandraunit.dataset.cql.FileCQLDataSet;
import java.net.InetSocketAddress;
exit = true;
}
return exit;
}
protected static void load() {
System.out.println("Start Loading...");
String host = commandLine.getOptionValue("h");
String port = commandLine.getOptionValue("p");
String file = commandLine.getOptionValue("f");
String fileExtension = StringUtils.substringAfterLast(file, ".");
if (CQL_FILE_EXTENSION.equals(fileExtension)) {
cqlDataSetLoad(host, port, file);
} else {
otherTypeOfDataSetLoad(host, port, file);
}
System.out.println("Loading completed");
}
private static void otherTypeOfDataSetLoad(String host, String port, String file) {
CqlSession session = CqlSession.builder()
.addContactPoint(new InetSocketAddress(host, Integer.parseInt(port)))
.withLocalDatacenter("datacenter1")
.build();
| CQLDataLoader dataLoader = new CQLDataLoader(session); |
jsevellec/cassandra-unit | cassandra-unit/src/main/java/org/cassandraunit/cli/CassandraUnitCommandLineLoader.java | // Path: cassandra-unit/src/main/java/org/cassandraunit/CQLDataLoader.java
// public class CQLDataLoader {
//
// private static final Logger log = LoggerFactory.getLogger(CQLDataLoader.class);
// public static final String DEFAULT_KEYSPACE_NAME = "cassandraunitkeyspace";
//
// public CqlSession getSession() {
// return session;
// }
//
// private final CqlSession session;
//
// public CQLDataLoader(CqlSession session) {
// this.session = session;
// }
//
// public void load(CQLDataSet dataSet) {
// initKeyspaceContext(session, dataSet);
//
// log.debug("loading data");
// dataSet.getCQLStatements().stream()
// .forEach(execute(session));
//
// if (dataSet.getKeyspaceName() != null) {
// use(session).accept(dataSet.getKeyspaceName());
// }
// }
//
// private void initKeyspaceContext(CqlSession session, CQLDataSet dataSet) {
// String keyspaceName = DEFAULT_KEYSPACE_NAME;
// if (dataSet.getKeyspaceName() != null) {
// keyspaceName = dataSet.getKeyspaceName();
// }
//
// log.debug("initKeyspaceContext : keyspaceDeletion={} keyspaceCreation={} ;keyspaceName={}",
// dataSet.isKeyspaceDeletion(), dataSet.isKeyspaceCreation(), keyspaceName);
//
// if (dataSet.isKeyspaceDeletion()) {
// dropKeyspace(session).accept(keyspaceName);
// }
//
// if (dataSet.isKeyspaceCreation()) {
// createKeyspace(session).accept(keyspaceName);
// use(session).accept(keyspaceName);
// }
// }
// }
//
// Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/FileCQLDataSet.java
// public class FileCQLDataSet extends AbstractCQLDataSet implements CQLDataSet {
//
// public FileCQLDataSet(String dataSetLocation) {
// super(dataSetLocation, true, true, null);
// }
//
// public FileCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, null);
// }
//
// public FileCQLDataSet(String dataSetLocation, String keyspaceName) {
// super(dataSetLocation, true, true, keyspaceName);
// }
//
// public FileCQLDataSet(String dataSetLocation, boolean keyspaceCreation) {
// super(dataSetLocation, keyspaceCreation, true, null);
// }
//
// public FileCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, keyspaceName);
// }
//
// @Override
// protected InputStream getInputDataSetLocation(String dataSetLocation) {
// if (dataSetLocation == null) {
// return null;
// }
// try {
// return new FileInputStream(dataSetLocation);
// } catch (FileNotFoundException e) {
// return null;
// }
// }
// }
| import com.datastax.oss.driver.api.core.CqlSession;
import org.apache.commons.cli.*;
import org.apache.commons.lang3.StringUtils;
import org.cassandraunit.CQLDataLoader;
import org.cassandraunit.dataset.cql.FileCQLDataSet;
import java.net.InetSocketAddress; | }
return exit;
}
protected static void load() {
System.out.println("Start Loading...");
String host = commandLine.getOptionValue("h");
String port = commandLine.getOptionValue("p");
String file = commandLine.getOptionValue("f");
String fileExtension = StringUtils.substringAfterLast(file, ".");
if (CQL_FILE_EXTENSION.equals(fileExtension)) {
cqlDataSetLoad(host, port, file);
} else {
otherTypeOfDataSetLoad(host, port, file);
}
System.out.println("Loading completed");
}
private static void otherTypeOfDataSetLoad(String host, String port, String file) {
CqlSession session = CqlSession.builder()
.addContactPoint(new InetSocketAddress(host, Integer.parseInt(port)))
.withLocalDatacenter("datacenter1")
.build();
CQLDataLoader dataLoader = new CQLDataLoader(session); | // Path: cassandra-unit/src/main/java/org/cassandraunit/CQLDataLoader.java
// public class CQLDataLoader {
//
// private static final Logger log = LoggerFactory.getLogger(CQLDataLoader.class);
// public static final String DEFAULT_KEYSPACE_NAME = "cassandraunitkeyspace";
//
// public CqlSession getSession() {
// return session;
// }
//
// private final CqlSession session;
//
// public CQLDataLoader(CqlSession session) {
// this.session = session;
// }
//
// public void load(CQLDataSet dataSet) {
// initKeyspaceContext(session, dataSet);
//
// log.debug("loading data");
// dataSet.getCQLStatements().stream()
// .forEach(execute(session));
//
// if (dataSet.getKeyspaceName() != null) {
// use(session).accept(dataSet.getKeyspaceName());
// }
// }
//
// private void initKeyspaceContext(CqlSession session, CQLDataSet dataSet) {
// String keyspaceName = DEFAULT_KEYSPACE_NAME;
// if (dataSet.getKeyspaceName() != null) {
// keyspaceName = dataSet.getKeyspaceName();
// }
//
// log.debug("initKeyspaceContext : keyspaceDeletion={} keyspaceCreation={} ;keyspaceName={}",
// dataSet.isKeyspaceDeletion(), dataSet.isKeyspaceCreation(), keyspaceName);
//
// if (dataSet.isKeyspaceDeletion()) {
// dropKeyspace(session).accept(keyspaceName);
// }
//
// if (dataSet.isKeyspaceCreation()) {
// createKeyspace(session).accept(keyspaceName);
// use(session).accept(keyspaceName);
// }
// }
// }
//
// Path: cassandra-unit/src/main/java/org/cassandraunit/dataset/cql/FileCQLDataSet.java
// public class FileCQLDataSet extends AbstractCQLDataSet implements CQLDataSet {
//
// public FileCQLDataSet(String dataSetLocation) {
// super(dataSetLocation, true, true, null);
// }
//
// public FileCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, null);
// }
//
// public FileCQLDataSet(String dataSetLocation, String keyspaceName) {
// super(dataSetLocation, true, true, keyspaceName);
// }
//
// public FileCQLDataSet(String dataSetLocation, boolean keyspaceCreation) {
// super(dataSetLocation, keyspaceCreation, true, null);
// }
//
// public FileCQLDataSet(String dataSetLocation, boolean keyspaceCreation, boolean keyspaceDeletion, String keyspaceName) {
// super(dataSetLocation, keyspaceCreation, keyspaceDeletion, keyspaceName);
// }
//
// @Override
// protected InputStream getInputDataSetLocation(String dataSetLocation) {
// if (dataSetLocation == null) {
// return null;
// }
// try {
// return new FileInputStream(dataSetLocation);
// } catch (FileNotFoundException e) {
// return null;
// }
// }
// }
// Path: cassandra-unit/src/main/java/org/cassandraunit/cli/CassandraUnitCommandLineLoader.java
import com.datastax.oss.driver.api.core.CqlSession;
import org.apache.commons.cli.*;
import org.apache.commons.lang3.StringUtils;
import org.cassandraunit.CQLDataLoader;
import org.cassandraunit.dataset.cql.FileCQLDataSet;
import java.net.InetSocketAddress;
}
return exit;
}
protected static void load() {
System.out.println("Start Loading...");
String host = commandLine.getOptionValue("h");
String port = commandLine.getOptionValue("p");
String file = commandLine.getOptionValue("f");
String fileExtension = StringUtils.substringAfterLast(file, ".");
if (CQL_FILE_EXTENSION.equals(fileExtension)) {
cqlDataSetLoad(host, port, file);
} else {
otherTypeOfDataSetLoad(host, port, file);
}
System.out.println("Loading completed");
}
private static void otherTypeOfDataSetLoad(String host, String port, String file) {
CqlSession session = CqlSession.builder()
.addContactPoint(new InetSocketAddress(host, Integer.parseInt(port)))
.withLocalDatacenter("datacenter1")
.build();
CQLDataLoader dataLoader = new CQLDataLoader(session); | dataLoader.load(new FileCQLDataSet(file)); |
Xiaofei-it/Shelly | app/src/main/java/xiaofei/library/shellytest/MainActivity.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
| import retrofit2.Response;
import retrofit2.Retrofit;
import xiaofei.library.shelly.Shelly;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import java.io.IOException;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback; | /**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shellytest;
/**
* Created by Xiaofei on 16/5/26.
*/
public class MainActivity extends AppCompatActivity {
private TextView textView;
private NetInterface netInterface;
private void initRetrofit() {
Retrofit retrofit = new Retrofit.Builder()
//这里建议:- Base URL: 总是以/结尾;- @Url: 不要以/开头
.baseUrl("http://www.weather.com.cn/")
.build();
netInterface = retrofit.create(NetInterface.class);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
// Path: app/src/main/java/xiaofei/library/shellytest/MainActivity.java
import retrofit2.Response;
import retrofit2.Retrofit;
import xiaofei.library.shelly.Shelly;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import java.io.IOException;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
/**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shellytest;
/**
* Created by Xiaofei on 16/5/26.
*/
public class MainActivity extends AppCompatActivity {
private TextView textView;
private NetInterface netInterface;
private void initRetrofit() {
Retrofit retrofit = new Retrofit.Builder()
//这里建议:- Base URL: 总是以/结尾;- @Url: 不要以/开头
.baseUrl("http://www.weather.com.cn/")
.build();
netInterface = retrofit.create(NetInterface.class);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); | Shelly.register(this); |
Xiaofei-it/Shelly | shelly/src/main/java/xiaofei/library/shelly/operator/MapOperator2.java | // Path: shelly/src/main/java/xiaofei/library/shelly/function/Function2.java
// public interface Function2<T, R, S> extends Function {
// S call(T input1, R input2);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/util/TargetCenter.java
// public class TargetCenter {
//
// private static volatile TargetCenter sInstance = null;
//
// private final ConcurrentHashMap<Class<?>, CopyOnWriteArrayList<Object>> mTargets;
//
// private TargetCenter() {
// mTargets = new ConcurrentHashMap<Class<?>, CopyOnWriteArrayList<Object>>();
// }
//
// public static TargetCenter getInstance() {
// if (sInstance == null) {
// synchronized (TargetCenter.class) {
// if (sInstance == null) {
// sInstance = new TargetCenter();
// }
// }
// }
// return sInstance;
// }
//
// public void register(Object target) {
// synchronized (mTargets) {
// for (Class<?> clazz = target.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
// CopyOnWriteArrayList<Object> targets = mTargets.get(clazz);
// if (targets == null) {
// mTargets.putIfAbsent(clazz, new CopyOnWriteArrayList<Object>());
// targets = mTargets.get(clazz);
// }
// targets.add(target);
// }
// }
// }
//
// public void unregister(Object target) {
// synchronized (mTargets) {
// for (Class<?> clazz = target.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
// CopyOnWriteArrayList<Object> targets = mTargets.get(clazz);
// if (targets == null) {
// return;
// }
// int size = targets.size();
// for (int i = 0; i < size; ++i) {
// if (targets.get(i) == target) {
// targets.remove(i);
// --i;
// --size;
// }
// }
// if (targets.isEmpty()) {
// mTargets.remove(clazz);
// }
// }
// }
// }
//
// public boolean isRegistered(Object target) {
// Class<?> clazz = target.getClass();
// CopyOnWriteArrayList<Object> targets = mTargets.get(clazz);
// return targets != null && targets.contains(target);
// }
//
// public CopyOnWriteArrayList<Object> getTargets(Class<?> clazz) {
// CopyOnWriteArrayList<Object> targets = mTargets.get(clazz);
// return targets == null ? new CopyOnWriteArrayList<Object>() : targets;
// }
// }
| import java.util.concurrent.CopyOnWriteArrayList;
import xiaofei.library.shelly.function.Function2;
import xiaofei.library.shelly.util.TargetCenter; | /**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.operator;
/**
* Created by Xiaofei on 16/6/23.
*/
public class MapOperator2<T, R, U> implements CopyOnWriteArrayListFunction1<T, R> {
private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
private Class<U> clazz;
| // Path: shelly/src/main/java/xiaofei/library/shelly/function/Function2.java
// public interface Function2<T, R, S> extends Function {
// S call(T input1, R input2);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/util/TargetCenter.java
// public class TargetCenter {
//
// private static volatile TargetCenter sInstance = null;
//
// private final ConcurrentHashMap<Class<?>, CopyOnWriteArrayList<Object>> mTargets;
//
// private TargetCenter() {
// mTargets = new ConcurrentHashMap<Class<?>, CopyOnWriteArrayList<Object>>();
// }
//
// public static TargetCenter getInstance() {
// if (sInstance == null) {
// synchronized (TargetCenter.class) {
// if (sInstance == null) {
// sInstance = new TargetCenter();
// }
// }
// }
// return sInstance;
// }
//
// public void register(Object target) {
// synchronized (mTargets) {
// for (Class<?> clazz = target.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
// CopyOnWriteArrayList<Object> targets = mTargets.get(clazz);
// if (targets == null) {
// mTargets.putIfAbsent(clazz, new CopyOnWriteArrayList<Object>());
// targets = mTargets.get(clazz);
// }
// targets.add(target);
// }
// }
// }
//
// public void unregister(Object target) {
// synchronized (mTargets) {
// for (Class<?> clazz = target.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
// CopyOnWriteArrayList<Object> targets = mTargets.get(clazz);
// if (targets == null) {
// return;
// }
// int size = targets.size();
// for (int i = 0; i < size; ++i) {
// if (targets.get(i) == target) {
// targets.remove(i);
// --i;
// --size;
// }
// }
// if (targets.isEmpty()) {
// mTargets.remove(clazz);
// }
// }
// }
// }
//
// public boolean isRegistered(Object target) {
// Class<?> clazz = target.getClass();
// CopyOnWriteArrayList<Object> targets = mTargets.get(clazz);
// return targets != null && targets.contains(target);
// }
//
// public CopyOnWriteArrayList<Object> getTargets(Class<?> clazz) {
// CopyOnWriteArrayList<Object> targets = mTargets.get(clazz);
// return targets == null ? new CopyOnWriteArrayList<Object>() : targets;
// }
// }
// Path: shelly/src/main/java/xiaofei/library/shelly/operator/MapOperator2.java
import java.util.concurrent.CopyOnWriteArrayList;
import xiaofei.library.shelly.function.Function2;
import xiaofei.library.shelly.util.TargetCenter;
/**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.operator;
/**
* Created by Xiaofei on 16/6/23.
*/
public class MapOperator2<T, R, U> implements CopyOnWriteArrayListFunction1<T, R> {
private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
private Class<U> clazz;
| private Function2<? super U, ? super T, ? extends R> map; |
Xiaofei-it/Shelly | shelly/src/main/java/xiaofei/library/shelly/util/TaskFunction.java | // Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function2.java
// public interface Function2<T, R, S> extends Function {
// S call(T input1, R input2);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/task/Task.java
// public abstract class Task<T, R, S> {
//
// private TaskListener<R, S> mListener;
//
// public Task() {
// }
//
// public void setListener(TaskListener<R, S> listener) {
// mListener = listener;
// }
//
// protected abstract void onExecute(T input);
//
// public final void execute(T input) {
// onExecute(input);
// }
//
// public final void notifySuccess(R result) {
// if (mListener != null) {
// mListener.onSuccess(result);
// }
// }
//
// public final void notifyFailure(S error) {
// if (mListener != null) {
// mListener.onFailure(error);
// }
// }
//
// public interface TaskListener<R, S> {
// void onSuccess(R result);
// void onFailure(S error);
// }
//
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/tuple/Triple.java
// public class Triple<T1, T2, T3> {
// public final T1 first;
// public final T2 second;
// public final T3 third;
//
// @Deprecated
// public Triple(T1 first, T2 second, T3 third) {
// this.first = first;
// this.second = second;
// this.third = third;
// }
//
// public static <T1, T2, T3> Triple<T1, T2, T3> create(T1 first, T2 second, T3 third) {
// return new Triple<T1, T2, T3>(first, second, third);
// }
// }
| import xiaofei.library.concurrentutils.ObjectCanary;
import xiaofei.library.concurrentutils.util.Action;
import xiaofei.library.concurrentutils.util.Condition;
import xiaofei.library.concurrentutils.util.Function;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.Function2;
import xiaofei.library.shelly.task.Task;
import xiaofei.library.shelly.tuple.Triple; | /**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.util;
/**
* Created by Xiaofei on 16/6/30.
*/
public class TaskFunction<T, R1, R2, U1, U2>
implements Function1<T, Triple<Boolean, R2, U2>>, Task.TaskListener<R1, U1> {
private Task<T, R1, U1> mTask;
| // Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function2.java
// public interface Function2<T, R, S> extends Function {
// S call(T input1, R input2);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/task/Task.java
// public abstract class Task<T, R, S> {
//
// private TaskListener<R, S> mListener;
//
// public Task() {
// }
//
// public void setListener(TaskListener<R, S> listener) {
// mListener = listener;
// }
//
// protected abstract void onExecute(T input);
//
// public final void execute(T input) {
// onExecute(input);
// }
//
// public final void notifySuccess(R result) {
// if (mListener != null) {
// mListener.onSuccess(result);
// }
// }
//
// public final void notifyFailure(S error) {
// if (mListener != null) {
// mListener.onFailure(error);
// }
// }
//
// public interface TaskListener<R, S> {
// void onSuccess(R result);
// void onFailure(S error);
// }
//
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/tuple/Triple.java
// public class Triple<T1, T2, T3> {
// public final T1 first;
// public final T2 second;
// public final T3 third;
//
// @Deprecated
// public Triple(T1 first, T2 second, T3 third) {
// this.first = first;
// this.second = second;
// this.third = third;
// }
//
// public static <T1, T2, T3> Triple<T1, T2, T3> create(T1 first, T2 second, T3 third) {
// return new Triple<T1, T2, T3>(first, second, third);
// }
// }
// Path: shelly/src/main/java/xiaofei/library/shelly/util/TaskFunction.java
import xiaofei.library.concurrentutils.ObjectCanary;
import xiaofei.library.concurrentutils.util.Action;
import xiaofei.library.concurrentutils.util.Condition;
import xiaofei.library.concurrentutils.util.Function;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.Function2;
import xiaofei.library.shelly.task.Task;
import xiaofei.library.shelly.tuple.Triple;
/**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.util;
/**
* Created by Xiaofei on 16/6/30.
*/
public class TaskFunction<T, R1, R2, U1, U2>
implements Function1<T, Triple<Boolean, R2, U2>>, Task.TaskListener<R1, U1> {
private Task<T, R1, U1> mTask;
| private Function2<T, R1, R2> mFunc1; |
Xiaofei-it/Shelly | shelly/src/test/java/xiaofei/library/shelly/domino/Test01.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
| import org.junit.Test;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction1; | /**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/5/30.
*/
public class Test01 {
private static class A {
private int i;
A(int i) {
this.i = i;
}
public void g(String s) {
System.out.println("A " + i + " g " + s);
}
}
private static class B {
}
@Test
public void case01() { | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
// Path: shelly/src/test/java/xiaofei/library/shelly/domino/Test01.java
import org.junit.Test;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction1;
/**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/5/30.
*/
public class Test01 {
private static class A {
private int i;
A(int i) {
this.i = i;
}
public void g(String s) {
System.out.println("A " + i + " g " + s);
}
}
private static class B {
}
@Test
public void case01() { | Shelly.register(new A(1)); |
Xiaofei-it/Shelly | shelly/src/test/java/xiaofei/library/shelly/domino/Test01.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
| import org.junit.Test;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction1; | /**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/5/30.
*/
public class Test01 {
private static class A {
private int i;
A(int i) {
this.i = i;
}
public void g(String s) {
System.out.println("A " + i + " g " + s);
}
}
private static class B {
}
@Test
public void case01() {
Shelly.register(new A(1));
Shelly.register(new A(2));
Shelly.<String>createDomino("case01") | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
// Path: shelly/src/test/java/xiaofei/library/shelly/domino/Test01.java
import org.junit.Test;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction1;
/**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/5/30.
*/
public class Test01 {
private static class A {
private int i;
A(int i) {
this.i = i;
}
public void g(String s) {
System.out.println("A " + i + " g " + s);
}
}
private static class B {
}
@Test
public void case01() {
Shelly.register(new A(1));
Shelly.register(new A(2));
Shelly.<String>createDomino("case01") | .perform(new Action0() { |
Xiaofei-it/Shelly | shelly/src/test/java/xiaofei/library/shelly/domino/Test01.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
| import org.junit.Test;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction1; | /**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/5/30.
*/
public class Test01 {
private static class A {
private int i;
A(int i) {
this.i = i;
}
public void g(String s) {
System.out.println("A " + i + " g " + s);
}
}
private static class B {
}
@Test
public void case01() {
Shelly.register(new A(1));
Shelly.register(new A(2));
Shelly.<String>createDomino("case01")
.perform(new Action0() {
@Override
public void call() {
System.out.println("Target action0");
}
}) | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
// Path: shelly/src/test/java/xiaofei/library/shelly/domino/Test01.java
import org.junit.Test;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction1;
/**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/5/30.
*/
public class Test01 {
private static class A {
private int i;
A(int i) {
this.i = i;
}
public void g(String s) {
System.out.println("A " + i + " g " + s);
}
}
private static class B {
}
@Test
public void case01() {
Shelly.register(new A(1));
Shelly.register(new A(2));
Shelly.<String>createDomino("case01")
.perform(new Action0() {
@Override
public void call() {
System.out.println("Target action0");
}
}) | .perform(new Action1<String>() { |
Xiaofei-it/Shelly | shelly/src/test/java/xiaofei/library/shelly/domino/Test01.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
| import org.junit.Test;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction1; | /**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/5/30.
*/
public class Test01 {
private static class A {
private int i;
A(int i) {
this.i = i;
}
public void g(String s) {
System.out.println("A " + i + " g " + s);
}
}
private static class B {
}
@Test
public void case01() {
Shelly.register(new A(1));
Shelly.register(new A(2));
Shelly.<String>createDomino("case01")
.perform(new Action0() {
@Override
public void call() {
System.out.println("Target action0");
}
})
.perform(new Action1<String>() {
@Override
public void call(String input) {
System.out.println("Target action1 " + input);
}
}) | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
// Path: shelly/src/test/java/xiaofei/library/shelly/domino/Test01.java
import org.junit.Test;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction1;
/**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/5/30.
*/
public class Test01 {
private static class A {
private int i;
A(int i) {
this.i = i;
}
public void g(String s) {
System.out.println("A " + i + " g " + s);
}
}
private static class B {
}
@Test
public void case01() {
Shelly.register(new A(1));
Shelly.register(new A(2));
Shelly.<String>createDomino("case01")
.perform(new Action0() {
@Override
public void call() {
System.out.println("Target action0");
}
})
.perform(new Action1<String>() {
@Override
public void call(String input) {
System.out.println("Target action1 " + input);
}
}) | .perform(A.class, new TargetAction1<A, String>() { |
Xiaofei-it/Shelly | shelly/src/test/java/xiaofei/library/shelly/domino/Test01.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
| import org.junit.Test;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction1; | public void g(String s) {
System.out.println("A " + i + " g " + s);
}
}
private static class B {
}
@Test
public void case01() {
Shelly.register(new A(1));
Shelly.register(new A(2));
Shelly.<String>createDomino("case01")
.perform(new Action0() {
@Override
public void call() {
System.out.println("Target action0");
}
})
.perform(new Action1<String>() {
@Override
public void call(String input) {
System.out.println("Target action1 " + input);
}
})
.perform(A.class, new TargetAction1<A, String>() {
@Override
public void call(A a, String input) {
a.g(input);
}
}) | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
// Path: shelly/src/test/java/xiaofei/library/shelly/domino/Test01.java
import org.junit.Test;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction1;
public void g(String s) {
System.out.println("A " + i + " g " + s);
}
}
private static class B {
}
@Test
public void case01() {
Shelly.register(new A(1));
Shelly.register(new A(2));
Shelly.<String>createDomino("case01")
.perform(new Action0() {
@Override
public void call() {
System.out.println("Target action0");
}
})
.perform(new Action1<String>() {
@Override
public void call(String input) {
System.out.println("Target action1 " + input);
}
})
.perform(A.class, new TargetAction1<A, String>() {
@Override
public void call(A a, String input) {
a.g(input);
}
}) | .map(new Function1<String, String>() { |
Xiaofei-it/Shelly | shelly/src/test/java/xiaofei/library/shelly/domino/Test05.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function2.java
// public interface Function2<T, R, S> extends Function {
// S call(T input1, R input2);
// }
| import org.junit.Test;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.Function2; | /**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/20.
*/
public class Test05 {
@Test
public void testMerge() { | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function2.java
// public interface Function2<T, R, S> extends Function {
// S call(T input1, R input2);
// }
// Path: shelly/src/test/java/xiaofei/library/shelly/domino/Test05.java
import org.junit.Test;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.Function2;
/**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/20.
*/
public class Test05 {
@Test
public void testMerge() { | Shelly.<String>createDomino(1) |
Xiaofei-it/Shelly | shelly/src/test/java/xiaofei/library/shelly/domino/Test05.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function2.java
// public interface Function2<T, R, S> extends Function {
// S call(T input1, R input2);
// }
| import org.junit.Test;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.Function2; | /**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/20.
*/
public class Test05 {
@Test
public void testMerge() {
Shelly.<String>createDomino(1)
.newThread() | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function2.java
// public interface Function2<T, R, S> extends Function {
// S call(T input1, R input2);
// }
// Path: shelly/src/test/java/xiaofei/library/shelly/domino/Test05.java
import org.junit.Test;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.Function2;
/**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/20.
*/
public class Test05 {
@Test
public void testMerge() {
Shelly.<String>createDomino(1)
.newThread() | .perform(new Action1<String>() { |
Xiaofei-it/Shelly | shelly/src/test/java/xiaofei/library/shelly/domino/Test05.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function2.java
// public interface Function2<T, R, S> extends Function {
// S call(T input1, R input2);
// }
| import org.junit.Test;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.Function2; | /**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/20.
*/
public class Test05 {
@Test
public void testMerge() {
Shelly.<String>createDomino(1)
.newThread()
.perform(new Action1<String>() {
@Override
public void call(String input) {
System.out.println("1: " + Thread.currentThread().getName() + " " + input);
}
}) | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function2.java
// public interface Function2<T, R, S> extends Function {
// S call(T input1, R input2);
// }
// Path: shelly/src/test/java/xiaofei/library/shelly/domino/Test05.java
import org.junit.Test;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.Function2;
/**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/20.
*/
public class Test05 {
@Test
public void testMerge() {
Shelly.<String>createDomino(1)
.newThread()
.perform(new Action1<String>() {
@Override
public void call(String input) {
System.out.println("1: " + Thread.currentThread().getName() + " " + input);
}
}) | .map(new Function1<String, String>() { |
Xiaofei-it/Shelly | shelly/src/test/java/xiaofei/library/shelly/domino/Test05.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function2.java
// public interface Function2<T, R, S> extends Function {
// S call(T input1, R input2);
// }
| import org.junit.Test;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.Function2; | } catch (InterruptedException e) {
}
return input.charAt(0) - 'A';
}
})
.commit();
Shelly.<String>createDomino(6)
.newThread()
.perform(new Action1<String>() {
@Override
public void call(String input) {
System.out.println("2: " + Thread.currentThread().getName() + " " + input);
}
})
.map(new Function1<String, Boolean>() {
@Override
public Boolean call(String input) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
return input.equals("A");
}
})
.commit();
Shelly.<String>createDomino(7)
.combine(Shelly.<String, Integer>getDominoByLabel(5),
Shelly.<String, Boolean>getDominoByLabel(6), | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function2.java
// public interface Function2<T, R, S> extends Function {
// S call(T input1, R input2);
// }
// Path: shelly/src/test/java/xiaofei/library/shelly/domino/Test05.java
import org.junit.Test;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.Function2;
} catch (InterruptedException e) {
}
return input.charAt(0) - 'A';
}
})
.commit();
Shelly.<String>createDomino(6)
.newThread()
.perform(new Action1<String>() {
@Override
public void call(String input) {
System.out.println("2: " + Thread.currentThread().getName() + " " + input);
}
})
.map(new Function1<String, Boolean>() {
@Override
public Boolean call(String input) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
return input.equals("A");
}
})
.commit();
Shelly.<String>createDomino(7)
.combine(Shelly.<String, Integer>getDominoByLabel(5),
Shelly.<String, Boolean>getDominoByLabel(6), | new Function2<Integer, Boolean, String>() { |
Xiaofei-it/Shelly | shelly/src/main/java/xiaofei/library/shelly/domino/TaskDomino.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/operator/ListIdentityOperator.java
// public class ListIdentityOperator<T> extends IdentityOperator<List<T>> {
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/tuple/Triple.java
// public class Triple<T1, T2, T3> {
// public final T1 first;
// public final T2 second;
// public final T3 third;
//
// @Deprecated
// public Triple(T1 first, T2 second, T3 third) {
// this.first = first;
// this.second = second;
// this.third = third;
// }
//
// public static <T1, T2, T3> Triple<T1, T2, T3> create(T1 first, T2 second, T3 third) {
// return new Triple<T1, T2, T3>(first, second, third);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/util/Tile.java
// public interface Tile<T, R> extends Function1<List<T>, Player<R>> {
//
// }
| import java.util.ArrayList;
import java.util.List;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.operator.ListIdentityOperator;
import xiaofei.library.shelly.tuple.Triple;
import xiaofei.library.shelly.util.Tile; | /**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/21.
*/
public class TaskDomino<T, R, U> extends Domino<T, Triple<Boolean, R, U>> {
protected TaskDomino(Object label, Tile<T, Triple<Boolean, R, U>> tile) {
super(label, tile);
}
private TaskDomino(Domino<T, Triple<Boolean, R, U>> domino) {
this(domino.getLabel(), domino.getPlayer());
}
public TaskDomino<T, R, U> onSuccess(final Domino<R, ?> domino) {
return new TaskDomino<T, R, U>( | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/operator/ListIdentityOperator.java
// public class ListIdentityOperator<T> extends IdentityOperator<List<T>> {
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/tuple/Triple.java
// public class Triple<T1, T2, T3> {
// public final T1 first;
// public final T2 second;
// public final T3 third;
//
// @Deprecated
// public Triple(T1 first, T2 second, T3 third) {
// this.first = first;
// this.second = second;
// this.third = third;
// }
//
// public static <T1, T2, T3> Triple<T1, T2, T3> create(T1 first, T2 second, T3 third) {
// return new Triple<T1, T2, T3>(first, second, third);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/util/Tile.java
// public interface Tile<T, R> extends Function1<List<T>, Player<R>> {
//
// }
// Path: shelly/src/main/java/xiaofei/library/shelly/domino/TaskDomino.java
import java.util.ArrayList;
import java.util.List;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.operator.ListIdentityOperator;
import xiaofei.library.shelly.tuple.Triple;
import xiaofei.library.shelly.util.Tile;
/**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/21.
*/
public class TaskDomino<T, R, U> extends Domino<T, Triple<Boolean, R, U>> {
protected TaskDomino(Object label, Tile<T, Triple<Boolean, R, U>> tile) {
super(label, tile);
}
private TaskDomino(Domino<T, Triple<Boolean, R, U>> domino) {
this(domino.getLabel(), domino.getPlayer());
}
public TaskDomino<T, R, U> onSuccess(final Domino<R, ?> domino) {
return new TaskDomino<T, R, U>( | perform(Shelly.<Triple<Boolean, R, U>>createAnonymousDomino() |
Xiaofei-it/Shelly | shelly/src/main/java/xiaofei/library/shelly/domino/TaskDomino.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/operator/ListIdentityOperator.java
// public class ListIdentityOperator<T> extends IdentityOperator<List<T>> {
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/tuple/Triple.java
// public class Triple<T1, T2, T3> {
// public final T1 first;
// public final T2 second;
// public final T3 third;
//
// @Deprecated
// public Triple(T1 first, T2 second, T3 third) {
// this.first = first;
// this.second = second;
// this.third = third;
// }
//
// public static <T1, T2, T3> Triple<T1, T2, T3> create(T1 first, T2 second, T3 third) {
// return new Triple<T1, T2, T3>(first, second, third);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/util/Tile.java
// public interface Tile<T, R> extends Function1<List<T>, Player<R>> {
//
// }
| import java.util.ArrayList;
import java.util.List;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.operator.ListIdentityOperator;
import xiaofei.library.shelly.tuple.Triple;
import xiaofei.library.shelly.util.Tile; | /**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/21.
*/
public class TaskDomino<T, R, U> extends Domino<T, Triple<Boolean, R, U>> {
protected TaskDomino(Object label, Tile<T, Triple<Boolean, R, U>> tile) {
super(label, tile);
}
private TaskDomino(Domino<T, Triple<Boolean, R, U>> domino) {
this(domino.getLabel(), domino.getPlayer());
}
public TaskDomino<T, R, U> onSuccess(final Domino<R, ?> domino) {
return new TaskDomino<T, R, U>(
perform(Shelly.<Triple<Boolean, R, U>>createAnonymousDomino() | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/operator/ListIdentityOperator.java
// public class ListIdentityOperator<T> extends IdentityOperator<List<T>> {
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/tuple/Triple.java
// public class Triple<T1, T2, T3> {
// public final T1 first;
// public final T2 second;
// public final T3 third;
//
// @Deprecated
// public Triple(T1 first, T2 second, T3 third) {
// this.first = first;
// this.second = second;
// this.third = third;
// }
//
// public static <T1, T2, T3> Triple<T1, T2, T3> create(T1 first, T2 second, T3 third) {
// return new Triple<T1, T2, T3>(first, second, third);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/util/Tile.java
// public interface Tile<T, R> extends Function1<List<T>, Player<R>> {
//
// }
// Path: shelly/src/main/java/xiaofei/library/shelly/domino/TaskDomino.java
import java.util.ArrayList;
import java.util.List;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.operator.ListIdentityOperator;
import xiaofei.library.shelly.tuple.Triple;
import xiaofei.library.shelly.util.Tile;
/**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/21.
*/
public class TaskDomino<T, R, U> extends Domino<T, Triple<Boolean, R, U>> {
protected TaskDomino(Object label, Tile<T, Triple<Boolean, R, U>> tile) {
super(label, tile);
}
private TaskDomino(Domino<T, Triple<Boolean, R, U>> domino) {
this(domino.getLabel(), domino.getPlayer());
}
public TaskDomino<T, R, U> onSuccess(final Domino<R, ?> domino) {
return new TaskDomino<T, R, U>(
perform(Shelly.<Triple<Boolean, R, U>>createAnonymousDomino() | .reduce(new Function1<List<Triple<Boolean, R, U>>, List<R>>() { |
Xiaofei-it/Shelly | shelly/src/main/java/xiaofei/library/shelly/domino/TaskDomino.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/operator/ListIdentityOperator.java
// public class ListIdentityOperator<T> extends IdentityOperator<List<T>> {
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/tuple/Triple.java
// public class Triple<T1, T2, T3> {
// public final T1 first;
// public final T2 second;
// public final T3 third;
//
// @Deprecated
// public Triple(T1 first, T2 second, T3 third) {
// this.first = first;
// this.second = second;
// this.third = third;
// }
//
// public static <T1, T2, T3> Triple<T1, T2, T3> create(T1 first, T2 second, T3 third) {
// return new Triple<T1, T2, T3>(first, second, third);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/util/Tile.java
// public interface Tile<T, R> extends Function1<List<T>, Player<R>> {
//
// }
| import java.util.ArrayList;
import java.util.List;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.operator.ListIdentityOperator;
import xiaofei.library.shelly.tuple.Triple;
import xiaofei.library.shelly.util.Tile; | /**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/21.
*/
public class TaskDomino<T, R, U> extends Domino<T, Triple<Boolean, R, U>> {
protected TaskDomino(Object label, Tile<T, Triple<Boolean, R, U>> tile) {
super(label, tile);
}
private TaskDomino(Domino<T, Triple<Boolean, R, U>> domino) {
this(domino.getLabel(), domino.getPlayer());
}
public TaskDomino<T, R, U> onSuccess(final Domino<R, ?> domino) {
return new TaskDomino<T, R, U>(
perform(Shelly.<Triple<Boolean, R, U>>createAnonymousDomino()
.reduce(new Function1<List<Triple<Boolean, R, U>>, List<R>>() {
@Override
public List<R> call(List<Triple<Boolean, R, U>> input) {
List<R> result= new ArrayList<R>();
for (Triple<Boolean, R, U> triple : input) {
if (triple.first) {
result.add(triple.second);
}
}
return result;
}
}) | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/operator/ListIdentityOperator.java
// public class ListIdentityOperator<T> extends IdentityOperator<List<T>> {
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/tuple/Triple.java
// public class Triple<T1, T2, T3> {
// public final T1 first;
// public final T2 second;
// public final T3 third;
//
// @Deprecated
// public Triple(T1 first, T2 second, T3 third) {
// this.first = first;
// this.second = second;
// this.third = third;
// }
//
// public static <T1, T2, T3> Triple<T1, T2, T3> create(T1 first, T2 second, T3 third) {
// return new Triple<T1, T2, T3>(first, second, third);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/util/Tile.java
// public interface Tile<T, R> extends Function1<List<T>, Player<R>> {
//
// }
// Path: shelly/src/main/java/xiaofei/library/shelly/domino/TaskDomino.java
import java.util.ArrayList;
import java.util.List;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.operator.ListIdentityOperator;
import xiaofei.library.shelly.tuple.Triple;
import xiaofei.library.shelly.util.Tile;
/**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/21.
*/
public class TaskDomino<T, R, U> extends Domino<T, Triple<Boolean, R, U>> {
protected TaskDomino(Object label, Tile<T, Triple<Boolean, R, U>> tile) {
super(label, tile);
}
private TaskDomino(Domino<T, Triple<Boolean, R, U>> domino) {
this(domino.getLabel(), domino.getPlayer());
}
public TaskDomino<T, R, U> onSuccess(final Domino<R, ?> domino) {
return new TaskDomino<T, R, U>(
perform(Shelly.<Triple<Boolean, R, U>>createAnonymousDomino()
.reduce(new Function1<List<Triple<Boolean, R, U>>, List<R>>() {
@Override
public List<R> call(List<Triple<Boolean, R, U>> input) {
List<R> result= new ArrayList<R>();
for (Triple<Boolean, R, U> triple : input) {
if (triple.first) {
result.add(triple.second);
}
}
return result;
}
}) | .flatMap(new ListIdentityOperator<R>()) |
Xiaofei-it/Shelly | shelly/src/main/java/xiaofei/library/shelly/domino/TaskDomino.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/operator/ListIdentityOperator.java
// public class ListIdentityOperator<T> extends IdentityOperator<List<T>> {
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/tuple/Triple.java
// public class Triple<T1, T2, T3> {
// public final T1 first;
// public final T2 second;
// public final T3 third;
//
// @Deprecated
// public Triple(T1 first, T2 second, T3 third) {
// this.first = first;
// this.second = second;
// this.third = third;
// }
//
// public static <T1, T2, T3> Triple<T1, T2, T3> create(T1 first, T2 second, T3 third) {
// return new Triple<T1, T2, T3>(first, second, third);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/util/Tile.java
// public interface Tile<T, R> extends Function1<List<T>, Player<R>> {
//
// }
| import java.util.ArrayList;
import java.util.List;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.operator.ListIdentityOperator;
import xiaofei.library.shelly.tuple.Triple;
import xiaofei.library.shelly.util.Tile; | /**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/21.
*/
public class TaskDomino<T, R, U> extends Domino<T, Triple<Boolean, R, U>> {
protected TaskDomino(Object label, Tile<T, Triple<Boolean, R, U>> tile) {
super(label, tile);
}
private TaskDomino(Domino<T, Triple<Boolean, R, U>> domino) {
this(domino.getLabel(), domino.getPlayer());
}
public TaskDomino<T, R, U> onSuccess(final Domino<R, ?> domino) {
return new TaskDomino<T, R, U>(
perform(Shelly.<Triple<Boolean, R, U>>createAnonymousDomino()
.reduce(new Function1<List<Triple<Boolean, R, U>>, List<R>>() {
@Override
public List<R> call(List<Triple<Boolean, R, U>> input) {
List<R> result= new ArrayList<R>();
for (Triple<Boolean, R, U> triple : input) {
if (triple.first) {
result.add(triple.second);
}
}
return result;
}
})
.flatMap(new ListIdentityOperator<R>())
.perform(domino)
));
}
| // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/operator/ListIdentityOperator.java
// public class ListIdentityOperator<T> extends IdentityOperator<List<T>> {
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/tuple/Triple.java
// public class Triple<T1, T2, T3> {
// public final T1 first;
// public final T2 second;
// public final T3 third;
//
// @Deprecated
// public Triple(T1 first, T2 second, T3 third) {
// this.first = first;
// this.second = second;
// this.third = third;
// }
//
// public static <T1, T2, T3> Triple<T1, T2, T3> create(T1 first, T2 second, T3 third) {
// return new Triple<T1, T2, T3>(first, second, third);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/util/Tile.java
// public interface Tile<T, R> extends Function1<List<T>, Player<R>> {
//
// }
// Path: shelly/src/main/java/xiaofei/library/shelly/domino/TaskDomino.java
import java.util.ArrayList;
import java.util.List;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.operator.ListIdentityOperator;
import xiaofei.library.shelly.tuple.Triple;
import xiaofei.library.shelly.util.Tile;
/**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/21.
*/
public class TaskDomino<T, R, U> extends Domino<T, Triple<Boolean, R, U>> {
protected TaskDomino(Object label, Tile<T, Triple<Boolean, R, U>> tile) {
super(label, tile);
}
private TaskDomino(Domino<T, Triple<Boolean, R, U>> domino) {
this(domino.getLabel(), domino.getPlayer());
}
public TaskDomino<T, R, U> onSuccess(final Domino<R, ?> domino) {
return new TaskDomino<T, R, U>(
perform(Shelly.<Triple<Boolean, R, U>>createAnonymousDomino()
.reduce(new Function1<List<Triple<Boolean, R, U>>, List<R>>() {
@Override
public List<R> call(List<Triple<Boolean, R, U>> input) {
List<R> result= new ArrayList<R>();
for (Triple<Boolean, R, U> triple : input) {
if (triple.first) {
result.add(triple.second);
}
}
return result;
}
})
.flatMap(new ListIdentityOperator<R>())
.perform(domino)
));
}
| public <S> TaskDomino<T, R, U> onSuccess(final Class<? extends S> target, final TargetAction0<? super S> targetAction0) { |
Xiaofei-it/Shelly | shelly/src/main/java/xiaofei/library/shelly/domino/TaskDomino.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/operator/ListIdentityOperator.java
// public class ListIdentityOperator<T> extends IdentityOperator<List<T>> {
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/tuple/Triple.java
// public class Triple<T1, T2, T3> {
// public final T1 first;
// public final T2 second;
// public final T3 third;
//
// @Deprecated
// public Triple(T1 first, T2 second, T3 third) {
// this.first = first;
// this.second = second;
// this.third = third;
// }
//
// public static <T1, T2, T3> Triple<T1, T2, T3> create(T1 first, T2 second, T3 third) {
// return new Triple<T1, T2, T3>(first, second, third);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/util/Tile.java
// public interface Tile<T, R> extends Function1<List<T>, Player<R>> {
//
// }
| import java.util.ArrayList;
import java.util.List;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.operator.ListIdentityOperator;
import xiaofei.library.shelly.tuple.Triple;
import xiaofei.library.shelly.util.Tile; | reduce(new ListIdentityOperator<Triple<Boolean, R, U>>())
.perform(target, new TargetAction1<S, List<Triple<Boolean, R, U>>>() {
@Override
public void call(S s, List<Triple<Boolean, R, U>> input) {
boolean success = false;
for (Triple<Boolean, R, U> triple : input) {
if (triple.first) {
success = true;
break;
}
}
if (success) {
targetAction0.call(s);
}
}
})
.flatMap(new ListIdentityOperator<Triple<Boolean, R, U>>()));
}
public <S> TaskDomino<T, R, U> onSuccess(final Class<? extends S> target, final TargetAction1<? super S, ? super R> targetAction1) {
return new TaskDomino<T, R, U>(perform(target, new TargetAction1<S, Triple<Boolean, R, U>>() {
@Override
public void call(S s, Triple<Boolean, R, U> input) {
if (input.first) {
targetAction1.call(s, input.second);
}
}
}));
}
| // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/operator/ListIdentityOperator.java
// public class ListIdentityOperator<T> extends IdentityOperator<List<T>> {
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/tuple/Triple.java
// public class Triple<T1, T2, T3> {
// public final T1 first;
// public final T2 second;
// public final T3 third;
//
// @Deprecated
// public Triple(T1 first, T2 second, T3 third) {
// this.first = first;
// this.second = second;
// this.third = third;
// }
//
// public static <T1, T2, T3> Triple<T1, T2, T3> create(T1 first, T2 second, T3 third) {
// return new Triple<T1, T2, T3>(first, second, third);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/util/Tile.java
// public interface Tile<T, R> extends Function1<List<T>, Player<R>> {
//
// }
// Path: shelly/src/main/java/xiaofei/library/shelly/domino/TaskDomino.java
import java.util.ArrayList;
import java.util.List;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.operator.ListIdentityOperator;
import xiaofei.library.shelly.tuple.Triple;
import xiaofei.library.shelly.util.Tile;
reduce(new ListIdentityOperator<Triple<Boolean, R, U>>())
.perform(target, new TargetAction1<S, List<Triple<Boolean, R, U>>>() {
@Override
public void call(S s, List<Triple<Boolean, R, U>> input) {
boolean success = false;
for (Triple<Boolean, R, U> triple : input) {
if (triple.first) {
success = true;
break;
}
}
if (success) {
targetAction0.call(s);
}
}
})
.flatMap(new ListIdentityOperator<Triple<Boolean, R, U>>()));
}
public <S> TaskDomino<T, R, U> onSuccess(final Class<? extends S> target, final TargetAction1<? super S, ? super R> targetAction1) {
return new TaskDomino<T, R, U>(perform(target, new TargetAction1<S, Triple<Boolean, R, U>>() {
@Override
public void call(S s, Triple<Boolean, R, U> input) {
if (input.first) {
targetAction1.call(s, input.second);
}
}
}));
}
| public TaskDomino<T, R, U> onSuccess(final Action0 action0) { |
Xiaofei-it/Shelly | shelly/src/main/java/xiaofei/library/shelly/domino/TaskDomino.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/operator/ListIdentityOperator.java
// public class ListIdentityOperator<T> extends IdentityOperator<List<T>> {
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/tuple/Triple.java
// public class Triple<T1, T2, T3> {
// public final T1 first;
// public final T2 second;
// public final T3 third;
//
// @Deprecated
// public Triple(T1 first, T2 second, T3 third) {
// this.first = first;
// this.second = second;
// this.third = third;
// }
//
// public static <T1, T2, T3> Triple<T1, T2, T3> create(T1 first, T2 second, T3 third) {
// return new Triple<T1, T2, T3>(first, second, third);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/util/Tile.java
// public interface Tile<T, R> extends Function1<List<T>, Player<R>> {
//
// }
| import java.util.ArrayList;
import java.util.List;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.operator.ListIdentityOperator;
import xiaofei.library.shelly.tuple.Triple;
import xiaofei.library.shelly.util.Tile; | public void call(S s, List<Triple<Boolean, R, U>> input) {
boolean success = false;
for (Triple<Boolean, R, U> triple : input) {
if (triple.first) {
success = true;
break;
}
}
if (success) {
targetAction0.call(s);
}
}
})
.flatMap(new ListIdentityOperator<Triple<Boolean, R, U>>()));
}
public <S> TaskDomino<T, R, U> onSuccess(final Class<? extends S> target, final TargetAction1<? super S, ? super R> targetAction1) {
return new TaskDomino<T, R, U>(perform(target, new TargetAction1<S, Triple<Boolean, R, U>>() {
@Override
public void call(S s, Triple<Boolean, R, U> input) {
if (input.first) {
targetAction1.call(s, input.second);
}
}
}));
}
public TaskDomino<T, R, U> onSuccess(final Action0 action0) {
return new TaskDomino<T, R, U>(
reduce(new ListIdentityOperator<Triple<Boolean, R, U>>()) | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/operator/ListIdentityOperator.java
// public class ListIdentityOperator<T> extends IdentityOperator<List<T>> {
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/tuple/Triple.java
// public class Triple<T1, T2, T3> {
// public final T1 first;
// public final T2 second;
// public final T3 third;
//
// @Deprecated
// public Triple(T1 first, T2 second, T3 third) {
// this.first = first;
// this.second = second;
// this.third = third;
// }
//
// public static <T1, T2, T3> Triple<T1, T2, T3> create(T1 first, T2 second, T3 third) {
// return new Triple<T1, T2, T3>(first, second, third);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/util/Tile.java
// public interface Tile<T, R> extends Function1<List<T>, Player<R>> {
//
// }
// Path: shelly/src/main/java/xiaofei/library/shelly/domino/TaskDomino.java
import java.util.ArrayList;
import java.util.List;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.operator.ListIdentityOperator;
import xiaofei.library.shelly.tuple.Triple;
import xiaofei.library.shelly.util.Tile;
public void call(S s, List<Triple<Boolean, R, U>> input) {
boolean success = false;
for (Triple<Boolean, R, U> triple : input) {
if (triple.first) {
success = true;
break;
}
}
if (success) {
targetAction0.call(s);
}
}
})
.flatMap(new ListIdentityOperator<Triple<Boolean, R, U>>()));
}
public <S> TaskDomino<T, R, U> onSuccess(final Class<? extends S> target, final TargetAction1<? super S, ? super R> targetAction1) {
return new TaskDomino<T, R, U>(perform(target, new TargetAction1<S, Triple<Boolean, R, U>>() {
@Override
public void call(S s, Triple<Boolean, R, U> input) {
if (input.first) {
targetAction1.call(s, input.second);
}
}
}));
}
public TaskDomino<T, R, U> onSuccess(final Action0 action0) {
return new TaskDomino<T, R, U>(
reduce(new ListIdentityOperator<Triple<Boolean, R, U>>()) | .perform(new Action1<List<Triple<Boolean, R, U>>>() { |
Xiaofei-it/Shelly | shelly/src/test/java/xiaofei/library/shelly/domino/Test06.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/task/Task.java
// public abstract class Task<T, R, S> {
//
// private TaskListener<R, S> mListener;
//
// public Task() {
// }
//
// public void setListener(TaskListener<R, S> listener) {
// mListener = listener;
// }
//
// protected abstract void onExecute(T input);
//
// public final void execute(T input) {
// onExecute(input);
// }
//
// public final void notifySuccess(R result) {
// if (mListener != null) {
// mListener.onSuccess(result);
// }
// }
//
// public final void notifyFailure(S error) {
// if (mListener != null) {
// mListener.onFailure(error);
// }
// }
//
// public interface TaskListener<R, S> {
// void onSuccess(R result);
// void onFailure(S error);
// }
//
// }
| import org.junit.Test;
import java.util.concurrent.TimeUnit;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.task.Task; | /**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/21.
*/
public class Test06 {
@Test
public void testTask() {
class A {
public void f(Character s) {
System.out.println("A f: " + Thread.currentThread().getName() + " " + s);
}
public void g(int s) {
System.out.println("A g: " + Thread.currentThread().getName() + " " + s);
}
} | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/task/Task.java
// public abstract class Task<T, R, S> {
//
// private TaskListener<R, S> mListener;
//
// public Task() {
// }
//
// public void setListener(TaskListener<R, S> listener) {
// mListener = listener;
// }
//
// protected abstract void onExecute(T input);
//
// public final void execute(T input) {
// onExecute(input);
// }
//
// public final void notifySuccess(R result) {
// if (mListener != null) {
// mListener.onSuccess(result);
// }
// }
//
// public final void notifyFailure(S error) {
// if (mListener != null) {
// mListener.onFailure(error);
// }
// }
//
// public interface TaskListener<R, S> {
// void onSuccess(R result);
// void onFailure(S error);
// }
//
// }
// Path: shelly/src/test/java/xiaofei/library/shelly/domino/Test06.java
import org.junit.Test;
import java.util.concurrent.TimeUnit;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.task.Task;
/**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/21.
*/
public class Test06 {
@Test
public void testTask() {
class A {
public void f(Character s) {
System.out.println("A f: " + Thread.currentThread().getName() + " " + s);
}
public void g(int s) {
System.out.println("A g: " + Thread.currentThread().getName() + " " + s);
}
} | Shelly.register(new A()); |
Xiaofei-it/Shelly | shelly/src/test/java/xiaofei/library/shelly/domino/Test06.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/task/Task.java
// public abstract class Task<T, R, S> {
//
// private TaskListener<R, S> mListener;
//
// public Task() {
// }
//
// public void setListener(TaskListener<R, S> listener) {
// mListener = listener;
// }
//
// protected abstract void onExecute(T input);
//
// public final void execute(T input) {
// onExecute(input);
// }
//
// public final void notifySuccess(R result) {
// if (mListener != null) {
// mListener.onSuccess(result);
// }
// }
//
// public final void notifyFailure(S error) {
// if (mListener != null) {
// mListener.onFailure(error);
// }
// }
//
// public interface TaskListener<R, S> {
// void onSuccess(R result);
// void onFailure(S error);
// }
//
// }
| import org.junit.Test;
import java.util.concurrent.TimeUnit;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.task.Task; | /**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/21.
*/
public class Test06 {
@Test
public void testTask() {
class A {
public void f(Character s) {
System.out.println("A f: " + Thread.currentThread().getName() + " " + s);
}
public void g(int s) {
System.out.println("A g: " + Thread.currentThread().getName() + " " + s);
}
}
Shelly.register(new A());
Shelly.<String>createDomino(1) | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/task/Task.java
// public abstract class Task<T, R, S> {
//
// private TaskListener<R, S> mListener;
//
// public Task() {
// }
//
// public void setListener(TaskListener<R, S> listener) {
// mListener = listener;
// }
//
// protected abstract void onExecute(T input);
//
// public final void execute(T input) {
// onExecute(input);
// }
//
// public final void notifySuccess(R result) {
// if (mListener != null) {
// mListener.onSuccess(result);
// }
// }
//
// public final void notifyFailure(S error) {
// if (mListener != null) {
// mListener.onFailure(error);
// }
// }
//
// public interface TaskListener<R, S> {
// void onSuccess(R result);
// void onFailure(S error);
// }
//
// }
// Path: shelly/src/test/java/xiaofei/library/shelly/domino/Test06.java
import org.junit.Test;
import java.util.concurrent.TimeUnit;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.task.Task;
/**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/21.
*/
public class Test06 {
@Test
public void testTask() {
class A {
public void f(Character s) {
System.out.println("A f: " + Thread.currentThread().getName() + " " + s);
}
public void g(int s) {
System.out.println("A g: " + Thread.currentThread().getName() + " " + s);
}
}
Shelly.register(new A());
Shelly.<String>createDomino(1) | .beginTask(new Task<String, Character, Integer>() { |
Xiaofei-it/Shelly | shelly/src/test/java/xiaofei/library/shelly/domino/Test06.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/task/Task.java
// public abstract class Task<T, R, S> {
//
// private TaskListener<R, S> mListener;
//
// public Task() {
// }
//
// public void setListener(TaskListener<R, S> listener) {
// mListener = listener;
// }
//
// protected abstract void onExecute(T input);
//
// public final void execute(T input) {
// onExecute(input);
// }
//
// public final void notifySuccess(R result) {
// if (mListener != null) {
// mListener.onSuccess(result);
// }
// }
//
// public final void notifyFailure(S error) {
// if (mListener != null) {
// mListener.onFailure(error);
// }
// }
//
// public interface TaskListener<R, S> {
// void onSuccess(R result);
// void onFailure(S error);
// }
//
// }
| import org.junit.Test;
import java.util.concurrent.TimeUnit;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.task.Task; | public void testTask() {
class A {
public void f(Character s) {
System.out.println("A f: " + Thread.currentThread().getName() + " " + s);
}
public void g(int s) {
System.out.println("A g: " + Thread.currentThread().getName() + " " + s);
}
}
Shelly.register(new A());
Shelly.<String>createDomino(1)
.beginTask(new Task<String, Character, Integer>() {
@Override
protected void onExecute(String input) {
System.out.println("1: " + Thread.currentThread().getName() + " " + input);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("2: " + Thread.currentThread().getName() + " " + input);
if (input.length() == 1) {
notifySuccess(input.charAt(0));
} else {
notifyFailure(input.charAt(0) - 'A');
}
}
})
.onSuccess(Shelly.<Character>createAnonymousDomino()
.background() | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/task/Task.java
// public abstract class Task<T, R, S> {
//
// private TaskListener<R, S> mListener;
//
// public Task() {
// }
//
// public void setListener(TaskListener<R, S> listener) {
// mListener = listener;
// }
//
// protected abstract void onExecute(T input);
//
// public final void execute(T input) {
// onExecute(input);
// }
//
// public final void notifySuccess(R result) {
// if (mListener != null) {
// mListener.onSuccess(result);
// }
// }
//
// public final void notifyFailure(S error) {
// if (mListener != null) {
// mListener.onFailure(error);
// }
// }
//
// public interface TaskListener<R, S> {
// void onSuccess(R result);
// void onFailure(S error);
// }
//
// }
// Path: shelly/src/test/java/xiaofei/library/shelly/domino/Test06.java
import org.junit.Test;
import java.util.concurrent.TimeUnit;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.task.Task;
public void testTask() {
class A {
public void f(Character s) {
System.out.println("A f: " + Thread.currentThread().getName() + " " + s);
}
public void g(int s) {
System.out.println("A g: " + Thread.currentThread().getName() + " " + s);
}
}
Shelly.register(new A());
Shelly.<String>createDomino(1)
.beginTask(new Task<String, Character, Integer>() {
@Override
protected void onExecute(String input) {
System.out.println("1: " + Thread.currentThread().getName() + " " + input);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("2: " + Thread.currentThread().getName() + " " + input);
if (input.length() == 1) {
notifySuccess(input.charAt(0));
} else {
notifyFailure(input.charAt(0) - 'A');
}
}
})
.onSuccess(Shelly.<Character>createAnonymousDomino()
.background() | .perform(new Action1<Character>() { |
Xiaofei-it/Shelly | shelly/src/test/java/xiaofei/library/shelly/domino/Test06.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/task/Task.java
// public abstract class Task<T, R, S> {
//
// private TaskListener<R, S> mListener;
//
// public Task() {
// }
//
// public void setListener(TaskListener<R, S> listener) {
// mListener = listener;
// }
//
// protected abstract void onExecute(T input);
//
// public final void execute(T input) {
// onExecute(input);
// }
//
// public final void notifySuccess(R result) {
// if (mListener != null) {
// mListener.onSuccess(result);
// }
// }
//
// public final void notifyFailure(S error) {
// if (mListener != null) {
// mListener.onFailure(error);
// }
// }
//
// public interface TaskListener<R, S> {
// void onSuccess(R result);
// void onFailure(S error);
// }
//
// }
| import org.junit.Test;
import java.util.concurrent.TimeUnit;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.task.Task; | }
}
Shelly.register(new A());
Shelly.<String>createDomino(1)
.beginTask(new Task<String, Character, Integer>() {
@Override
protected void onExecute(String input) {
System.out.println("1: " + Thread.currentThread().getName() + " " + input);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("2: " + Thread.currentThread().getName() + " " + input);
if (input.length() == 1) {
notifySuccess(input.charAt(0));
} else {
notifyFailure(input.charAt(0) - 'A');
}
}
})
.onSuccess(Shelly.<Character>createAnonymousDomino()
.background()
.perform(new Action1<Character>() {
@Override
public void call(Character input) {
System.out.println("3: " + Thread.currentThread().getName() + " " + input);
}
}))
.newThread() | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/task/Task.java
// public abstract class Task<T, R, S> {
//
// private TaskListener<R, S> mListener;
//
// public Task() {
// }
//
// public void setListener(TaskListener<R, S> listener) {
// mListener = listener;
// }
//
// protected abstract void onExecute(T input);
//
// public final void execute(T input) {
// onExecute(input);
// }
//
// public final void notifySuccess(R result) {
// if (mListener != null) {
// mListener.onSuccess(result);
// }
// }
//
// public final void notifyFailure(S error) {
// if (mListener != null) {
// mListener.onFailure(error);
// }
// }
//
// public interface TaskListener<R, S> {
// void onSuccess(R result);
// void onFailure(S error);
// }
//
// }
// Path: shelly/src/test/java/xiaofei/library/shelly/domino/Test06.java
import org.junit.Test;
import java.util.concurrent.TimeUnit;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.task.Task;
}
}
Shelly.register(new A());
Shelly.<String>createDomino(1)
.beginTask(new Task<String, Character, Integer>() {
@Override
protected void onExecute(String input) {
System.out.println("1: " + Thread.currentThread().getName() + " " + input);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("2: " + Thread.currentThread().getName() + " " + input);
if (input.length() == 1) {
notifySuccess(input.charAt(0));
} else {
notifyFailure(input.charAt(0) - 'A');
}
}
})
.onSuccess(Shelly.<Character>createAnonymousDomino()
.background()
.perform(new Action1<Character>() {
@Override
public void call(Character input) {
System.out.println("3: " + Thread.currentThread().getName() + " " + input);
}
}))
.newThread() | .onSuccess(new Action0() { |
Xiaofei-it/Shelly | shelly/src/test/java/xiaofei/library/shelly/domino/Test06.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/task/Task.java
// public abstract class Task<T, R, S> {
//
// private TaskListener<R, S> mListener;
//
// public Task() {
// }
//
// public void setListener(TaskListener<R, S> listener) {
// mListener = listener;
// }
//
// protected abstract void onExecute(T input);
//
// public final void execute(T input) {
// onExecute(input);
// }
//
// public final void notifySuccess(R result) {
// if (mListener != null) {
// mListener.onSuccess(result);
// }
// }
//
// public final void notifyFailure(S error) {
// if (mListener != null) {
// mListener.onFailure(error);
// }
// }
//
// public interface TaskListener<R, S> {
// void onSuccess(R result);
// void onFailure(S error);
// }
//
// }
| import org.junit.Test;
import java.util.concurrent.TimeUnit;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.task.Task; | System.out.println("2: " + Thread.currentThread().getName() + " " + input);
if (input.length() == 1) {
notifySuccess(input.charAt(0));
} else {
notifyFailure(input.charAt(0) - 'A');
}
}
})
.onSuccess(Shelly.<Character>createAnonymousDomino()
.background()
.perform(new Action1<Character>() {
@Override
public void call(Character input) {
System.out.println("3: " + Thread.currentThread().getName() + " " + input);
}
}))
.newThread()
.onSuccess(new Action0() {
@Override
public void call() {
System.out.println("4: " + Thread.currentThread().getName());
}
})
.onSuccess(new Action1<Character>() {
@Override
public void call(Character input) {
System.out.println("5: " + Thread.currentThread().getName() + " " + input);
}
})
.background() | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/task/Task.java
// public abstract class Task<T, R, S> {
//
// private TaskListener<R, S> mListener;
//
// public Task() {
// }
//
// public void setListener(TaskListener<R, S> listener) {
// mListener = listener;
// }
//
// protected abstract void onExecute(T input);
//
// public final void execute(T input) {
// onExecute(input);
// }
//
// public final void notifySuccess(R result) {
// if (mListener != null) {
// mListener.onSuccess(result);
// }
// }
//
// public final void notifyFailure(S error) {
// if (mListener != null) {
// mListener.onFailure(error);
// }
// }
//
// public interface TaskListener<R, S> {
// void onSuccess(R result);
// void onFailure(S error);
// }
//
// }
// Path: shelly/src/test/java/xiaofei/library/shelly/domino/Test06.java
import org.junit.Test;
import java.util.concurrent.TimeUnit;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.task.Task;
System.out.println("2: " + Thread.currentThread().getName() + " " + input);
if (input.length() == 1) {
notifySuccess(input.charAt(0));
} else {
notifyFailure(input.charAt(0) - 'A');
}
}
})
.onSuccess(Shelly.<Character>createAnonymousDomino()
.background()
.perform(new Action1<Character>() {
@Override
public void call(Character input) {
System.out.println("3: " + Thread.currentThread().getName() + " " + input);
}
}))
.newThread()
.onSuccess(new Action0() {
@Override
public void call() {
System.out.println("4: " + Thread.currentThread().getName());
}
})
.onSuccess(new Action1<Character>() {
@Override
public void call(Character input) {
System.out.println("5: " + Thread.currentThread().getName() + " " + input);
}
})
.background() | .onSuccess(A.class, new TargetAction0<A>() { |
Xiaofei-it/Shelly | shelly/src/test/java/xiaofei/library/shelly/domino/Test06.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/task/Task.java
// public abstract class Task<T, R, S> {
//
// private TaskListener<R, S> mListener;
//
// public Task() {
// }
//
// public void setListener(TaskListener<R, S> listener) {
// mListener = listener;
// }
//
// protected abstract void onExecute(T input);
//
// public final void execute(T input) {
// onExecute(input);
// }
//
// public final void notifySuccess(R result) {
// if (mListener != null) {
// mListener.onSuccess(result);
// }
// }
//
// public final void notifyFailure(S error) {
// if (mListener != null) {
// mListener.onFailure(error);
// }
// }
//
// public interface TaskListener<R, S> {
// void onSuccess(R result);
// void onFailure(S error);
// }
//
// }
| import org.junit.Test;
import java.util.concurrent.TimeUnit;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.task.Task; | })
.background()
.onSuccess(A.class, new TargetAction0<A>() {
@Override
public void call(A a) {
System.out.println("6: " + Thread.currentThread().getName());
a.f('T');
}
})
.backgroundQueue()
.onFailure(Shelly.<Integer>createAnonymousDomino()
.newThread()
.perform(new Action1<Integer>() {
@Override
public void call(Integer input) {
System.out.println("7: " + Thread.currentThread().getName() + " " + input);
}
}))
.onFailure(new Action1<Integer>() {
@Override
public void call(Integer input) {
System.out.println("8: " + Thread.currentThread().getName() + " " + input);
}
})
.onFailure(new Action0() {
@Override
public void call() {
System.out.println("9: " + Thread.currentThread().getName());
}
}) | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action0.java
// public interface Action0 extends Action {
// void call();
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction0.java
// public interface TargetAction0<T> extends Action {
// void call(T t);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/TargetAction1.java
// public interface TargetAction1<T, R> extends Action {
// void call(T t, R input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/task/Task.java
// public abstract class Task<T, R, S> {
//
// private TaskListener<R, S> mListener;
//
// public Task() {
// }
//
// public void setListener(TaskListener<R, S> listener) {
// mListener = listener;
// }
//
// protected abstract void onExecute(T input);
//
// public final void execute(T input) {
// onExecute(input);
// }
//
// public final void notifySuccess(R result) {
// if (mListener != null) {
// mListener.onSuccess(result);
// }
// }
//
// public final void notifyFailure(S error) {
// if (mListener != null) {
// mListener.onFailure(error);
// }
// }
//
// public interface TaskListener<R, S> {
// void onSuccess(R result);
// void onFailure(S error);
// }
//
// }
// Path: shelly/src/test/java/xiaofei/library/shelly/domino/Test06.java
import org.junit.Test;
import java.util.concurrent.TimeUnit;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action0;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.TargetAction0;
import xiaofei.library.shelly.function.TargetAction1;
import xiaofei.library.shelly.task.Task;
})
.background()
.onSuccess(A.class, new TargetAction0<A>() {
@Override
public void call(A a) {
System.out.println("6: " + Thread.currentThread().getName());
a.f('T');
}
})
.backgroundQueue()
.onFailure(Shelly.<Integer>createAnonymousDomino()
.newThread()
.perform(new Action1<Integer>() {
@Override
public void call(Integer input) {
System.out.println("7: " + Thread.currentThread().getName() + " " + input);
}
}))
.onFailure(new Action1<Integer>() {
@Override
public void call(Integer input) {
System.out.println("8: " + Thread.currentThread().getName() + " " + input);
}
})
.onFailure(new Action0() {
@Override
public void call() {
System.out.println("9: " + Thread.currentThread().getName());
}
}) | .onSuccess(A.class, new TargetAction1<A, Character>() { |
Xiaofei-it/Shelly | shelly/src/test/java/xiaofei/library/shelly/domino/Test04.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
| import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1; | /**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/18.
*/
public class Test04 {
@Test
public void testFlatMap() { | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
// Path: shelly/src/test/java/xiaofei/library/shelly/domino/Test04.java
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
/**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/18.
*/
public class Test04 {
@Test
public void testFlatMap() { | Shelly.<String>createDomino(1) |
Xiaofei-it/Shelly | shelly/src/test/java/xiaofei/library/shelly/domino/Test04.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
| import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1; | /**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/18.
*/
public class Test04 {
@Test
public void testFlatMap() {
Shelly.<String>createDomino(1) | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
// Path: shelly/src/test/java/xiaofei/library/shelly/domino/Test04.java
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
/**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/18.
*/
public class Test04 {
@Test
public void testFlatMap() {
Shelly.<String>createDomino(1) | .perform(new Action1<String>() { |
Xiaofei-it/Shelly | shelly/src/test/java/xiaofei/library/shelly/domino/Test04.java | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
| import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1; | /**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/18.
*/
public class Test04 {
@Test
public void testFlatMap() {
Shelly.<String>createDomino(1)
.perform(new Action1<String>() {
@Override
public void call(String input) {
System.out.println("1: " + input);
}
}) | // Path: shelly/src/main/java/xiaofei/library/shelly/Shelly.java
// public class Shelly {
//
// private static final TargetCenter TARGET_CENTER = TargetCenter.getInstance();
//
// private static final DominoCenter DOMINO_CENTER = DominoCenter.getInstance();
//
// public static void register(Object object) {
// TARGET_CENTER.register(object);
// }
//
// public static boolean isRegistered(Object object) {
// return TARGET_CENTER.isRegistered(object);
// }
//
// public static void unregister(Object object) {
// TARGET_CENTER.unregister(object);
// }
//
// public static <T> Domino<T, T> createDomino(Object label) {
// return new Domino<T, T>(label);
// }
//
// public static <T> Domino<T, T> createAnonymousDomino() {
// return createDomino(null);
// }
//
// @SafeVarargs
// public static <T> void playDomino(Object label, T... input) {
// CopyOnWriteArrayList<T> newInput = new CopyOnWriteArrayList<T>();
// if (input == null) {
// newInput.add(null);
// } else if (input.length > 0) {
// newInput.addAll(Arrays.asList(input));
// }
// playDominoInternal(label, newInput);
// }
//
// public static void playDomino(Object label) {
// playDominoInternal(label, new CopyOnWriteArrayList<Object>());
// }
//
// private static <T> void playDominoInternal(Object label, CopyOnWriteArrayList<T> input) {
// DOMINO_CENTER.play(label, input);
// }
//
// public static <T, R> Domino<T, R> getDominoByLabel(Object label) {
// return DOMINO_CENTER.getDomino(label);
// }
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Action1.java
// public interface Action1<T> extends Action {
// void call(T input);
// }
//
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
// R call(T input);
// }
// Path: shelly/src/test/java/xiaofei/library/shelly/domino/Test04.java
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import xiaofei.library.shelly.Shelly;
import xiaofei.library.shelly.function.Action1;
import xiaofei.library.shelly.function.Function1;
/**
*
* Copyright 2016 Xiaofei
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package xiaofei.library.shelly.domino;
/**
* Created by Xiaofei on 16/6/18.
*/
public class Test04 {
@Test
public void testFlatMap() {
Shelly.<String>createDomino(1)
.perform(new Action1<String>() {
@Override
public void call(String input) {
System.out.println("1: " + input);
}
}) | .flatMap(new Function1<String, List<Integer>>() { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.