List of usage examples for org.apache.commons.lang3.tuple Triple of
public static <L, M, R> Triple<L, M, R> of(final L left, final M middle, final R right)
Obtains an immutable triple of from three objects inferring the generic types.
This factory allows the triple to be created using inference to obtain the generic types.
From source file:cherry.foundation.bizcal.WorkdayManagerImpl.java
@Override public int getNumberOfWorkday(String name, LocalDate from, LocalDate to) { try {//from w ww .j a va 2 s . c o m return numberOfWorkdayCache.get(Triple.of(name, from, to)); } catch (ExecutionException ex) { throw new IllegalStateException(ex); } }
From source file:com.netflix.genie.agent.execution.statemachine.StateMachineConfig.java
@Bean @Lazy//from w ww .j ava2 s.c o m Collection<Triple<States, Events, States>> eventDrivenTransitions() { return Arrays.asList( // Regular execution Triple.of(States.READY, Events.START, States.INITIALIZE), Triple.of(States.INITIALIZE, Events.INITIALIZE_COMPLETE, States.CONFIGURE_AGENT), Triple.of(States.CONFIGURE_AGENT, Events.CONFIGURE_AGENT_COMPLETE, States.RESOLVE_JOB_SPECIFICATION), Triple.of(States.RESOLVE_JOB_SPECIFICATION, Events.RESOLVE_JOB_SPECIFICATION_COMPLETE, States.SETUP_JOB), Triple.of(States.SETUP_JOB, Events.SETUP_JOB_COMPLETE, States.LAUNCH_JOB), Triple.of(States.LAUNCH_JOB, Events.LAUNCH_JOB_COMPLETE, States.MONITOR_JOB), Triple.of(States.MONITOR_JOB, Events.MONITOR_JOB_COMPLETE, States.CLEANUP_JOB), Triple.of(States.CLEANUP_JOB, Events.CLEANUP_JOB_COMPLETE, States.SHUTDOWN), Triple.of(States.SHUTDOWN, Events.SHUTDOWN_COMPLETE, States.END), // Job cancellation Triple.of(States.READY, Events.CANCEL_JOB_LAUNCH, States.CLEANUP_JOB), Triple.of(States.INITIALIZE, Events.CANCEL_JOB_LAUNCH, States.CLEANUP_JOB), Triple.of(States.CONFIGURE_AGENT, Events.CANCEL_JOB_LAUNCH, States.CLEANUP_JOB), Triple.of(States.RESOLVE_JOB_SPECIFICATION, Events.CANCEL_JOB_LAUNCH, States.CLEANUP_JOB), Triple.of(States.SETUP_JOB, Events.CANCEL_JOB_LAUNCH, States.CLEANUP_JOB)); }
From source file:com.act.lcms.ExtractFromNetCDFAroundMass.java
/** * Extracts a window around a particular m/z value within the spectra * @param file The netCDF file with the full LCMS (lockmass corrected) spectra * @param mz The m/z value +- 1 around which to extract data for * @param numTimepointsToExamine Since we stream the netCDF in, we can choose * to look at the first few timepoints or -1 for all *//*from w w w . j av a2 s.c om*/ public List<Triple<Double, Double, Double>> get2DWindow(String file, double mz, int numTimepointsToExamine) throws Exception { LCMSParser parser = new LCMSNetCDFParser(); Iterator<LCMSSpectrum> iter = parser.getIterator(file); List<Triple<Double, Double, Double>> window = new ArrayList<>(); int pulled = 0; Double mzTightL = mz - 0.1; Double mzTightR = mz + 0.1; Double mzMinus1Da = mz - 1; Double mzPlus1Da = mz + 1; // iterate through first few, or all if -1 given while (iter.hasNext() && (numTimepointsToExamine == -1 || pulled < numTimepointsToExamine)) { LCMSSpectrum timepoint = iter.next(); List<Pair<Double, Double>> intensities = timepoint.getIntensities(); // this time point is valid to look at if its max intensity is around // the mass we care about. So lets first get the max peak location Pair<Double, Double> max_peak = findMaxPeak(intensities); Double max_mz = max_peak.getLeft(); // If the max_mz value is pretty close to our target mass, ie in [mzTightL, mzTightR] // Then this timepoint is a good timepoint to output... proceed, shall we. if (max_mz >= mzTightL && max_mz <= mzTightR) { // For this timepoint, output a window for (int k = 0; k < intensities.size(); k++) { Double mz_here = intensities.get(k).getLeft(); Double intensity = intensities.get(k).getRight(); // The window not as tight, but +-1 Da around the target mass if (mz_here > mzMinus1Da && mz_here < mzPlus1Da) { window.add(Triple.of(timepoint.getTimeVal(), mz_here, intensity)); } } } pulled++; } return window; }
From source file:edu.umd.umiacs.clip.tools.classifier.ConfusionMatrix.java
public Triple<Float, Float, Float> getF1withCI() { double n[] = new double[] { FN + TN, TP + FP }; double r[] = new double[] { FN, TP }; double N[] = range(0, 2).mapToDouble(i -> n[i] * N_TOTAL / (n[0] + n[1])).toArray(); double R[] = range(0, 2).mapToDouble(i -> r[i] * N_TOTAL / (n[0] + n[1])).toArray(); double Var_R[] = range(0, 2) .mapToDouble(i -> Math.pow(N[i], 2) * r[i] * (1 - r[i] / n[i]) / Math.pow(n[i], 2)).toArray(); double temp = 2 * R[1] / Math.pow(R[1] + R[0] + N[1], 2); double Var_F1_1 = Math.pow(2 / (R[1] + R[0] + N[1]) - temp, 2); double Var_F1_0 = Math.pow(temp, 2); double Var_F1 = Var_F1_1 * Var_R[1] + Var_F1_0 * Var_R[0]; float pe = getF1(); float delta = (float) (1.96 * Math.sqrt(Var_F1)); return Triple.of(pe - delta, pe, pe + delta); }
From source file:com.netflix.genie.agent.execution.ExecutionContextImpl.java
/** * {@inheritDoc}//from w w w. ja v a 2 s .co m */ @Override public void addStateActionError(final States state, final Class<? extends Action> actionClass, final Exception exception) { synchronized (stateActionErrors) { stateActionErrors.add(Triple.of(state, actionClass, exception)); } }
From source file:com.nttec.everychan.ui.tabs.TabsTrackerService.java
/** , ? ? ? ( ) */ public static void addSubscriptionNotification(String tabUrl, String postNumber, String tabTitle) { List<Triple<String, String, String>> list = subscriptionsData; if (list == null) list = new ArrayList<>(); int index = findTab(list, tabUrl, tabTitle); if (index == -1) { String postUrl = tabUrl;//from w w w .j av a 2 s . c o m try { UrlPageModel pageModel = UrlHandler.getPageModel(tabUrl); if (pageModel != null) { pageModel.postNumber = postNumber; postUrl = MainApplication.getInstance().getChanModule(pageModel.chanName).buildUrl(pageModel); } } catch (Exception e) { Logger.e(TAG, e); } list.add(Triple.of(tabUrl, postUrl, tabTitle)); } else { String postUrl = list.get(index).getMiddle(); list.set(index, Triple.of(tabUrl, postUrl, tabTitle)); } subscriptionsData = list; subscriptions = true; }
From source file:net.malisis.blocks.vanishingoption.VanishingOptionsGui.java
@Override public void construct() { UIWindow window = new UIWindow(this, "gui.vanishingoptions.title", 200, 220); window.add(new UILabel(this, "Direction").setPosition(0, 20)); window.add(new UILabel(this, "Delay").setPosition(55, 20)); window.add(new UILabel(this, "Inversed").setPosition(90, 20)); int i = 0;/*from w w w . ja v a 2 s.c om*/ for (EnumFacing dir : EnumFacing.VALUES) { DirectionState state = vanishingOptions.getDirectionState(dir); int y = i * 14 + 30; UICheckBox cb = new UICheckBox(this, dir.name()); cb.setPosition(2, y).setChecked(state.shouldPropagate).register(this); cb.attachData(Pair.of(dir, DataType.PROPAGATION)); UITextField textField = new UITextField(this, "" + state.delay).setSize(27, 0).setPosition(55, y) .setDisabled(!state.shouldPropagate).register(this); textField.attachData(Pair.of(dir, DataType.DELAY)); UICheckBox invCb = new UICheckBox(this).setPosition(105, y).setDisabled(!state.shouldPropagate) .setChecked(state.inversed).register(this); invCb.attachData(Pair.of(dir, DataType.INVERSED)); window.add(cb); window.add(textField); window.add(invCb); configs.put(dir, Triple.of(cb, textField, invCb)); i++; } UIContainer cont = new UIContainer<UIContainer>(this, 50, 60).setPosition(0, 40, Anchor.RIGHT); duration = new UITextField(this, "" + vanishingOptions.getDuration()).setSize(30, 0) .setPosition(0, 10, Anchor.CENTER).register(this); duration.attachData(Pair.of(null, DataType.DURATION)); cont.add(new UILabel(this, "Duration").setPosition(0, 0, Anchor.CENTER)); cont.add(duration); UIInventory inv = new UIInventory(this, inventoryContainer.getInventory(1)); inv.setPosition(0, 40, Anchor.CENTER); cont.add(new UILabel(this, "Block").setPosition(0, 30, Anchor.CENTER)); cont.add(inv); window.add(cont); UIPlayerInventory playerInv = new UIPlayerInventory(this, inventoryContainer.getPlayerInventory()); window.add(playerInv); addToScreen(window); if (tileEntity != null) TileEntityUtils.linkTileEntityToGui(tileEntity, this); }
From source file:gobblin.ingestion.google.webmaster.UrlTriePrefixGrouperTest.java
@Test public void testGroupToPagesWithContainsOperator() { List<String> pages = Arrays.asList(_property + "13", _property + "14"); UrlTrie trie = new UrlTrie(_property, pages); ArrayList<String> actual = UrlTriePrefixGrouper .groupToPages(Triple.of(_property, FilterOperator.CONTAINS, trie.getRoot())); Assert.assertEquals(actual.toArray(), pages.toArray()); }
From source file:com.quartercode.jtimber.rh.agent.asm.InsertJAXBTweaksClassAdapter.java
@Override public FieldVisitor visitField(int access, final String name, String desc, String signature, Object value) { fields.put(name, Type.getType(desc)); // This annotation visitor expects "SubstituteWithWrapper" annotations, parses them and adds their data to the list "fieldsForWrapperSubstitution" final class AnnotationVisitorImpl extends AnnotationVisitor { private Type wrapperType; private Type wrapperConstructorArgType; private AnnotationVisitorImpl(AnnotationVisitor av) { super(ASM5, av); }/*from w w w . j av a 2s. c om*/ @Override public void visit(String name, Object value) { if (name.equals("value")) { wrapperType = (Type) value; } else if (name.equals("wrapperConstructorArg")) { wrapperConstructorArgType = (Type) value; if (wrapperConstructorArgType.equals(SWW_DEFAULT_CLASS)) { wrapperConstructorArgType = null; } } } @Override public void visitEnd() { fieldsForWrapperSubstitution.add(Triple.of(name, wrapperType, wrapperConstructorArgType)); } } // This field visitor just "invokes" the AnnotationVisitorImpl with each found "SubstituteWithWrapper" annotation final class FieldVisitorImpl extends FieldVisitor { private FieldVisitorImpl(FieldVisitor fv) { super(ASM5, fv); } @Override public AnnotationVisitor visitAnnotation(String desc, boolean visible) { AnnotationVisitor av = super.visitAnnotation(desc, visible); if (desc.equals(SWW_CLASS.getDescriptor()) && av != null) { av = new AnnotationVisitorImpl(av); } return av; } } // Return a FieldVisitorImpl FieldVisitor fv = super.visitField(access, name, desc, signature, value); if (fv != null) { fv = new FieldVisitorImpl(fv); } return fv; }
From source file:cherry.foundation.bizcal.WorkdayManagerImpl.java
@Override public LocalDate getNextWorkday(String name, LocalDate from, int numberOfWorkday) { try {/*from www .j a va 2s . com*/ return nextWorkdayCache.get(Triple.of(name, from, numberOfWorkday)); } catch (ExecutionException ex) { throw new IllegalStateException(ex); } }