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.ThrowableObjBiIntToLongFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiIntToLongFunction}. 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. 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 ThrowableObjBiIntToLongFunction}. * @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 ThrowableObjBiIntToLongFunction<T, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Integer, Integer>, Long> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiIntToLongFunction<T, X> & Memoized) (t, value1, value2) -> { final long returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyAsLongThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiIntToCharFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiIntToCharFunction}. 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 . 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 ThrowableObjBiIntToCharFunction}. * @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 ThrowableObjBiIntToCharFunction<T, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Integer, Integer>, Character> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiIntToCharFunction<T, X> & Memoized) (t, value1, value2) -> { final char returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyAsCharThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiFloatToIntFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiFloatToIntFunction}. 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 a2s . 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 ThrowableObjBiFloatToIntFunction}. * @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 ThrowableObjBiFloatToIntFunction<T, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Float, Float>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiFloatToIntFunction<T, X> & Memoized) (t, value1, value2) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyAsIntThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiShortToIntFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiShortToIntFunction}. 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 va2 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 ThrowableObjBiShortToIntFunction}. * @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 ThrowableObjBiShortToIntFunction<T, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Short, Short>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiShortToIntFunction<T, X> & Memoized) (t, value1, value2) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyAsIntThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiByteToLongFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiByteToLongFunction}. 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 . 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 ThrowableObjBiByteToLongFunction}. * @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 ThrowableObjBiByteToLongFunction<T, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Byte, Byte>, Long> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiByteToLongFunction<T, X> & Memoized) (t, value1, value2) -> { final long returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyAsLongThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiLongToByteFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiLongToByteFunction}. 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 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 ThrowableObjBiLongToByteFunction}. * @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 ThrowableObjBiLongToByteFunction<T, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Long, Long>, Byte> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiLongToByteFunction<T, X> & Memoized) (t, value1, value2) -> { final byte returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyAsByteThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiByteToCharFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiByteToCharFunction}. 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 . ja va 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 ThrowableObjBiByteToCharFunction}. * @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 ThrowableObjBiByteToCharFunction<T, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Byte, Byte>, Character> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiByteToCharFunction<T, X> & Memoized) (t, value1, value2) -> { final char returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyAsCharThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiLongToCharFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiLongToCharFunction}. 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 va 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 ThrowableObjBiLongToCharFunction}. * @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 ThrowableObjBiLongToCharFunction<T, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Long, Long>, Character> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiLongToCharFunction<T, X> & Memoized) (t, value1, value2) -> { final char returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyAsCharThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiCharToByteFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiCharToByteFunction}. 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 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 ThrowableObjBiCharToByteFunction}. * @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 ThrowableObjBiCharToByteFunction<T, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Character, Character>, Byte> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiCharToByteFunction<T, X> & Memoized) (t, value1, value2) -> { final byte returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyAsByteThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiCharToLongFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableObjBiCharToLongFunction}. 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 a2 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 ThrowableObjBiCharToLongFunction}. * @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 ThrowableObjBiCharToLongFunction<T, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Character, Character>, Long> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableObjBiCharToLongFunction<T, X> & Memoized) (t, value1, value2) -> { final long returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction .of(key -> applyAsLongThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }