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.ObjBiDoubleToLongFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiDoubleToLongFunction}. 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 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 ObjBiDoubleToLongFunction}. * @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 ObjBiDoubleToLongFunction<T> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Double, Double>, Long> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiDoubleToLongFunction<T> & Memoized) (t, value1, value2) -> { final long returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> applyAsLong(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiByteToDoubleFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiByteToDoubleFunction}. 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 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 ObjBiByteToDoubleFunction}. * @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 ObjBiByteToDoubleFunction<T> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Byte, Byte>, Double> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiByteToDoubleFunction<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.ObjBiLongToDoubleFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiLongToDoubleFunction}. 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 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 ObjBiLongToDoubleFunction}. * @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 ObjBiLongToDoubleFunction<T> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Long, Long>, Double> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiLongToDoubleFunction<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.ObjBiCharToDoubleFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiCharToDoubleFunction}. 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 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 ObjBiCharToDoubleFunction}. * @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 ObjBiCharToDoubleFunction<T> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Character, Character>, Double> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiCharToDoubleFunction<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.ObjBiFloatToShortFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiFloatToShortFunction}. 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 a2 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 ObjBiFloatToShortFunction}. * @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 ObjBiFloatToShortFunction<T> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Float, Float>, Short> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiFloatToShortFunction<T> & Memoized) (t, value1, value2) -> { final short returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> applyAsShort(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiShortToFloatFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiShortToFloatFunction}. 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 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 ObjBiShortToFloatFunction}. * @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 ObjBiShortToFloatFunction<T> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Short, Short>, Float> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiShortToFloatFunction<T> & Memoized) (t, value1, value2) -> { final float returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> applyAsFloat(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiDoubleToFloatFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiDoubleToFloatFunction}. 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 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 ObjBiDoubleToFloatFunction}. * @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 ObjBiDoubleToFloatFunction<T> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Double, Double>, Float> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiDoubleToFloatFunction<T> & Memoized) (t, value1, value2) -> { final float returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> applyAsFloat(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiDoubleToShortFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiDoubleToShortFunction}. 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 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 ObjBiDoubleToShortFunction}. * @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 ObjBiDoubleToShortFunction<T> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Double, Double>, Short> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiDoubleToShortFunction<T> & Memoized) (t, value1, value2) -> { final short returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> applyAsShort(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.operator.ternary.ThrowableFloatTernaryOperator.java
/** * Returns a memoized (caching) version of this {@link ThrowableFloatTernaryOperator}. 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 . java 2s. c o 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 ThrowableFloatTernaryOperator}. * @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 ThrowableFloatTernaryOperator<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Float, Float, Float>, Float> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableFloatTernaryOperator<X> & Memoized) (value1, value2, value3) -> { final float returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), ThrowableFunction .of(key -> applyAsFloatThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.operator.ternary.ThrowableShortTernaryOperator.java
/** * Returns a memoized (caching) version of this {@link ThrowableShortTernaryOperator}. 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 . 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 ThrowableShortTernaryOperator}. * @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 ThrowableShortTernaryOperator<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Short, Short, Short>, Short> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableShortTernaryOperator<X> & Memoized) (value1, value2, value3) -> { final short returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), ThrowableFunction .of(key -> applyAsShortThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }