Example usage for org.apache.commons.lang3.tuple Triple of

List of usage examples for org.apache.commons.lang3.tuple Triple of

Introduction

In this page you can find the example usage for org.apache.commons.lang3.tuple Triple of.

Prototype

public static <L, M, R> Triple<L, M, R> of(final L left, final M middle, final R right) 

Source Link

Document

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.

Usage

From source file:de.pixida.logtest.designer.testrun.TestRunEditor.java

public void createLogFileSourceInputItems(final List<Triple<String, Node, String>> formItems) {
    final TextField logFilePath = new TextField();
    this.logFilePathProperty.bind(logFilePath.textProperty());
    HBox.setHgrow(logFilePath, Priority.ALWAYS);
    final Button selectLogFileButton = SelectFileButton.createButtonWithFileSelection(logFilePath,
            LogReaderEditor.LOG_FILE_ICON_NAME, "Select log file", null, null);
    final HBox fileInputConfig = new HBox(logFilePath, selectLogFileButton);
    final VBox lines = new VBox();
    final double spacingOfLines = 5d;
    lines.setSpacing(spacingOfLines);//from w  w w  .  ja  v a 2 s  . c o m
    final HBox inputTypeLine = new HBox();
    final double hSpacingOfInputTypeChoices = 30d;
    inputTypeLine.setSpacing(hSpacingOfInputTypeChoices);
    final ToggleGroup group = new ToggleGroup();
    final RadioButton inputTypeText = new RadioButton("Paste/Enter log");
    inputTypeText.setToggleGroup(group);
    this.loadLogFromEnteredTextProperty.bind(inputTypeText.selectedProperty());
    final RadioButton inputTypeFile = new RadioButton("Read log file");
    inputTypeFile.setToggleGroup(group);
    this.loadLogFromFileProperty.bind(inputTypeFile.selectedProperty());
    inputTypeFile.setSelected(true);
    inputTypeLine.getChildren().add(inputTypeText);
    inputTypeLine.getChildren().add(inputTypeFile);
    fileInputConfig.visibleProperty().bind(inputTypeFile.selectedProperty());
    fileInputConfig.managedProperty().bind(fileInputConfig.visibleProperty());
    final TextArea logInputText = new TextArea();
    HBox.setHgrow(logInputText, Priority.ALWAYS);
    final int numLinesForEnteringLogInputManually = 10;
    logInputText.setPrefRowCount(numLinesForEnteringLogInputManually);
    logInputText.setStyle("-fx-font-family: monospace");
    this.enteredLogTextProperty.bind(logInputText.textProperty());
    final HBox enterTextConfig = new HBox();
    enterTextConfig.getChildren().add(logInputText);
    enterTextConfig.visibleProperty().bind(inputTypeText.selectedProperty());
    enterTextConfig.managedProperty().bind(enterTextConfig.visibleProperty());
    lines.getChildren().addAll(inputTypeLine, fileInputConfig, enterTextConfig);
    formItems.add(Triple.of("Trace Log", lines, null));
}

From source file:de.pixida.logtest.designer.logreader.LogReaderEditor.java

public void createInputForHandlingOfNonHeadlineLines(final List<Triple<String, Node, String>> formItems) {
    final Map<HandlingOfNonHeadlineLines, String> mapValueToChoice = new HashMap<>();
    mapValueToChoice.put(HandlingOfNonHeadlineLines.FAIL,
            "Abort - Each line in the log file is assumed to be a log entry");
    mapValueToChoice.put(HandlingOfNonHeadlineLines.CREATE_MULTILINE_ENTRY,
            "Append to payload - This will create multiline payloads");
    mapValueToChoice.put(HandlingOfNonHeadlineLines.ASSUME_LAST_TIMESTAMP,
            "Create new log entry and use timestamp of recent log entry");
    mapValueToChoice.put(HandlingOfNonHeadlineLines.ASSUME_LAST_TIMESTAMP_AND_CHANNEL,
            "Create new log entry and use timestamp and channel of recent log entry");
    final ChoiceBox<HandlingOfNonHeadlineLines> handlingOfNonHeadlineLinesInput = new ChoiceBox<>(
            FXCollections.observableArrayList(HandlingOfNonHeadlineLines.values()));
    handlingOfNonHeadlineLinesInput.setConverter(new StringConverter<HandlingOfNonHeadlineLines>() {
        @Override//  ww  w .j  a  va 2  s.  co m
        public String toString(final HandlingOfNonHeadlineLines object) {
            return mapValueToChoice.get(object);
        }

        @Override
        public HandlingOfNonHeadlineLines fromString(final String string) {
            for (final Entry<HandlingOfNonHeadlineLines, String> entry : mapValueToChoice.entrySet()) {
                if (entry.getValue() == string) // Intentionally comparing references to obtain a bijection
                {
                    return entry.getKey();
                }
            }
            return null; // Should never happen
        }
    });
    handlingOfNonHeadlineLinesInput.getSelectionModel().select(this.logReader.getHandlingOfNonHeadlineLines());
    handlingOfNonHeadlineLinesInput.getSelectionModel().selectedIndexProperty()
            .addListener((ChangeListener<Number>) (observable, oldValue, newValue) -> {
                this.logReader.setHandlingOfNonHeadlineLines(
                        handlingOfNonHeadlineLinesInput.getItems().get(newValue.intValue()));
                this.setChanged(true);
            });
    formItems.add(Triple.of("Dangling Lines", handlingOfNonHeadlineLinesInput,
            "Define what to do if dangling lines are spotted. Dangling lines are lines which do not match the headline pattern, i.e."
                    + " which do not introduce a new log entry."));
}

From source file:alfio.manager.AdminReservationManagerIntegrationTest.java

private Triple<Event, String, TicketReservation> performExistingCategoryTest(
        List<TicketCategoryModification> categories, boolean bounded, List<Integer> attendeesNr,
        boolean addSeatsIfNotAvailable, boolean expectSuccess, int reservedTickets, int expectedEventSeats) {
    assertEquals("Test error: categories' size must be equal to attendees' size", categories.size(),
            attendeesNr.size());//ww w . j  a  v a2  s.  co m
    Pair<Event, String> eventWithUsername = initEvent(categories, organizationRepository, userManager,
            eventManager, eventRepository);
    Event event = eventWithUsername.getKey();
    String username = eventWithUsername.getValue();
    DateTimeModification expiration = DateTimeModification.fromZonedDateTime(ZonedDateTime.now().plusDays(1));
    CustomerData customerData = new CustomerData("Integration", "Test", "integration-test@test.ch",
            "Billing Address", "en");
    Iterator<Integer> attendeesIterator = attendeesNr.iterator();
    List<TicketCategory> existingCategories = ticketCategoryRepository.findByEventId(event.getId());
    List<Attendee> allAttendees = new ArrayList<>();
    List<TicketsInfo> ticketsInfoList = existingCategories.stream().map(existingCategory -> {
        Category category = new Category(existingCategory.getId(), existingCategory.getName(),
                existingCategory.getPrice());
        List<Attendee> attendees = generateAttendees(attendeesIterator.next());
        allAttendees.addAll(attendees);
        return new TicketsInfo(category, attendees, addSeatsIfNotAvailable, false);
    }).collect(toList());
    AdminReservationModification modification = new AdminReservationModification(expiration, customerData,
            ticketsInfoList, "en", false, null);

    if (reservedTickets > 0) {
        TicketReservationModification trm = new TicketReservationModification();
        trm.setAmount(reservedTickets);
        trm.setTicketCategoryId(existingCategories.get(0).getId());
        TicketReservationWithOptionalCodeModification r = new TicketReservationWithOptionalCodeModification(trm,
                Optional.empty());
        ticketReservationManager.createTicketReservation(event, Collections.singletonList(r),
                Collections.emptyList(), DateUtils.addDays(new Date(), 1), Optional.empty(), Optional.empty(),
                Locale.ENGLISH, false);
    }

    Result<Pair<TicketReservation, List<Ticket>>> result = adminReservationManager
            .createReservation(modification, event.getShortName(), username);
    if (expectSuccess) {
        validateSuccess(bounded, attendeesNr, event, username, existingCategories, result, allAttendees,
                expectedEventSeats, reservedTickets);
    } else {
        assertFalse(result.isSuccess());
        return null;
    }
    return Triple.of(eventWithUsername.getLeft(), eventWithUsername.getRight(), result.getData().getKey());
}

From source file:de.tu_dortmund.ub.data.dswarm.TaskProcessingUnit.java

private static void doInit(final String resourceWatchFolder, final String initResourceFileName,
        final String serviceName, final Integer engineThreads, final Properties config,
        final Map<String, Triple<String, String, String>> inputDataModelsAndResources) throws Exception {

    final JsonObject initResultJSON = TPUUtil.doInit(resourceWatchFolder, initResourceFileName, serviceName,
            engineThreads, config, 0);/*w  w w.j ava2  s.c o  m*/

    final String inputDataModelID = initResultJSON.getString(Init.DATA_MODEL_ID);
    final String resourceID = initResultJSON.getString(Init.RESOURCE_ID);
    final String configurationID = initResultJSON.getString(Init.CONFIGURATION_ID);

    inputDataModelsAndResources.put(inputDataModelID, Triple.of(inputDataModelID, resourceID, configurationID));
}

From source file:com.act.lcms.db.analysis.IonDetectionAnalysis.java

/**
 * This function does the SNR analysis for each positive well and constructs plots for each mass charge for each
 * positive well run//from   ww  w  .j  a  va2  s .c  o  m
 * @return A map of positive well to map of chem id to plotting file path to pair of max intensity, time and SNR.
 * @throws Exception
 */
public Map<T, Map<String, Triple<String, XZ, Double>>> getSnrAndPlotResultsForMassChargesForEachPositiveWell()
        throws Exception {

    // Get signal profiles for each positive and negative wells once. This is the rate limiting step of the computation.
    Map<ScanData.KIND, List<Pair<T, ChemicalToMapOfMetlinIonsToIntensityTimeValues>>> designUnitToListOfWellIntensityTimeValues = getIntensityTimeValuesForMassChargesInPositiveAndNegativeWells();

    // This is the object the final results are stored in.
    Map<T, Map<String, Triple<String, XZ, Double>>> positiveWellToMapOfChemicalToSNRResults = new HashMap<>();

    List<Pair<T, ChemicalToMapOfMetlinIonsToIntensityTimeValues>> positiveWellResults = designUnitToListOfWellIntensityTimeValues
            .get(ScanData.KIND.POS_SAMPLE);

    List<ChemicalToMapOfMetlinIonsToIntensityTimeValues> negativeWellsSignalProfiles = designUnitToListOfWellIntensityTimeValues
            .get(ScanData.KIND.NEG_CONTROL).stream().map(pair -> pair.getRight()).collect(Collectors.toList());

    for (Pair<T, ChemicalToMapOfMetlinIonsToIntensityTimeValues> value : positiveWellResults) {
        T positiveWell = value.getLeft();
        ChemicalToMapOfMetlinIonsToIntensityTimeValues positiveWellSignalProfile = value.getRight();

        Map<String, Pair<XZ, Double>> snrResults = WaveformAnalysis
                .performSNRAnalysisAndReturnMetlinIonsRankOrderedBySNRForWells(positiveWellSignalProfile,
                        negativeWellsSignalProfiles, setOfMassCharges);

        List<T> positiveWellAndNegativeWells = new ArrayList<>();
        positiveWellAndNegativeWells.add(positiveWell);
        positiveWellAndNegativeWells.addAll(negativeWells);

        // This variable is used as a part of the file path dir to uniquely identify the pos/neg wells for the chemical.
        StringBuilder indexedPath = new StringBuilder();
        for (T well : positiveWellAndNegativeWells) {
            indexedPath.append(Integer.toString(well.getId()) + "-");
        }

        Map<String, String> plottingFileMappings = ChemicalToMapOfMetlinIonsToIntensityTimeValues
                .plotPositiveAndNegativeControlsForEachMZ(setOfMassCharges, indexedPath.toString(),
                        positiveWellSignalProfile, negativeWellsSignalProfiles, plottingDirPath);

        Map<String, Triple<String, XZ, Double>> mzToPlotDirAndSNR = new HashMap<>();
        for (Map.Entry<String, Pair<XZ, Double>> entry : snrResults.entrySet()) {
            String plottingPath = plottingFileMappings.get(entry.getKey());
            XZ snr = entry.getValue().getLeft();

            if (plottingDirPath == null || snr == null) {
                throw new RuntimeException("Plotting directory or snr is null");
            }

            mzToPlotDirAndSNR.put(entry.getKey(),
                    Triple.of(plottingPath, entry.getValue().getLeft(), entry.getValue().getRight()));
        }

        positiveWellToMapOfChemicalToSNRResults.put(positiveWell, mzToPlotDirAndSNR);
    }

    return positiveWellToMapOfChemicalToSNRResults;
}

From source file:at.gridtec.lambda4j.function.tri.to.ToIntTriFunction.java

/**
 * Returns a memoized (caching) version of this {@link ToIntTriFunction}. Whenever it is called, the mapping between
 * the input parameters and the return value is preserved in a cache, making subsequent calls returning the memoized
 * value instead of computing the return value again.
 * <p>/*from  w w w. j  a  va2s .com*/
 * Unless the function and therefore the used cache will be garbage-collected, it will keep all memoized values
 * forever.
 *
 * @return A memoized (caching) version of this {@code ToIntTriFunction}.
 * @implSpec This implementation does not allow the input parameters or return value to be {@code null} for the
 * resulting memoized function, as the cache used internally does not permit {@code null} keys or values.
 * @implNote The returned memoized function can be safely used concurrently from multiple threads which makes it
 * thread-safe.
 */
@Nonnull
default ToIntTriFunction<T, U, V> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, U, V>, Integer> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (ToIntTriFunction<T, U, V> & Memoized) (t, u, v) -> {
            final int returnValue;
            synchronized (lock) {
                returnValue = cache.computeIfAbsent(Triple.of(t, u, v),
                        key -> applyAsInt(key.getLeft(), key.getMiddle(), key.getRight()));
            }
            return returnValue;
        };
    }
}

From source file:at.gridtec.lambda4j.function.tri.to.ToLongTriFunction.java

/**
 * Returns a memoized (caching) version of this {@link ToLongTriFunction}. Whenever it is called, the mapping
 * between the input parameters and the return value is preserved in a cache, making subsequent calls returning the
 * memoized value instead of computing the return value again.
 * <p>// w ww  . j a va  2s.  com
 * Unless the function and therefore the used cache will be garbage-collected, it will keep all memoized values
 * forever.
 *
 * @return A memoized (caching) version of this {@code ToLongTriFunction}.
 * @implSpec This implementation does not allow the input parameters or return value to be {@code null} for the
 * resulting memoized function, as the cache used internally does not permit {@code null} keys or values.
 * @implNote The returned memoized function can be safely used concurrently from multiple threads which makes it
 * thread-safe.
 */
@Nonnull
default ToLongTriFunction<T, U, V> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, U, V>, Long> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (ToLongTriFunction<T, U, V> & Memoized) (t, u, v) -> {
            final long returnValue;
            synchronized (lock) {
                returnValue = cache.computeIfAbsent(Triple.of(t, u, v),
                        key -> applyAsLong(key.getLeft(), key.getMiddle(), key.getRight()));
            }
            return returnValue;
        };
    }
}

From source file:at.gridtec.lambda4j.function.tri.to.ToByteTriFunction.java

/**
 * Returns a memoized (caching) version of this {@link ToByteTriFunction}. Whenever it is called, the mapping
 * between the input parameters and the return value is preserved in a cache, making subsequent calls returning the
 * memoized value instead of computing the return value again.
 * <p>/*  w  w  w.  j  a  v a 2s . c  o m*/
 * Unless the function and therefore the used cache will be garbage-collected, it will keep all memoized values
 * forever.
 *
 * @return A memoized (caching) version of this {@code ToByteTriFunction}.
 * @implSpec This implementation does not allow the input parameters or return value to be {@code null} for the
 * resulting memoized function, as the cache used internally does not permit {@code null} keys or values.
 * @implNote The returned memoized function can be safely used concurrently from multiple threads which makes it
 * thread-safe.
 */
@Nonnull
default ToByteTriFunction<T, U, V> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, U, V>, Byte> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (ToByteTriFunction<T, U, V> & Memoized) (t, u, v) -> {
            final byte returnValue;
            synchronized (lock) {
                returnValue = cache.computeIfAbsent(Triple.of(t, u, v),
                        key -> applyAsByte(key.getLeft(), key.getMiddle(), key.getRight()));
            }
            return returnValue;
        };
    }
}

From source file:at.gridtec.lambda4j.function.tri.to.ToCharTriFunction.java

/**
 * Returns a memoized (caching) version of this {@link ToCharTriFunction}. Whenever it is called, the mapping
 * between the input parameters and the return value is preserved in a cache, making subsequent calls returning the
 * memoized value instead of computing the return value again.
 * <p>// w ww .  j ava 2  s .c o m
 * Unless the function and therefore the used cache will be garbage-collected, it will keep all memoized values
 * forever.
 *
 * @return A memoized (caching) version of this {@code ToCharTriFunction}.
 * @implSpec This implementation does not allow the input parameters or return value to be {@code null} for the
 * resulting memoized function, as the cache used internally does not permit {@code null} keys or values.
 * @implNote The returned memoized function can be safely used concurrently from multiple threads which makes it
 * thread-safe.
 */
@Nonnull
default ToCharTriFunction<T, U, V> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, U, V>, Character> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (ToCharTriFunction<T, U, V> & Memoized) (t, u, v) -> {
            final char returnValue;
            synchronized (lock) {
                returnValue = cache.computeIfAbsent(Triple.of(t, u, v),
                        key -> applyAsChar(key.getLeft(), key.getMiddle(), key.getRight()));
            }
            return returnValue;
        };
    }
}

From source file:at.gridtec.lambda4j.function.tri.to.ToFloatTriFunction.java

/**
 * Returns a memoized (caching) version of this {@link ToFloatTriFunction}. Whenever it is called, the mapping
 * between the input parameters and the return value is preserved in a cache, making subsequent calls returning the
 * memoized value instead of computing the return value again.
 * <p>/*from w  w  w  . j  a  v a  2 s .  co m*/
 * Unless the function and therefore the used cache will be garbage-collected, it will keep all memoized values
 * forever.
 *
 * @return A memoized (caching) version of this {@code ToFloatTriFunction}.
 * @implSpec This implementation does not allow the input parameters or return value to be {@code null} for the
 * resulting memoized function, as the cache used internally does not permit {@code null} keys or values.
 * @implNote The returned memoized function can be safely used concurrently from multiple threads which makes it
 * thread-safe.
 */
@Nonnull
default ToFloatTriFunction<T, U, V> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, U, V>, Float> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (ToFloatTriFunction<T, U, V> & Memoized) (t, u, v) -> {
            final float returnValue;
            synchronized (lock) {
                returnValue = cache.computeIfAbsent(Triple.of(t, u, v),
                        key -> applyAsFloat(key.getLeft(), key.getMiddle(), key.getRight()));
            }
            return returnValue;
        };
    }
}