List of usage examples for org.apache.commons.lang3.tuple Triple getRight
public abstract R getRight();
Gets the right element from this triple.
From source file:at.gridtec.lambda4j.consumer.tri.ThrowableTriConsumer.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.Triple *//*from ww w .j a v a2 s. c o m*/ default void acceptThrows(@Nonnull Triple<T, U, V> tuple) throws X { Objects.requireNonNull(tuple); acceptThrows(tuple.getLeft(), tuple.getMiddle(), tuple.getRight()); }
From source file:alfio.controller.api.admin.AdminReservationApiController.java
private TicketReservationDescriptor toReservationDescriptor(String reservationId, Triple<TicketReservation, List<Ticket>, Event> triple) { List<SerializablePair<TicketCategory, List<Ticket>>> tickets = triple.getMiddle().stream() .collect(Collectors.groupingBy(Ticket::getCategoryId)).entrySet().stream() .map(entry -> SerializablePair.of( eventManager.getTicketCategoryById(entry.getKey(), triple.getRight().getId()), entry.getValue()))// ww w . j a va2 s .c o m .collect(Collectors.toList()); TicketReservation reservation = triple.getLeft(); return new TicketReservationDescriptor(reservation, ticketReservationManager.orderSummaryForReservationId( reservationId, triple.getRight(), Locale.forLanguageTag(reservation.getUserLanguage())), tickets); }
From source file:at.gridtec.lambda4j.function.tri.to.ToByteTriFunction.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @see org.apache.commons.lang3.tuple.Triple *//*from w w w .ja va 2 s .c o m*/ default byte applyAsByte(@Nonnull Triple<T, U, V> tuple) { Objects.requireNonNull(tuple); return applyAsByte(tuple.getLeft(), tuple.getMiddle(), tuple.getRight()); }
From source file:at.gridtec.lambda4j.function.tri.to.ToCharTriFunction.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @see org.apache.commons.lang3.tuple.Triple *///from w ww . j a v a 2 s.c o m default char applyAsChar(@Nonnull Triple<T, U, V> tuple) { Objects.requireNonNull(tuple); return applyAsChar(tuple.getLeft(), tuple.getMiddle(), tuple.getRight()); }
From source file:at.gridtec.lambda4j.function.tri.to.ToIntTriFunction.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @see org.apache.commons.lang3.tuple.Triple */// w ww .java 2 s . co m default int applyAsInt(@Nonnull Triple<T, U, V> tuple) { Objects.requireNonNull(tuple); return applyAsInt(tuple.getLeft(), tuple.getMiddle(), tuple.getRight()); }
From source file:at.gridtec.lambda4j.function.tri.to.ToFloatTriFunction.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @see org.apache.commons.lang3.tuple.Triple *///from w w w . ja v a2 s . c o m default float applyAsFloat(@Nonnull Triple<T, U, V> tuple) { Objects.requireNonNull(tuple); return applyAsFloat(tuple.getLeft(), tuple.getMiddle(), tuple.getRight()); }
From source file:at.gridtec.lambda4j.function.tri.to.ToLongTriFunction.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @see org.apache.commons.lang3.tuple.Triple *//*from w ww .j a va 2 s. c om*/ default long applyAsLong(@Nonnull Triple<T, U, V> tuple) { Objects.requireNonNull(tuple); return applyAsLong(tuple.getLeft(), tuple.getMiddle(), tuple.getRight()); }
From source file:at.gridtec.lambda4j.function.tri.to.ToShortTriFunction.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @see org.apache.commons.lang3.tuple.Triple *//* w w w. java2s .co m*/ default short applyAsShort(@Nonnull Triple<T, U, V> tuple) { Objects.requireNonNull(tuple); return applyAsShort(tuple.getLeft(), tuple.getMiddle(), tuple.getRight()); }
From source file:at.gridtec.lambda4j.function.tri.to.ToDoubleTriFunction.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @see org.apache.commons.lang3.tuple.Triple */// www .j a va 2 s. co m default double applyAsDouble(@Nonnull Triple<T, U, V> tuple) { Objects.requireNonNull(tuple); return applyAsDouble(tuple.getLeft(), tuple.getMiddle(), tuple.getRight()); }
From source file:com.hurence.logisland.processor.elasticsearch.EnrichRecordsElasticsearch.java
/** * process events//from w w w .j a va2s .co m * * @param context * @param records * @return */ @Override public Collection<Record> process(final ProcessContext context, final Collection<Record> records) { if (records.size() == 0) { return Collections.emptyList(); } List<Triple<Record, String, IncludeFields>> recordsToEnrich = new ArrayList<>(); MultiGetQueryRecordBuilder mgqrBuilder = new MultiGetQueryRecordBuilder(); mgqrBuilder.excludeFields(excludesArray); for (Record record : records) { String recordKeyName = evaluatePropAsString(record, context, RECORD_KEY_FIELD); String indexName = evaluatePropAsString(record, context, ES_INDEX_FIELD); String typeName = evaluatePropAsString(record, context, ES_TYPE_FIELD); String includesFieldName = evaluatePropAsString(record, context, ES_INCLUDES_FIELD); if (recordKeyName != null && indexName != null && typeName != null) { try { // Includes : String[] includesArray = null; if ((includesFieldName != null) && (!includesFieldName.isEmpty())) { includesArray = includesFieldName.split("\\s*,\\s*"); } IncludeFields includeFields = new IncludeFields(includesArray); mgqrBuilder.add(indexName, typeName, includeFields.getAttrsToIncludeArray(), recordKeyName); recordsToEnrich.add(new ImmutableTriple(record, asUniqueKey(indexName, typeName, recordKeyName), includeFields)); } catch (Throwable t) { record.setStringField(FieldDictionary.RECORD_ERRORS, "Can not request ElasticSearch with " + indexName + " " + typeName + " " + recordKeyName); getLogger().error( "Can not request ElasticSearch with index: {}, type: {}, recordKey: {}, record id is :\n{}", new Object[] { indexName, typeName, recordKeyName, record.getId() }, t); } } else { getLogger().warn( "Can not request ElasticSearch with " + "index: {}, type: {}, recordKey: {}, record id is :\n{}", new Object[] { indexName, typeName, recordKeyName, record.getId() }); } } List<MultiGetResponseRecord> multiGetResponseRecords = null; try { List<MultiGetQueryRecord> mgqrs = mgqrBuilder.build(); if (mgqrs.isEmpty()) return records; multiGetResponseRecords = elasticsearchClientService.multiGet(mgqrs); } catch (InvalidMultiGetQueryRecordException e) { getLogger().error("error while multiGet elasticsearch", e); } if (multiGetResponseRecords == null || multiGetResponseRecords.isEmpty()) { return records; } // Transform the returned documents from ES in a Map Map<String, MultiGetResponseRecord> responses = multiGetResponseRecords.stream() .collect(Collectors.toMap(EnrichRecordsElasticsearch::asUniqueKey, Function.identity())); recordsToEnrich.forEach(recordToEnrich -> { Triple<Record, String, IncludeFields> triple = recordToEnrich; Record outputRecord = triple.getLeft(); String key = triple.getMiddle(); IncludeFields includeFields = triple.getRight(); MultiGetResponseRecord responseRecord = responses.get(key); if ((responseRecord != null) && (responseRecord.getRetrievedFields() != null)) { // Retrieve the fields from responseRecord that matches the ones in the recordToEnrich. responseRecord.getRetrievedFields().forEach((fieldName, v) -> { if (includeFields.includes(fieldName)) { // Now check if there is an attribute mapping rule to apply if (includeFields.hasMappingFor(fieldName)) { String mappedAttributeName = includeFields.getAttributeToMap(fieldName); // Replace the attribute name outputRecord.setStringField(mappedAttributeName, v); } else { outputRecord.setStringField(fieldName, v); } } }); } }); return records; }