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.ThrowableBiObjCharToCharFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjCharToCharFunction}. 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 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 ThrowableBiObjCharToCharFunction}. * @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 ThrowableBiObjCharToCharFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Character>, Character> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjCharToCharFunction<T, U, X> & Memoized) (t, u, value) -> { final char returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyAsCharThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjIntToByteFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjIntToByteFunction}. 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 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 ThrowableBiObjIntToByteFunction}. * @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 ThrowableBiObjIntToByteFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Integer>, Byte> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjIntToByteFunction<T, U, X> & Memoized) (t, u, value) -> { final byte returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyAsByteThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjIntToLongFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjIntToLongFunction}. 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 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 ThrowableBiObjIntToLongFunction}. * @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 ThrowableBiObjIntToLongFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Integer>, Long> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjIntToLongFunction<T, U, X> & Memoized) (t, u, value) -> { final long returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyAsLongThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjIntToCharFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjIntToCharFunction}. 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 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 ThrowableBiObjIntToCharFunction}. * @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 ThrowableBiObjIntToCharFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Integer>, Character> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjIntToCharFunction<T, U, X> & Memoized) (t, u, value) -> { final char returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyAsCharThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjBooleanToIntFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjBooleanToIntFunction}. 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. jav 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 ThrowableBiObjBooleanToIntFunction}. * @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 ThrowableBiObjBooleanToIntFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Boolean>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjBooleanToIntFunction<T, U, X> & Memoized) (t, u, value) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyAsIntThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjFloatToIntFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjFloatToIntFunction}. 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 .java2s . 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 ThrowableBiObjFloatToIntFunction}. * @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 ThrowableBiObjFloatToIntFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Float>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjFloatToIntFunction<T, U, X> & Memoized) (t, u, value) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyAsIntThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjShortToIntFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjShortToIntFunction}. 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 ThrowableBiObjShortToIntFunction}. * @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 ThrowableBiObjShortToIntFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Short>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjShortToIntFunction<T, U, X> & Memoized) (t, u, value) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyAsIntThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjByteToLongFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjByteToLongFunction}. 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 ava 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 ThrowableBiObjByteToLongFunction}. * @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 ThrowableBiObjByteToLongFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Byte>, Long> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjByteToLongFunction<T, U, X> & Memoized) (t, u, value) -> { final long returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyAsLongThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjLongToByteFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjLongToByteFunction}. 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 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 ThrowableBiObjLongToByteFunction}. * @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 ThrowableBiObjLongToByteFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Long>, Byte> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjLongToByteFunction<T, U, X> & Memoized) (t, u, value) -> { final byte returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyAsByteThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjByteToCharFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjByteToCharFunction}. 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 ThrowableBiObjByteToCharFunction}. * @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 ThrowableBiObjByteToCharFunction<T, U, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Byte>, Character> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjByteToCharFunction<T, U, X> & Memoized) (t, u, value) -> { final char returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyAsCharThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }