List of usage examples for org.apache.commons.lang3.tuple Pair getLeft
public abstract L getLeft();
Gets the left element from this pair.
When treated as a key-value pair, this is the key.
From source file:eionet.gdem.web.listeners.JobScheduler.java
/** * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) {@inheritDoc} *///from w w w.jav a 2 s.c om @Override public void contextInitialized(ServletContextEvent sce) { intervalJobs = new Pair[] { Pair.of(new Integer(Properties.wqCheckInterval), newJob(WQCheckerJob.class) .withIdentity(WQCheckerJob.class.getSimpleName(), WQCheckerJob.class.getName()).build()), Pair.of(new Integer(Properties.wqCleanInterval), newJob(WQCleanerJob.class) .withIdentity(WQCleanerJob.class.getSimpleName(), WQCleanerJob.class.getName()).build()), Pair.of(new Integer(Properties.ddTablesUpdateInterval), newJob(DDTablesCacheUpdater.class).withIdentity(DDTablesCacheUpdater.class.getSimpleName(), DDTablesCacheUpdater.class.getName()).build()) }; // schedule interval jobs for (Pair<Integer, JobDetail> job : intervalJobs) { try { scheduleIntervalJob(job.getLeft(), job.getRight()); LOGGER.debug(job.getRight().getKey().getName() + " scheduled, interval=" + job.getLeft()); } catch (Exception e) { LOGGER.error(Markers.fatal, "Error when scheduling " + job.getRight().getKey().getName(), e); } } WorkqueueManager.resetActiveJobs(); }
From source file:com.intuit.karate.Script.java
private static ScriptValue getValueOfParentNode(Object actRoot, String path) { if (actRoot instanceof DocumentContext) { Pair<String, String> parentAndLeaf = JsonUtils.getParentAndLeafPath(path); DocumentContext actDoc = (DocumentContext) actRoot; Object thisObject = actDoc.read(parentAndLeaf.getLeft()); return new ScriptValue(thisObject); } else {/*w ww . ja v a 2 s .c om*/ return null; } }
From source file:additionalpipes.pipes.PipeFluidsTeleport.java
@Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { if (CoreProxy.proxy.isRenderWorld(container.worldObj)) { return 0; }/* w ww.ja v a 2 s.c o m*/ FluidStack fluid = resource.copy(); List<PipeFluidsTeleport> connectedPipes = logic.getConnectedPipes(true); connectedPipes = Lists.newArrayList(connectedPipes); Collections.shuffle(connectedPipes, container.worldObj.rand); OUTER: for (PipeFluidsTeleport destPipe : connectedPipes) { List<Pair<ForgeDirection, IFluidHandler>> fluidsList = destPipe.getPossibleFluidsMovements(); Collections.shuffle(fluidsList, container.worldObj.rand); for (Pair<ForgeDirection, IFluidHandler> fluids : fluidsList) { ForgeDirection side = fluids.getLeft(); IFluidHandler tank = fluids.getRight(); int usedSingle = tank.fill(side, fluid, false); if (usedSingle > 0) { int energy = APUtils.divideAndCeil(usedSingle, AdditionalPipes.unitFluids); if (doFill ? logic.useEnergy(energy) : logic.canUseEnergy(energy)) { if (doFill) { tank.fill(side, fluid, doFill); } fluid.amount -= usedSingle; if (fluid.amount <= 0) { break OUTER; } } } } } return resource.amount - fluid.amount; }
From source file:com.epam.ngb.cli.manager.command.handler.http.ReferenceRegistrationHandler.java
/** * Verifies that input arguments contain the required parameters: * first and the only argument must be path to the reference file. * @param arguments command line arguments for 'register_reference' command * @param options to specify a reference name and output options *///from w w w .j a v a 2 s . c om @Override public void parseAndVerifyArguments(List<String> arguments, ApplicationOptions options) { if (arguments.isEmpty() || arguments.size() != 1) { throw new IllegalArgumentException( MessageConstants.getMessage(ILLEGAL_COMMAND_ARGUMENTS, getCommand(), 1, arguments.size())); } referencePath = arguments.get(0); if (options.getName() != null) { referenceName = options.getName(); } if (options.getGeneFile() != null) { try { geneFileId = loadFileByNameOrBioID(options.getGeneFile()).getId(); } catch (ApplicationException e) { LOGGER.debug(e.getMessage(), e); Pair<String, String> path = parseAndVerifyFilePath(options.getGeneFile()); geneFilePath = path.getLeft(); geneIndexPath = path.getRight(); } } printJson = options.isPrintJson(); printTable = options.isPrintTable(); noGCContent = options.isNoGCContent(); prettyName = options.getPrettyName(); }
From source file:com.act.lcms.v2.TraceIndexAnalyzer.java
private void runExtraction(File rocksDBFile, File outputFile) throws RocksDBException, IOException { List<AnalysisResult> results = new ArrayList<>(); // Extract each target's trace, computing and saving stats as we go. This should fit in memory no problem. Iterator<Pair<Double, List<XZ>>> traceIterator = new TraceIndexExtractor() .getIteratorOverTraces(rocksDBFile); while (traceIterator.hasNext()) { Pair<Double, List<XZ>> targetAndTrace = traceIterator.next(); String label = String.format("%.6f", targetAndTrace.getLeft()); // Note: here we cheat by knowing how the MS1 class is going to use this incredibly complex container. MS1ScanForWellAndMassCharge scanForWell = new MS1ScanForWellAndMassCharge(); scanForWell.setMetlinIons(Collections.singletonList(label)); scanForWell.getIonsToSpectra().put(label, targetAndTrace.getRight()); Pair<List<XZ>, Map<Double, Double>> timeWindowsAndMaxes = WaveformAnalysis .compressIntensityAndTimeGraphsAndFindMaxIntensityInEveryTimeWindow(targetAndTrace.getRight(), WaveformAnalysis.COMPRESSION_CONSTANT); List<XZ> calledPeaks = WaveformAnalysis.detectPeaksInIntensityTimeWaveform( timeWindowsAndMaxes.getLeft(), WaveformAnalysis.PEAK_DETECTION_THRESHOLD); // Same as waveform analysis. for (XZ calledPeak : calledPeaks) { AnalysisResult result = new AnalysisResult(targetAndTrace.getLeft(), timeWindowsAndMaxes.getRight().get(calledPeak.getTime()), calledPeak.getTime()); results.add(result);//from w w w . j a v a2 s. co m } } LOGGER.info("Writing window stats to JSON file"); try (FileOutputStream fos = new FileOutputStream(outputFile)) { OBJECT_MAPPER.writerWithDefaultPrettyPrinter().writeValue(fos, results); } }
From source file:cherry.sqlman.tool.statement.SqlStatementControllerImpl.java
@Override public ModelAndView execute(SqlStatementForm form, BindingResult binding, Authentication auth, Locale locale, SitePreference sitePref, NativeWebRequest request) { if (hasErrors(form, binding)) { return withViewname(viewnameOfStart).build(); }//from w w w. j ava2 s . c o m try { Pair<PageSet, ResultSet> pair = search(form); return withViewname(viewnameOfStart).addObject(pair.getLeft()).addObject(pair.getRight()).build(); } catch (BadSqlGrammarException ex) { LogicalErrorUtil.reject(binding, LogicError.BadSqlGrammer, Util.getRootCause(ex).getMessage()); return withViewname(viewnameOfStart).build(); } }
From source file:gobblin.ingestion.google.webmaster.UrlTriePostOrderIteratorTest.java
/** * The trie is:// w w w .j ava 2 s .co m * / * 0 * 1 * 2 */ @Test public void testVerticalTrie1TraversalWithSize2() { UrlTrie trie = new UrlTrie(_property, Arrays.asList(_property + "0", _property + "01", _property + "012")); UrlTriePostOrderIterator iterator = new UrlTriePostOrderIterator(trie, 2); ArrayList<String> chars = new ArrayList<>(); while (iterator.hasNext()) { Pair<String, UrlTrieNode> next = iterator.next(); chars.add(next.getLeft()); } Assert.assertEquals(new String[] { _property + "01", _property + "0", _property }, chars.toArray()); }
From source file:gobblin.ingestion.google.webmaster.UrlTriePostOrderIteratorTest.java
/** * The trie is://from w ww .ja v a 2 s.c o m * / * 0 * 1 * 2 */ @Test public void testVerticalTrie1TraversalWithSize1() { UrlTrie trie = new UrlTrie(_property, Arrays.asList(_property + "0", _property + "01", _property + "012")); UrlTriePostOrderIterator iterator = new UrlTriePostOrderIterator(trie, 1); ArrayList<String> chars = new ArrayList<>(); while (iterator.hasNext()) { Pair<String, UrlTrieNode> next = iterator.next(); chars.add(next.getLeft()); } Assert.assertEquals(new String[] { _property + "012", _property + "01", _property + "0", _property }, chars.toArray()); }
From source file:gobblin.ingestion.google.webmaster.UrlTriePostOrderIteratorTest.java
/** * The trie is://from www. jav a2 s . c o m * / * 0 * 1 * 2 */ @Test public void testVerticalTrie1TraversalWithSize3() { UrlTrie trie = new UrlTrie(_property, Arrays.asList(_property + "0", _property + "01", _property + "012")); UrlTriePostOrderIterator iterator = new UrlTriePostOrderIterator(trie, 3); ArrayList<String> chars = new ArrayList<>(); while (iterator.hasNext()) { Pair<String, UrlTrieNode> next = iterator.next(); chars.add(next.getLeft()); } //the root node is a leaf node Assert.assertEquals(new String[] { _property }, chars.toArray()); }
From source file:gobblin.ingestion.google.webmaster.UrlTriePostOrderIteratorTest.java
/** * The trie is://from w w w .j a v a2 s . c om * / * 0 * 1 * 2 */ @Test public void testVerticalTrie1TraversalWithSize4() { UrlTrie trie = new UrlTrie(_property, Arrays.asList(_property + "0", _property + "01", _property + "012")); UrlTriePostOrderIterator iterator = new UrlTriePostOrderIterator(trie, 4); ArrayList<String> chars = new ArrayList<>(); while (iterator.hasNext()) { Pair<String, UrlTrieNode> next = iterator.next(); chars.add(next.getLeft()); } //the root node is a leaf node Assert.assertEquals(new String[] { _property }, chars.toArray()); }