List of usage examples for org.apache.commons.lang3.tuple Pair of
public static <L, R> Pair<L, R> of(final L left, final R right)
Obtains an immutable pair of from two objects inferring the generic types.
This factory allows the pair to be created using inference to obtain the generic types.
From source file:edu.wpi.checksims.algorithm.similaritymatrix.SimilarityMatrix.java
/** * @return Size of the Similarity Matrix */ public Pair<Integer, Integer> getArrayBounds() { return Pair.of(xSubmissions.size(), ySubmissions.size()); }
From source file:com.github.jknack.handlebars.cache.HighConcurrencyTemplateCache.java
/** * Creates a new future task for compiling the given source. * * @param source The template source.// w ww .j a va2 s . co m * @param parser The handlebars parser. * @return A new future task. */ private FutureTask<Pair<TemplateSource, Template>> newTask(final TemplateSource source, final Parser parser) { return new FutureTask<Pair<TemplateSource, Template>>(new Callable<Pair<TemplateSource, Template>>() { @Override public Pair<TemplateSource, Template> call() throws IOException { return Pair.of(source, parser.parse(source)); } }); }
From source file:de.ellpeck.actuallyadditions.mod.tile.TileEntityItemRepairer.java
public static boolean isBlacklisted(ItemStack stack) { if (!runOnce) { runOnce = true;//from ww w. jav a 2 s. co m for (String s : ConfigStringListValues.REPAIR_BLACKLIST.getValue()) { String[] split = s.split("@"); Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(split[0])); if (item == null) { ActuallyAdditions.LOGGER.error("Invalid item in repair blacklist: " + s); continue; } if (split.length == 1) BLACKLIST.add(Pair.of(item, 0)); else if (split.length == 2) { BLACKLIST.add(Pair.of(item, Integer.parseInt(split[1]))); } } } return BLACKLIST.contains(Pair.of(stack.getItem(), stack.getMetadata())); }
From source file:io.cloudslang.lang.runtime.steps.ExecutableSteps.java
/** * This method is executed by the finishExecutable execution step of an operation or flow * * @param runEnv the run environment object * @param executableOutputs the operation outputs data * @param executableResults the operation results data * @param executionRuntimeServices services supplied by score engine for handling the execution */// ww w.j a va2s . c om public void finishExecutable(@Param(ScoreLangConstants.RUN_ENV) RunEnvironment runEnv, @Param(ScoreLangConstants.EXECUTABLE_OUTPUTS_KEY) List<Output> executableOutputs, @Param(ScoreLangConstants.EXECUTABLE_RESULTS_KEY) List<Result> executableResults, @Param(EXECUTION_RUNTIME_SERVICES) ExecutionRuntimeServices executionRuntimeServices, @Param(ScoreLangConstants.NODE_NAME_KEY) String nodeName) { try { runEnv.getExecutionPath().up(); Context operationContext = runEnv.getStack().popContext(); Map<String, Serializable> operationVariables = operationContext == null ? null : operationContext.getImmutableViewOfVariables(); ReturnValues actionReturnValues = runEnv.removeReturnValues(); fireEvent(executionRuntimeServices, runEnv, ScoreLangConstants.EVENT_OUTPUT_START, "Output binding started", Pair.of(ScoreLangConstants.EXECUTABLE_OUTPUTS_KEY, (Serializable) executableOutputs), Pair.of(ScoreLangConstants.EXECUTABLE_RESULTS_KEY, (Serializable) executableResults), Pair.of("actionReturnValues", actionReturnValues), Pair.of(LanguageEventData.levelName.EXECUTABLE_NAME.toString(), nodeName)); // Resolving the result of the operation/flow String result = resultsBinding.resolveResult(operationVariables, actionReturnValues.getOutputs(), executableResults, actionReturnValues.getResult()); Map<String, Serializable> operationReturnOutputs = outputsBinding.bindOutputs(operationVariables, actionReturnValues.getOutputs(), executableOutputs); //todo: hook ReturnValues returnValues = new ReturnValues(operationReturnOutputs, result); runEnv.putReturnValues(returnValues); fireEvent(executionRuntimeServices, runEnv, ScoreLangConstants.EVENT_OUTPUT_END, "Output binding finished", Pair.of(LanguageEventData.OUTPUTS, (Serializable) operationReturnOutputs), Pair.of(LanguageEventData.RESULT, returnValues.getResult()), Pair.of(LanguageEventData.levelName.EXECUTABLE_NAME.toString(), nodeName)); // If we have parent flow data on the stack, we pop it and request the score engine to switch to the parent // execution plan id once it can, and we set the next position that was stored there for the use of the navigation if (!runEnv.getParentFlowStack().isEmpty()) { handleNavigationToParent(runEnv, executionRuntimeServices); } else { fireEvent(executionRuntimeServices, runEnv, ScoreLangConstants.EVENT_EXECUTION_FINISHED, "Execution finished running", Pair.of(LanguageEventData.RESULT, returnValues.getResult()), Pair.of(LanguageEventData.OUTPUTS, (Serializable) operationReturnOutputs), Pair.of(LanguageEventData.levelName.EXECUTABLE_NAME.toString(), nodeName)); } } catch (RuntimeException e) { logger.error("There was an error running the finish executable execution step of: \'" + nodeName + "\'.\n\tError is: " + e.getMessage()); throw new RuntimeException("Error running: \'" + nodeName + "\'.\n\t" + e.getMessage(), e); } }
From source file:alfio.model.Event.java
@Override @JsonIgnore public Pair<String, String> getLatLong() { return Pair.of(latitude, longitude); }
From source file:candr.yoclip.option.OptionPropertiesField.java
@Override public List<Pair<String, String>> getPropertyDescriptions() { final PropertyDescription[] propertyDescriptions = getOptionProperties().propertyDescriptions(); if (ArrayUtils.isEmpty(propertyDescriptions)) { return Collections.emptyList(); }//from w w w. j a v a 2 s.c o m List<Pair<String, String>> synopsisAndDetails = new LinkedList<Pair<String, String>>(); for (final PropertyDescription propertyDescription : propertyDescriptions) { synopsisAndDetails.add( Pair.of(propertyDescription.synopsis(), OptionUtils.combine(propertyDescription.details()))); } return synopsisAndDetails; }
From source file:net.lyonlancer5.mcmp.unmapi.xejon.XejonLoader.java
/** * Enumerates the extensions present and checks for dupes *///from w w w. j a v a2s . com public void enumerate() { if (success) { LOGGER.info("Enumerating sources from " + Constants.EXTENSIONS_DIR.getAbsolutePath()); List<String> registeredID = Lists.newArrayList(); for (File directory : Constants.EXTENSIONS_DIR.listFiles(new FileFilter() { public boolean accept(File pathname) { return pathname.isDirectory(); } })) { LOGGER.trace("Looking in " + directory.getPath()); List<File> jsonFilesInDir = FSTools.findRecursively(directory, TXT_JSON); for (File jsonFile : jsonFilesInDir) { if (jsonFile.getName().endsWith("pack-info.json") || jsonFile.getName().endsWith("pack-info.txt")) { LOGGER.debug("Found JSON pack info in " + directory.getPath()); try { JsonParser parser = new JsonParser(); JsonObject rootObject = parser.parse(new FileReader(jsonFile)).getAsJsonObject(); String str = rootObject.get("id").getAsString(); if (!(str.equals("null") && registeredID.contains(str))) { registeredID.add(str); jsonPackIds.add(Pair.of(str, Pair.of(jsonFile.getParentFile(), rootObject))); LOGGER.debug("Registered an extension pack with ID: " + str); } } catch (IOException | JsonParseException e) { LOGGER.warn("Cannot read pack-info.json in " + jsonFile.getParent() + ", ignoring"); } } } LOGGER.info("Read through " + jsonPackIds.size() + " candidate directories"); } } else { LOGGER.warn("Reflection failed, all extensions will fail to load!"); jsonPackIds.clear(); } }
From source file:com.act.lcms.db.io.parser.PlateCompositionParser.java
public void processFile(File inFile) throws IOException { try (BufferedReader br = new BufferedReader(new FileReader(inFile))) { String line;/*w w w .ja v a2s.c om*/ boolean readingCompositionTable = false; String compositionTableName = null; List<String> compositionTableColumns = null; int rowIndexInCompositionTable = 0; while ((line = br.readLine()) != null) { if (line.startsWith(">>")) { // TODO: add max table width based on plate type. String[] fields = StringUtils.splitByWholeSeparatorPreserveAllTokens(line, "\t"); readingCompositionTable = true; if (fields.length < 2) { throw new RuntimeException( String.format("Found malformed composition table header: %s", line)); } compositionTableColumns = Arrays.asList(fields); compositionTableName = fields[0].replaceFirst("^>>", ""); rowIndexInCompositionTable = 0; } else if (line.startsWith(">")) { String[] fields = StringUtils.split(line, "\t", 2); // Found a plate attribute. if (fields.length != 2) { System.err.format("Too few fields: %s\n", StringUtils.join(fields, ", ")); System.err.flush(); throw new RuntimeException(String.format("Found malformed plate attribute line: %s", line)); } plateProperties.put(fields[0].replaceFirst("^>", ""), fields[1]); } else if (line.trim().length() == 0) { // Assume a blank line terminates a composition table. readingCompositionTable = false; compositionTableName = null; compositionTableColumns = null; rowIndexInCompositionTable = 0; } else if (readingCompositionTable) { // This split method with a very long name preserves blanks and doesn't merge consecutive delimiters. String[] fields = StringUtils.splitByWholeSeparatorPreserveAllTokens(line, "\t"); // The split ^^ preserves blanks, so we can exactly compare the lengths. if (fields.length != compositionTableColumns.size()) { throw new RuntimeException(String.format( "Found %d fields where %d were expected in composition table line:\n '%s'\n", fields.length, compositionTableColumns.size(), line)); } for (int i = 1; i < fields.length; i++) { String val = compositionTableColumns.get(i); // No need to store empty values; if (val == null || val.isEmpty()) { continue; } Pair<String, String> coordinates = Pair.of(fields[0], val); // Note: assumes every row appears in each composition table (even empty ones). coordinatesToIndices.put(coordinates, Pair.of(rowIndexInCompositionTable, i - 1)); Map<Pair<String, String>, String> thisTable = compositionTables.get(compositionTableName); if (thisTable == null) { thisTable = new HashMap<>(); compositionTables.put(compositionTableName, thisTable); } // TODO: add paranoid check for repeated keys? Shouldn't be possible unless tables are repeated. thisTable.put(coordinates, fields[i]); } rowIndexInCompositionTable++; } } } }
From source file:enumj.StreamComparator.java
private Pair<Function<Stream<T>, Stream<T>>, Function<E, E>> getPeekFuns() { final int seed = rnd.nextInt(); final Consumer<T> peeker = peekConsumerOfSeed.apply(seed); final Function<Stream<T>, Stream<T>> lhs = s -> s.peek(peeker); final Function<E, E> rhs = e -> peek(e, peeker); if (statistics != null) { statistics.peek();//from w w w . java 2s .co m } return Pair.of(lhs, rhs); }
From source file:de.ks.activity.context.ActivityContext.java
protected Pair<String, Class<?>> getKey(Bean<?> bean) { Class<?> beanClass = bean.getBeanClass(); Annotation annotation = beanClass.getAnnotation(ActivityScoped.class); if (annotation == null) {//might be a producer method, only warn String msg = "Unable to retrieve " + ActivityScoped.class.getName() + " from " + beanClass; if (bean.getClass().getName().contains("Producer")) { log.trace(msg);/*www .j a v a 2s . c o m*/ } else { log.warn(msg); } } if (currentActivity == null) { throw new IllegalStateException("No activity currently active!"); } return Pair.of(currentActivity, beanClass); }