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.ThrowableBiObjCharToByteFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjCharToByteFunction}. 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 ThrowableBiObjCharToByteFunction}. * @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 ThrowableBiObjCharToByteFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Character>, Byte> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjCharToByteFunction<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.ThrowableBiObjCharToLongFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjCharToLongFunction}. 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 . 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 ThrowableBiObjCharToLongFunction}. * @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 ThrowableBiObjCharToLongFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Character>, Long> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjCharToLongFunction<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.ThrowableBiObjLongToCharFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjLongToCharFunction}. 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 a2s.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 ThrowableBiObjLongToCharFunction}. * @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 ThrowableBiObjLongToCharFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Long>, Character> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjLongToCharFunction<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.ThrowableBiObjIntToFloatFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjIntToFloatFunction}. 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 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 ThrowableBiObjIntToFloatFunction}. * @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 ThrowableBiObjIntToFloatFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Integer>, Float> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjIntToFloatFunction<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.ThrowableBiObjIntToShortFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjIntToShortFunction}. 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 av 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 ThrowableBiObjIntToShortFunction}. * @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 ThrowableBiObjIntToShortFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Integer>, Short> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjIntToShortFunction<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.ThrowableBiObjBooleanToByteFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjBooleanToByteFunction}. 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. java 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 ThrowableBiObjBooleanToByteFunction}. * @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 ThrowableBiObjBooleanToByteFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Boolean>, Byte> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjBooleanToByteFunction<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.ThrowableBiObjBooleanToLongFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjBooleanToLongFunction}. 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 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 ThrowableBiObjBooleanToLongFunction}. * @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 ThrowableBiObjBooleanToLongFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Boolean>, Long> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjBooleanToLongFunction<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.ThrowableBiObjBooleanToCharFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjBooleanToCharFunction}. 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>/* www .j av 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 ThrowableBiObjBooleanToCharFunction}. * @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 ThrowableBiObjBooleanToCharFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Boolean>, Character> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjBooleanToCharFunction<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.ThrowableBiObjDoubleToIntFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjDoubleToIntFunction}. 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 .ja 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 ThrowableBiObjDoubleToIntFunction}. * @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 ThrowableBiObjDoubleToIntFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Double>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjDoubleToIntFunction<T, U, X> & Memoized) (t, u, value) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyAsIntThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjFloatToFloatFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjFloatToFloatFunction}. 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 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 ThrowableBiObjFloatToFloatFunction}. * @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 ThrowableBiObjFloatToFloatFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Float>, Float> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjFloatToFloatFunction<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; }; } }