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.operator.ternary.DoubleTernaryOperator.java
/** * Returns a memoized (caching) version of this {@link DoubleTernaryOperator}. 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 . com*/ * 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 DoubleTernaryOperator}. * @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 DoubleTernaryOperator memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Double, Double, Double>, Double> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (DoubleTernaryOperator & Memoized) (value1, value2, value3) -> { final double returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), key -> applyAsDouble(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.ThrowableTriBooleanToIntFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriBooleanToIntFunction}. 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 ThrowableTriBooleanToIntFunction}. * @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 ThrowableTriBooleanToIntFunction<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Boolean, Boolean, Boolean>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriBooleanToIntFunction<X> & Memoized) (value1, value2, value3) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), ThrowableFunction .of(key -> applyAsIntThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.ThrowableTriIntToByteFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriIntToByteFunction}. 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 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 ThrowableTriIntToByteFunction}. * @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 ThrowableTriIntToByteFunction<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Integer, Integer, Integer>, Byte> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriIntToByteFunction<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.ThrowableTriIntToLongFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriIntToLongFunction}. 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.jav 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 ThrowableTriIntToLongFunction}. * @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 ThrowableTriIntToLongFunction<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Integer, Integer, Integer>, Long> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriIntToLongFunction<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.ThrowableTriIntToCharFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriIntToCharFunction}. 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 a 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 ThrowableTriIntToCharFunction}. * @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 ThrowableTriIntToCharFunction<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Integer, Integer, Integer>, Character> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriIntToCharFunction<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.conversion.ThrowableTriByteToIntFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriByteToIntFunction}. 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 .java 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 ThrowableTriByteToIntFunction}. * @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 ThrowableTriByteToIntFunction<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Byte, Byte, Byte>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriByteToIntFunction<X> & Memoized) (value1, value2, value3) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), ThrowableFunction .of(key -> applyAsIntThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.ThrowableTriLongToIntFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriLongToIntFunction}. 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 .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 ThrowableTriLongToIntFunction}. * @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 ThrowableTriLongToIntFunction<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Long, Long, Long>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriLongToIntFunction<X> & Memoized) (value1, value2, value3) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), ThrowableFunction .of(key -> applyAsIntThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.ThrowableTriBooleanToByteFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriBooleanToByteFunction}. 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 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 ThrowableTriBooleanToByteFunction}. * @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 ThrowableTriBooleanToByteFunction<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Boolean, Boolean, Boolean>, Byte> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriBooleanToByteFunction<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.ThrowableTriBooleanToLongFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriBooleanToLongFunction}. 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 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 ThrowableTriBooleanToLongFunction}. * @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 ThrowableTriBooleanToLongFunction<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Boolean, Boolean, Boolean>, Long> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriBooleanToLongFunction<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.ThrowableTriCharToIntFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriCharToIntFunction}. 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 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 ThrowableTriCharToIntFunction}. * @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 ThrowableTriCharToIntFunction<X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Character, Character, Character>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriCharToIntFunction<X> & Memoized) (value1, value2, value3) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), ThrowableFunction .of(key -> applyAsIntThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }