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.ThrowableObjBiBooleanToByteFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiBooleanToByteFunction}. 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. j a 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 ThrowableObjBiBooleanToByteFunction}. * @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 ThrowableObjBiBooleanToByteFunction<T, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Boolean, Boolean>, Byte> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiBooleanToByteFunction<T, X> & Memoized) (t, value1, value2) -> { final byte returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyAsByteThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiBooleanToLongFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiBooleanToLongFunction}. 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 . j ava2s . 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 ThrowableObjBiBooleanToLongFunction}. * @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 ThrowableObjBiBooleanToLongFunction<T, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Boolean, Boolean>, Long> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiBooleanToLongFunction<T, X> & Memoized) (t, value1, value2) -> { final long returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyAsLongThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiIntToFloatFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiIntToFloatFunction}. 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 va2 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 ThrowableObjBiIntToFloatFunction}. * @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 ThrowableObjBiIntToFloatFunction<T, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Integer, Integer>, Float> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiIntToFloatFunction<T, X> & Memoized) (t, value1, value2) -> { final float returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyAsFloatThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiIntToShortFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiIntToShortFunction}. 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 v a 2s . 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 ThrowableObjBiIntToShortFunction}. * @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 ThrowableObjBiIntToShortFunction<T, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Integer, Integer>, Short> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiIntToShortFunction<T, X> & Memoized) (t, value1, value2) -> { final short returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyAsShortThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiBooleanToCharFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiBooleanToCharFunction}. 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 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 ThrowableObjBiBooleanToCharFunction}. * @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 ThrowableObjBiBooleanToCharFunction<T, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Boolean, Boolean>, Character> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiBooleanToCharFunction<T, X> & Memoized) (t, value1, value2) -> { final char returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyAsCharThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiFloatToFloatFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiFloatToFloatFunction}. 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 ThrowableObjBiFloatToFloatFunction}. * @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 ThrowableObjBiFloatToFloatFunction<T, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Float, Float>, Float> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiFloatToFloatFunction<T, X> & Memoized) (t, value1, value2) -> { final float returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyAsFloatThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiShortToShortFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiShortToShortFunction}. 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 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 ThrowableObjBiShortToShortFunction}. * @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 ThrowableObjBiShortToShortFunction<T, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Short, Short>, Short> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiShortToShortFunction<T, X> & Memoized) (t, value1, value2) -> { final short returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyAsShortThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiDoubleToIntFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiDoubleToIntFunction}. 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 va2 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 ThrowableObjBiDoubleToIntFunction}. * @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 ThrowableObjBiDoubleToIntFunction<T, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Double, Double>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiDoubleToIntFunction<T, X> & Memoized) (t, value1, value2) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyAsIntThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiFloatToByteFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiFloatToByteFunction}. 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 . 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 ThrowableObjBiFloatToByteFunction}. * @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 ThrowableObjBiFloatToByteFunction<T, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Float, Float>, Byte> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiFloatToByteFunction<T, X> & Memoized) (t, value1, value2) -> { final byte returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyAsByteThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiFloatToLongFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiFloatToLongFunction}. 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.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 ThrowableObjBiFloatToLongFunction}. * @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 ThrowableObjBiFloatToLongFunction<T, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Float, Float>, Long> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiFloatToLongFunction<T, X> & Memoized) (t, value1, value2) -> { final long returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyAsLongThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }