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.ThrowableTriLongToDoubleFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriLongToDoubleFunction}. 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 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 ThrowableTriLongToDoubleFunction}. * @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 ThrowableTriLongToDoubleFunction<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Long, Long, Long>, Double> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriLongToDoubleFunction<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.conversion.ThrowableTriCharToDoubleFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriCharToDoubleFunction}. 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 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 ThrowableTriCharToDoubleFunction}. * @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 ThrowableTriCharToDoubleFunction<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Character, Character, Character>, Double> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriCharToDoubleFunction<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.conversion.ThrowableTriFloatToShortFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriFloatToShortFunction}. 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 a 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 ThrowableTriFloatToShortFunction}. * @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 ThrowableTriFloatToShortFunction<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Float, Float, Float>, Short> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriFloatToShortFunction<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.conversion.ThrowableTriShortToFloatFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriShortToFloatFunction}. 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 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 ThrowableTriShortToFloatFunction}. * @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 ThrowableTriShortToFloatFunction<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Short, Short, Short>, Float> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriShortToFloatFunction<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.ThrowableTriDoubleToByteFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriDoubleToByteFunction}. 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 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 ThrowableTriDoubleToByteFunction}. * @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 ThrowableTriDoubleToByteFunction<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Double, Double, Double>, Byte> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriDoubleToByteFunction<X> & Memoized) (value1, value2, value3) -> { final byte returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), ThrowableFunction .of(key -> applyAsByteThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.ThrowableTriDoubleToLongFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriDoubleToLongFunction}. 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 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 ThrowableTriDoubleToLongFunction}. * @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 ThrowableTriDoubleToLongFunction<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Double, Double, Double>, Long> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriDoubleToLongFunction<X> & Memoized) (value1, value2, value3) -> { final long returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), ThrowableFunction .of(key -> applyAsLongThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.ThrowableTriDoubleToCharFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriDoubleToCharFunction}. 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 av 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 ThrowableTriDoubleToCharFunction}. * @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 ThrowableTriDoubleToCharFunction<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Double, Double, Double>, Character> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriDoubleToCharFunction<X> & Memoized) (value1, value2, value3) -> { final char returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), ThrowableFunction .of(key -> applyAsCharThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiIntToByteFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiIntToByteFunction}. 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 ObjBiIntToByteFunction}. * @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 ObjBiIntToByteFunction<T> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Integer, Integer>, Byte> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiIntToByteFunction<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; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiIntToCharFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiIntToCharFunction}. 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 .java2 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 ObjBiIntToCharFunction}. * @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 ObjBiIntToCharFunction<T> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Integer, Integer>, Character> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiIntToCharFunction<T> & Memoized) (t, value1, value2) -> { final char returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> applyAsChar(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.ThrowableTriFloatToDoubleFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriFloatToDoubleFunction}. 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. 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 ThrowableTriFloatToDoubleFunction}. * @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 ThrowableTriFloatToDoubleFunction<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Float, Float, Float>, Double> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriFloatToDoubleFunction<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; }; } }