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.ThrowableTriBooleanFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriBooleanFunction}. 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 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 ThrowableTriBooleanFunction}. * @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 ThrowableTriBooleanFunction<R, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Boolean, Boolean, Boolean>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriBooleanFunction<R, X> & Memoized) (value1, value2, value3) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), ThrowableFunction .of(key -> applyThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.ThrowableTriIntFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriIntFunction}. 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 v 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 ThrowableTriIntFunction}. * @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 ThrowableTriIntFunction<R, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Integer, Integer, Integer>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriIntFunction<R, X> & Memoized) (value1, value2, value3) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), ThrowableFunction .of(key -> applyThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.ThrowableTriByteFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriByteFunction}. 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 .jav 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 ThrowableTriByteFunction}. * @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 ThrowableTriByteFunction<R, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Byte, Byte, Byte>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriByteFunction<R, X> & Memoized) (value1, value2, value3) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), ThrowableFunction .of(key -> applyThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.ThrowableTriLongFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriLongFunction}. 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 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 ThrowableTriLongFunction}. * @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 ThrowableTriLongFunction<R, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Long, Long, Long>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriLongFunction<R, X> & Memoized) (value1, value2, value3) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), ThrowableFunction .of(key -> applyThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.ThrowableTriCharFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriCharFunction}. 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 a va2 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 ThrowableTriCharFunction}. * @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 ThrowableTriCharFunction<R, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Character, Character, Character>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriCharFunction<R, X> & Memoized) (value1, value2, value3) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), ThrowableFunction .of(key -> applyThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiBooleanFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiBooleanFunction}. 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 .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 ObjBiBooleanFunction}. * @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 ObjBiBooleanFunction<T, R> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Boolean, Boolean>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiBooleanFunction<T, R> & Memoized) (t, value1, value2) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> apply(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.ThrowableTriFloatFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriFloatFunction}. 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 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 ThrowableTriFloatFunction}. * @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 ThrowableTriFloatFunction<R, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Float, Float, Float>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriFloatFunction<R, X> & Memoized) (value1, value2, value3) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), ThrowableFunction .of(key -> applyThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.ThrowableTriShortFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriShortFunction}. 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 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 ThrowableTriShortFunction}. * @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 ThrowableTriShortFunction<R, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Short, Short, Short>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriShortFunction<R, X> & Memoized) (value1, value2, value3) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), ThrowableFunction .of(key -> applyThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiIntFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiIntFunction}. 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 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 ObjBiIntFunction}. * @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 ObjBiIntFunction<T, R> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Integer, Integer>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiIntFunction<T, R> & Memoized) (t, value1, value2) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> apply(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.ThrowableTriDoubleFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableTriDoubleFunction}. 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 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 ThrowableTriDoubleFunction}. * @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 ThrowableTriDoubleFunction<R, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Double, Double, Double>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableTriDoubleFunction<R, X> & Memoized) (value1, value2, value3) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), ThrowableFunction .of(key -> applyThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }