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.ThrowableBiObjFloatFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjFloatFunction}. 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.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 ThrowableBiObjFloatFunction}. * @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 ThrowableBiObjFloatFunction<T, U, R, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Float>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjFloatFunction<T, U, R, X> & Memoized) (t, u, value) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjShortFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjShortFunction}. 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 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 ThrowableBiObjShortFunction}. * @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 ThrowableBiObjShortFunction<T, U, R, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Short>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjShortFunction<T, U, R, X> & Memoized) (t, u, value) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableBiObjDoubleFunction.java
/** * Returns a memoized (caching) version of this {@link ThrowableBiObjDoubleFunction}. 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 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 ThrowableBiObjDoubleFunction}. * @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 ThrowableBiObjDoubleFunction<T, U, R, X> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Double>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ThrowableBiObjDoubleFunction<T, U, R, X> & Memoized) (t, u, value) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), ThrowableFunction .of(key -> applyThrows(key.getLeft(), key.getMiddle(), key.getRight()))); } return returnValue; }; } }
From source file:blusunrize.immersiveengineering.api.shader.ShaderRegistry.java
public static Triple<ItemStack, ShaderRegistryEntry, ShaderCase> getStoredShaderAndCase( CapabilityShader.ShaderWrapper wrapper) { ItemStack shader = wrapper.getShaderItem(); if (!shader.isEmpty() && shader.getItem() instanceof IShaderItem) { IShaderItem iShaderItem = ((IShaderItem) shader.getItem()); ShaderRegistryEntry registryEntry = shaderRegistry.get(iShaderItem.getShaderName(shader)); if (registryEntry != null) return Triple.of(shader, registryEntry, registryEntry.getCase(wrapper.getShaderType())); }//from www . ja v a 2s. c o m return null; }
From source file:at.gridtec.lambda4j.function.tri.conversion.TriBooleanToIntFunction.java
/** * Returns a memoized (caching) version of this {@link TriBooleanToIntFunction}. 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 ava 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 TriBooleanToIntFunction}. * @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 TriBooleanToIntFunction memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Boolean, Boolean, Boolean>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (TriBooleanToIntFunction & Memoized) (value1, value2, value3) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), key -> applyAsInt(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.TriIntToLongFunction.java
/** * Returns a memoized (caching) version of this {@link TriIntToLongFunction}. 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 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 TriIntToLongFunction}. * @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 TriIntToLongFunction memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Integer, Integer, Integer>, Long> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (TriIntToLongFunction & Memoized) (value1, value2, value3) -> { final long returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), key -> applyAsLong(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.TriByteToIntFunction.java
/** * Returns a memoized (caching) version of this {@link TriByteToIntFunction}. 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 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 TriByteToIntFunction}. * @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 TriByteToIntFunction memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Byte, Byte, Byte>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (TriByteToIntFunction & Memoized) (value1, value2, value3) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), key -> applyAsInt(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.TriLongToIntFunction.java
/** * Returns a memoized (caching) version of this {@link TriLongToIntFunction}. 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 . 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 TriLongToIntFunction}. * @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 TriLongToIntFunction memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Long, Long, Long>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (TriLongToIntFunction & Memoized) (value1, value2, value3) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), key -> applyAsInt(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.TriIntToByteFunction.java
/** * Returns a memoized (caching) version of this {@link TriIntToByteFunction}. 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. 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 TriIntToByteFunction}. * @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 TriIntToByteFunction memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Integer, Integer, Integer>, Byte> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (TriIntToByteFunction & Memoized) (value1, value2, value3) -> { final byte returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), key -> applyAsByte(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.TriBooleanToLongFunction.java
/** * Returns a memoized (caching) version of this {@link TriBooleanToLongFunction}. 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 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 TriBooleanToLongFunction}. * @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 TriBooleanToLongFunction memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Boolean, Boolean, Boolean>, Long> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (TriBooleanToLongFunction & Memoized) (value1, value2, value3) -> { final long returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), key -> applyAsLong(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }