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:at.gridtec.lambda4j.function.tri.obj.ObjBiFloatToDoubleFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiFloatToDoubleFunction}. 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>// ww w. j a v a 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 ObjBiFloatToDoubleFunction}. * @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 ObjBiFloatToDoubleFunction<T> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Float, Float>, Double> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiFloatToDoubleFunction<T> & Memoized) (t, value1, value2) -> { final double returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> applyAsDouble(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiShortToDoubleFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiShortToDoubleFunction}. 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 www.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 ObjBiShortToDoubleFunction}. * @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 ObjBiShortToDoubleFunction<T> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Short, Short>, Double> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiShortToDoubleFunction<T> & Memoized) (t, value1, value2) -> { final double returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> applyAsDouble(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiDoubleToDoubleFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiDoubleToDoubleFunction}. 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 ww .j a v a2s . 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 ObjBiDoubleToDoubleFunction}. * @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 ObjBiDoubleToDoubleFunction<T> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Double, Double>, Double> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiDoubleToDoubleFunction<T> & Memoized) (t, value1, value2) -> { final double returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> applyAsDouble(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:alfio.manager.TicketReservationManager.java
public Optional<Triple<Event, TicketReservation, Ticket>> from(String eventName, String reservationId, String ticketIdentifier) { return optionally(() -> Triple.of(eventRepository.findByShortName(eventName), ticketReservationRepository.findReservationById(reservationId), ticketRepository.findByUUID(ticketIdentifier))).flatMap((x) -> { Ticket t = x.getRight(); Event e = x.getLeft(); TicketReservation tr = x.getMiddle(); if (tr.getId().equals(t.getTicketsReservationId()) && e.getId() == t.getEventId()) { return Optional.of(x); } else { return Optional.empty(); }/* www . j a v a2 s .c o m*/ }); }
From source file:at.gridtec.lambda4j.operator.ternary.ThrowableDoubleTernaryOperator.java
/** * Returns a memoized (caching) version of this {@link ThrowableDoubleTernaryOperator}. 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 ww .j a v a 2s .co m*/ * Unless the operator and therefore the used cache will be garbage-collected, it will keep all memoized values * forever. * * @return A memoized (caching) version of this {@code ThrowableDoubleTernaryOperator}. * @implSpec This implementation does not allow the input parameters or return value to be {@code null} for the * resulting memoized operator, as the cache used internally does not permit {@code null} keys or values. * @implNote The returned memoized operator can be safely used concurrently from multiple threads which makes it * thread-safe. */ @Nonnull default ThrowableDoubleTernaryOperator<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Double, Double, Double>, Double> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableDoubleTernaryOperator<X> & Memoized) (value1, value2, value3) -> { final double returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), ThrowableFunction .of(key -> applyAsDoubleThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.BiObjIntToIntFunction.java
/** * Returns a memoized (caching) version of this {@link BiObjIntToIntFunction}. 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 ww w. ja v a 2s. 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 BiObjIntToIntFunction}. * @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 BiObjIntToIntFunction<T, U> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Integer>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (BiObjIntToIntFunction<T, U> & Memoized) (t, u, value) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), key -> applyAsInt(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.BiObjByteToIntFunction.java
/** * Returns a memoized (caching) version of this {@link BiObjByteToIntFunction}. 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 av a 2s .c om*/ * 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 BiObjByteToIntFunction}. * @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 BiObjByteToIntFunction<T, U> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Byte>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (BiObjByteToIntFunction<T, U> & Memoized) (t, u, value) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), key -> applyAsInt(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.BiObjIntToByteFunction.java
/** * Returns a memoized (caching) version of this {@link BiObjIntToByteFunction}. 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 ww . j av a 2 s.c om*/ * 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 BiObjIntToByteFunction}. * @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 BiObjIntToByteFunction<T, U> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Integer>, Byte> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (BiObjIntToByteFunction<T, U> & Memoized) (t, u, value) -> { final byte returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), key -> applyAsByte(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.BiObjLongToIntFunction.java
/** * Returns a memoized (caching) version of this {@link BiObjLongToIntFunction}. 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 ww 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 BiObjLongToIntFunction}. * @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 BiObjLongToIntFunction<T, U> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Long>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (BiObjLongToIntFunction<T, U> & Memoized) (t, u, value) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), key -> applyAsInt(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.BiObjCharToIntFunction.java
/** * Returns a memoized (caching) version of this {@link BiObjCharToIntFunction}. 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 a2 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 BiObjCharToIntFunction}. * @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 BiObjCharToIntFunction<T, U> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Character>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (BiObjCharToIntFunction<T, U> & Memoized) (t, u, value) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), key -> applyAsInt(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }