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.to.ToShortTriFunction.java
/** * Returns a memoized (caching) version of this {@link ToShortTriFunction}. 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 va2 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 ToShortTriFunction}. * @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 ToShortTriFunction<T, U, V> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, V>, Short> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ToShortTriFunction<T, U, V> & Memoized) (t, u, v) -> { final short returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, v), key -> applyAsShort(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.to.ToDoubleTriFunction.java
/** * Returns a memoized (caching) version of this {@link ToDoubleTriFunction}. 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 ava 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 ToDoubleTriFunction}. * @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 ToDoubleTriFunction<T, U, V> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, V>, Double> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ToDoubleTriFunction<T, U, V> & Memoized) (t, u, v) -> { final double returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, v), key -> applyAsDouble(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:alfio.manager.EventManager.java
void fixOutOfRangeCategories(EventModification em, String username, ZoneId zoneId, ZonedDateTime end) { Event event = getSingleEvent(em.getShortName(), username); ticketCategoryRepository.findAllTicketCategories(event.getId()).stream() .map(tc -> Triple.of(tc, tc.getInception(zoneId), tc.getExpiration(zoneId))) .filter(t -> t.getRight().isAfter(end)) .forEach(t -> fixTicketCategoryDates(end, t.getLeft(), t.getMiddle(), t.getRight())); }
From source file:at.gridtec.lambda4j.function.tri.to.ThrowableToIntTriFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableToIntTriFunction}. 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 . 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 ThrowableToIntTriFunction}. * @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 ThrowableToIntTriFunction<T, U, V, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, V>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableToIntTriFunction<T, U, V, X> & Memoized) (t, u, v) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, v), ThrowableFunction .of(key -> applyAsIntThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.to.ThrowableToByteTriFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableToByteTriFunction}. 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 av a2 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 ThrowableToByteTriFunction}. * @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 ThrowableToByteTriFunction<T, U, V, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, V>, Byte> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableToByteTriFunction<T, U, V, X> & Memoized) (t, u, v) -> { final byte returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, v), ThrowableFunction .of(key -> applyAsByteThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.to.ThrowableToLongTriFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableToLongTriFunction}. 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 . 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 ThrowableToLongTriFunction}. * @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 ThrowableToLongTriFunction<T, U, V, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, V>, Long> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableToLongTriFunction<T, U, V, X> & Memoized) (t, u, v) -> { final long returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, v), ThrowableFunction .of(key -> applyAsLongThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.to.ThrowableToCharTriFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableToCharTriFunction}. 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 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 ThrowableToCharTriFunction}. * @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 ThrowableToCharTriFunction<T, U, V, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, V>, Character> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableToCharTriFunction<T, U, V, X> & Memoized) (t, u, v) -> { final char returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, v), ThrowableFunction .of(key -> applyAsCharThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.to.ThrowableToFloatTriFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableToFloatTriFunction}. 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 va2 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 ThrowableToFloatTriFunction}. * @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 ThrowableToFloatTriFunction<T, U, V, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, V>, Float> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableToFloatTriFunction<T, U, V, X> & Memoized) (t, u, v) -> { final float returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, v), ThrowableFunction .of(key -> applyAsFloatThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.to.ThrowableToShortTriFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableToShortTriFunction}. 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.ja v a2s . 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 ThrowableToShortTriFunction}. * @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 ThrowableToShortTriFunction<T, U, V, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, V>, Short> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableToShortTriFunction<T, U, V, X> & Memoized) (t, u, v) -> { final short returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, v), ThrowableFunction .of(key -> applyAsShortThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.to.ThrowableToDoubleTriFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableToDoubleTriFunction}. 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. ja v a2s . 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 ThrowableToDoubleTriFunction}. * @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 ThrowableToDoubleTriFunction<T, U, V, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, V>, Double> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableToDoubleTriFunction<T, U, V, X> & Memoized) (t, u, v) -> { final double returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, v), ThrowableFunction .of(key -> applyAsDoubleThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }