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:com.act.lcms.db.model.DeliveredStrainWell.java
public List<DeliveredStrainWell> insertFromPlateComposition(DB db, PlateCompositionParser parser, Plate p) throws SQLException, IOException { List<DeliveredStrainWell> results = new ArrayList<>(); Map<Pair<String, String>, String> featuresTable = parser.getCompositionTables().get("well"); /* The composition tables are usually constructed with well coordinates as the X and Y axes. Amyris strain plates, * however, have the combined well coordinates in the first column and the msid/composition in related columns. * We'll collect the features in each row by traversing the per-cell entries in the parser's table and merging on * the first coordinate component. */ Map<Pair<Integer, Integer>, Map<String, String>> wellToFeaturesMap = new HashMap<>(); for (Map.Entry<Pair<String, String>, String> entry : featuresTable.entrySet()) { String wellCoordinates = entry.getKey().getLeft(); String featureName = entry.getKey().getRight(); String featureValue = entry.getValue(); Pair<Integer, Integer> coordinates = Utils.parsePlateCoordinates(wellCoordinates); Map<String, String> featuresForWell = wellToFeaturesMap.get(coordinates); if (featuresForWell == null) { featuresForWell = new HashMap<>(); wellToFeaturesMap.put(coordinates, featuresForWell); }//from ww w . j ava 2 s. c o m if (featuresForWell.containsKey(featureName)) { throw new RuntimeException( String.format("Found duplicate feature %s for well %s", wellCoordinates, featureName)); } featuresForWell.put(featureName, featureValue); // Also save the original well coordinates string. featuresForWell.put("well", wellCoordinates); } List<Map.Entry<Pair<Integer, Integer>, Map<String, String>>> sortedEntries = new ArrayList<>( wellToFeaturesMap.entrySet()); Collections.sort(sortedEntries, new Comparator<Map.Entry<Pair<Integer, Integer>, Map<String, String>>>() { @Override public int compare(Map.Entry<Pair<Integer, Integer>, Map<String, String>> o1, Map.Entry<Pair<Integer, Integer>, Map<String, String>> o2) { return o1.getKey().compareTo(o2.getKey()); } }); for (Map.Entry<Pair<Integer, Integer>, Map<String, String>> entry : sortedEntries) { Pair<Integer, Integer> coords = entry.getKey(); Map<String, String> attrs = entry.getValue(); DeliveredStrainWell s = INSTANCE.insert(db, p.getId(), coords.getLeft(), coords.getRight(), attrs.get("well"), attrs.get("msid"), attrs.get("composition")); results.add(s); } return results; }
From source file:com.epam.ngb.cli.manager.command.handler.http.FileRegistrationHandler.java
private RegistrationRequest createRegistrationRequest(Pair<String, String> file, BiologicalDataItemFormat format) { RegistrationRequest registration = new RegistrationRequest(); registration.setName(fileName);//from ww w. j a va2s .com registration.setPrettyName(prettyName); registration.setPath(file.getLeft()); registration.setIndexPath(file.getRight()); registration.setReferenceId(referenceId); registration.setType(BiologicalDataItemResourceType.getTypeFromPath(file.getKey())); if (file.getValue() != null) { registration.setIndexType(BiologicalDataItemResourceType.getTypeFromPath(file.getValue())); } if (format == BiologicalDataItemFormat.VCF || format == BiologicalDataItemFormat.GENE) { registration.setDoIndex(doIndex); } return registration; }
From source file:at.gridtec.lambda4j.consumer.bi.ThrowableBiConsumer.java
/** * Applies this consumer to the given tuple. * * @param tuple The tuple to be applied to the consumer * @throws NullPointerException If given argument is {@code null} * @throws X Any throwable from this consumers action * @see org.apache.commons.lang3.tuple.Pair *///from ww w. java 2 s . co m default void acceptThrows(@Nonnull Pair<T, U> tuple) throws X { Objects.requireNonNull(tuple); acceptThrows(tuple.getLeft(), tuple.getRight()); }
From source file:com.spotify.heroic.shell.task.DeleteKeys.java
private AsyncFuture<Void> doDelete(final ShellIO io, final Parameters params, final MetricBackendGroup group, final QueryOptions options, final Stream<BackendKey> keys) { final StreamCollector<Pair<BackendKey, Long>, Void> collector = new StreamCollector<Pair<BackendKey, Long>, Void>() { @Override//from ww w .j a v a 2s .co m public void resolved(Pair<BackendKey, Long> result) throws Exception { if (params.verbose) { synchronized (io) { io.out().println("Deleted: " + result.getLeft() + " (" + result.getRight() + ")"); io.out().flush(); } } } @Override public void failed(Throwable cause) throws Exception { synchronized (io) { io.out().println("Delete Failed: " + cause); cause.printStackTrace(io.out()); io.out().flush(); } } @Override public void cancelled() throws Exception { } @Override public Void end(int resolved, int failed, int cancelled) throws Exception { io.out().println("Finished (resolved: " + resolved + ", failed: " + failed + ", " + "cancelled: " + cancelled + ")"); io.out().flush(); return null; } }; final AtomicInteger outstanding = new AtomicInteger(params.parallelism); final Object lock = new Object(); final ResolvableFuture<Void> future = async.future(); final Iterator<BackendKey> it = keys.iterator(); for (int i = 0; i < params.parallelism; i++) { async.call(new Callable<Void>() { @Override public Void call() throws Exception { final BackendKey k; synchronized (lock) { k = it.hasNext() ? it.next() : null; } if (k == null) { if (outstanding.decrementAndGet() == 0) { future.resolve(null); } return null; } deleteKey(group, k, options).onDone(new FutureDone<Pair<BackendKey, Long>>() { @Override public void failed(Throwable cause) throws Exception { collector.failed(cause); } @Override public void resolved(Pair<BackendKey, Long> result) throws Exception { collector.resolved(result); } @Override public void cancelled() throws Exception { collector.cancelled(); } }).onFinished(this::call); return null; } }); } return future.onFinished(keys::close); }
From source file:io.lavagna.service.ProjectServiceTest.java
@Test public void testFindBoardsByUserActivityWithPermissionsOnTest() { Pair<Project, User> prep = prepareOneActivity(); List<ProjectWithEventCounts> projects = projectService.findProjectsActivityByUserInProjects( prep.getRight().getId(), Arrays.asList(prep.getLeft().getId())); Assert.assertEquals(1, projects.size()); }
From source file:enterprises.orbital.evekit.model.corporation.sync.ESICorporationIndustryJobSync.java
@Override protected ESIAccountServerResult<List<GetCorporationsCorporationIdIndustryJobs200Ok>> getServerData( ESIAccountClientProvider cp) throws ApiException, IOException { IndustryApi apiInstance = cp.getIndustryApi(); Pair<Long, List<GetCorporationsCorporationIdIndustryJobs200Ok>> result = pagedResultRetriever((page) -> { ESIThrottle.throttle(endpoint().name(), account); return apiInstance.getCorporationsCorporationIdIndustryJobsWithHttpInfo( (int) account.getEveCorporationID(), null, null, true, page, accessToken()); });/*from ww w. java2 s .c o m*/ return new ESIAccountServerResult<>( result.getLeft() > 0 ? result.getLeft() : OrbitalProperties.getCurrentTime() + maxDelay(), result.getRight()); }
From source file:name.martingeisse.phunky.runtime.code.expression.array.ArrayElementExpression.java
@Override public AssignmentTarget resolveAssignmentTarget(Environment environment) { Pair<Variable, String> variableArrayAndKey = obtainArrayVariableAndKey(environment); if (variableArrayAndKey == null) { environment.getRuntime().triggerError("trying to get element of non-array value", getLocation()); return null; } else {/* ww w. java 2 s . c o m*/ Variable arrayVariable = variableArrayAndKey.getLeft(); String key = variableArrayAndKey.getRight(); return new ArrayElementAssignmentTarget(array, key); } }
From source file:com.mtbs3d.minecrift.control.GuiScreenNaviator.java
public void left() { onSlot = false;//w w w .ja v a 2 s . co m parsePoints(); if (curPoint != null) { Pair<Integer, Integer> nextBest = null; for (Pair<Integer, Integer> point : points) { if (point.getLeft() < curPoint.getLeft()) { if (nextBest == null || dist(nextBest, curPoint, 1, AXIS_PREFERENCE) > dist(point, curPoint, 1, AXIS_PREFERENCE)) nextBest = point; } } if (nextBest != null) { mc.currentScreen.mouseGuiDrag(curPoint.getLeft(), curPoint.getRight()); curPoint = nextBest; mouseto(); } } }
From source file:com.mtbs3d.minecrift.control.GuiScreenNaviator.java
public void right() { onSlot = false;/*from www .j a v a 2 s .co m*/ parsePoints(); if (curPoint != null) { Pair<Integer, Integer> nextBest = null; for (Pair<Integer, Integer> point : points) { if (point.getLeft() > curPoint.getLeft()) { if (nextBest == null || dist(nextBest, curPoint, 1, AXIS_PREFERENCE) > dist(point, curPoint, 1, AXIS_PREFERENCE)) nextBest = point; } } if (nextBest != null) { mc.currentScreen.mouseGuiDrag(curPoint.getLeft(), curPoint.getRight()); curPoint = nextBest; mouseto(); } } }
From source file:edu.sabanciuniv.sentilab.sare.models.setcover.DocumentSetCover.java
/** * Adjusts the coverage of the set cover. * @param weightCoverage the desired minimum weight coverage. * @return the {@code this} object./*from w w w.j a v a2 s . c om*/ */ public DocumentSetCover adjustCoverage(double weightCoverage) { // a quick way of checking if the weight coverage is valid or not. the setter will throw an exception if not. new SetCoverFactory().setWeightCoverage(weightCoverage); // apply the weight ratio. Pair<List<SetCoverDocument>, List<SetCoverDocument>> coverageSplit = this.splitByCoverage(weightCoverage); // mark covered and uncovered. for (SetCoverDocument document : coverageSplit.getLeft()) { document.setCovered(true); } for (SetCoverDocument document : coverageSplit.getRight()) { document.setCovered(false); } return this.setWeightCoverage(weightCoverage); }