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.conversion.ThrowableTriShortToDoubleFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriShortToDoubleFunction}. 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 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 ThrowableTriShortToDoubleFunction}. * @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 ThrowableTriShortToDoubleFunction<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Short, Short, Short>, Double> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriShortToDoubleFunction<X> & Memoized) (value1, value2, value3) -> { final double returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), ThrowableFunction .of(key -> applyAsDoubleThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiBooleanToIntFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiBooleanToIntFunction}. 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 va2s . 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 ObjBiBooleanToIntFunction}. * @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 ObjBiBooleanToIntFunction<T> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Boolean, Boolean>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiBooleanToIntFunction<T> & Memoized) (t, value1, value2) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> applyAsInt(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiByteToIntFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiByteToIntFunction}. 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 va 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 ObjBiByteToIntFunction}. * @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 ObjBiByteToIntFunction<T> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Byte, Byte>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiByteToIntFunction<T> & Memoized) (t, value1, value2) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> applyAsInt(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiLongToIntFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiLongToIntFunction}. 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 va2s .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 ObjBiLongToIntFunction}. * @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 ObjBiLongToIntFunction<T> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Long, Long>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiLongToIntFunction<T> & Memoized) (t, value1, value2) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> applyAsInt(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.ThrowableTriDoubleToFloatFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriDoubleToFloatFunction}. 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. 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 ThrowableTriDoubleToFloatFunction}. * @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 ThrowableTriDoubleToFloatFunction<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Double, Double, Double>, Float> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriDoubleToFloatFunction<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.function.tri.conversion.ThrowableTriDoubleToShortFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriDoubleToShortFunction}. 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 . jav a2s .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 ThrowableTriDoubleToShortFunction}. * @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 ThrowableTriDoubleToShortFunction<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Double, Double, Double>, Short> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriDoubleToShortFunction<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; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiCharToIntFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiCharToIntFunction}. 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 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 ObjBiCharToIntFunction}. * @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 ObjBiCharToIntFunction<T> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Character, Character>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiCharToIntFunction<T> & Memoized) (t, value1, value2) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> applyAsInt(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiIntToLongFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiIntToLongFunction}. 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 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 ObjBiIntToLongFunction}. * @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 ObjBiIntToLongFunction<T> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Integer, Integer>, Long> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiIntToLongFunction<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.ObjBiLongToLongFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiLongToLongFunction}. 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 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 ObjBiLongToLongFunction}. * @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 ObjBiLongToLongFunction<T> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Long, Long>, Long> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiLongToLongFunction<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.ObjBiByteToByteFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiByteToByteFunction}. 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 .jav 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 ObjBiByteToByteFunction}. * @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 ObjBiByteToByteFunction<T> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Byte, Byte>, Byte> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiByteToByteFunction<T> & Memoized) (t, value1, value2) -> { final byte returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> applyAsByte(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }