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.ThrowableObjBiCharFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiCharFunction}. 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 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 ThrowableObjBiCharFunction}. * @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 ThrowableObjBiCharFunction<T, R, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Character, Character>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiCharFunction<T, R, X> & Memoized) (t, value1, value2) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiFloatFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiFloatFunction}. 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 . ja 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 ThrowableObjBiFloatFunction}. * @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 ThrowableObjBiFloatFunction<T, R, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Float, Float>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiFloatFunction<T, R, X> & Memoized) (t, value1, value2) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiShortFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiShortFunction}. 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 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 ThrowableObjBiShortFunction}. * @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 ThrowableObjBiShortFunction<T, R, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Short, Short>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiShortFunction<T, R, X> & Memoized) (t, value1, value2) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiDoubleFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiDoubleFunction}. 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 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 ThrowableObjBiDoubleFunction}. * @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 ThrowableObjBiDoubleFunction<T, R, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Double, Double>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiDoubleFunction<T, R, X> & Memoized) (t, value1, value2) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.predicate.tri.ThrowableTriPredicate.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriPredicate}. 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. c om*/ * Unless the predicate and therefore the used cache will be garbage-collected, it will keep all memoized values * forever. * * @return A memoized (caching) version of this {@code ThrowableTriPredicate}. * @implSpec This implementation does not allow the input parameters or return value to be {@code null} for the * resulting memoized predicate, as the cache used internally does not permit {@code null} keys or values. * @implNote The returned memoized predicate can be safely used concurrently from multiple threads which makes it * thread-safe. */ @Nonnull default ThrowableTriPredicate<T, U, V, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, V>, Boolean> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriPredicate<T, U, V, X> & Memoized) (t, u, v) -> { final boolean returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, v), ThrowableFunction .of(key -> testThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjIntFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjIntFunction}. 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 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 ThrowableBiObjIntFunction}. * @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 ThrowableBiObjIntFunction<T, U, R, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Integer>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjIntFunction<T, U, R, X> & Memoized) (t, u, value) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjBooleanFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjBooleanFunction}. 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 2 s. com*/ * 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 ThrowableBiObjBooleanFunction}. * @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 ThrowableBiObjBooleanFunction<T, U, R, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Boolean>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjBooleanFunction<T, U, R, X> & Memoized) (t, u, value) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjByteFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjByteFunction}. 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 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 ThrowableBiObjByteFunction}. * @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 ThrowableBiObjByteFunction<T, U, R, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Byte>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjByteFunction<T, U, R, X> & Memoized) (t, u, value) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjLongFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjLongFunction}. 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 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 ThrowableBiObjLongFunction}. * @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 ThrowableBiObjLongFunction<T, U, R, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Long>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjLongFunction<T, U, R, X> & Memoized) (t, u, value) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjCharFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjCharFunction}. 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 ava 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 ThrowableBiObjCharFunction}. * @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 ThrowableBiObjCharFunction<T, U, R, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Character>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjCharFunction<T, U, R, X> & Memoized) (t, u, value) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }