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.ThrowableBiObjLongToShortFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjLongToShortFunction}. 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 . 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 ThrowableBiObjLongToShortFunction}. * @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 ThrowableBiObjLongToShortFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Long>, Short> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjLongToShortFunction<T, U, X> & Memoized) (t, u, value) -> { final short returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyAsShortThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjCharToFloatFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjCharToFloatFunction}. 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.jav 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 ThrowableBiObjCharToFloatFunction}. * @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 ThrowableBiObjCharToFloatFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Character>, Float> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjCharToFloatFunction<T, U, X> & Memoized) (t, u, value) -> { final float returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyAsFloatThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjCharToShortFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjCharToShortFunction}. 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 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 ThrowableBiObjCharToShortFunction}. * @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 ThrowableBiObjCharToShortFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Character>, Short> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjCharToShortFunction<T, U, X> & Memoized) (t, u, value) -> { final short returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyAsShortThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjIntToDoubleFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjIntToDoubleFunction}. 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 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 ThrowableBiObjIntToDoubleFunction}. * @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 ThrowableBiObjIntToDoubleFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Integer>, Double> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjIntToDoubleFunction<T, U, X> & Memoized) (t, u, value) -> { final double returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyAsDoubleThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjBooleanToFloatFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjBooleanToFloatFunction}. 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 . 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 ThrowableBiObjBooleanToFloatFunction}. * @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 ThrowableBiObjBooleanToFloatFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Boolean>, Float> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjBooleanToFloatFunction<T, U, X> & Memoized) (t, u, value) -> { final float returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyAsFloatThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjBooleanToShortFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjBooleanToShortFunction}. 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 .ja va2s. 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 ThrowableBiObjBooleanToShortFunction}. * @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 ThrowableBiObjBooleanToShortFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Boolean>, Short> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjBooleanToShortFunction<T, U, X> & Memoized) (t, u, value) -> { final short returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyAsShortThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjDoubleToByteFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjDoubleToByteFunction}. 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.ja 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 ThrowableBiObjDoubleToByteFunction}. * @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 ThrowableBiObjDoubleToByteFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Double>, Byte> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjDoubleToByteFunction<T, U, X> & Memoized) (t, u, value) -> { final byte returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyAsByteThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjDoubleToLongFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjDoubleToLongFunction}. 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 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 ThrowableBiObjDoubleToLongFunction}. * @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 ThrowableBiObjDoubleToLongFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Double>, Long> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjDoubleToLongFunction<T, U, X> & Memoized) (t, u, value) -> { final long returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyAsLongThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjDoubleToCharFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjDoubleToCharFunction}. 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 ava 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 ThrowableBiObjDoubleToCharFunction}. * @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 ThrowableBiObjDoubleToCharFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Double>, Character> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjDoubleToCharFunction<T, U, X> & Memoized) (t, u, value) -> { final char returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyAsCharThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjFloatToShortFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjFloatToShortFunction}. 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 va 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 ThrowableBiObjFloatToShortFunction}. * @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 ThrowableBiObjFloatToShortFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Float>, Short> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjFloatToShortFunction<T, U, X> & Memoized) (t, u, value) -> { final short returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyAsShortThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }