Example usage for org.apache.commons.lang3.tuple Triple of

List of usage examples for org.apache.commons.lang3.tuple Triple of

Introduction

In this page you can find the example usage for org.apache.commons.lang3.tuple Triple of.

Prototype

public static <L, M, R> Triple<L, M, R> of(final L left, final M middle, final R right) 

Source Link

Document

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.

Usage

From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiShortToByteFunction.java

/**
 * Returns a memoized (caching) version of this {@link ThrowableObjBiShortToByteFunction}. 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 .  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 ThrowableObjBiShortToByteFunction}.
 * @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 ThrowableObjBiShortToByteFunction<T, X> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, Short, Short>, Byte> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (ThrowableObjBiShortToByteFunction<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.ThrowableObjBiShortToLongFunction.java

/**
 * Returns a memoized (caching) version of this {@link ThrowableObjBiShortToLongFunction}. 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 ava 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 ThrowableObjBiShortToLongFunction}.
 * @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 ThrowableObjBiShortToLongFunction<T, X> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, Short, Short>, Long> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (ThrowableObjBiShortToLongFunction<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.ThrowableObjBiFloatToCharFunction.java

/**
 * Returns a memoized (caching) version of this {@link ThrowableObjBiFloatToCharFunction}. 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 .  jav  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 ThrowableObjBiFloatToCharFunction}.
 * @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 ThrowableObjBiFloatToCharFunction<T, X> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, Float, Float>, Character> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (ThrowableObjBiFloatToCharFunction<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.ThrowableObjBiShortToCharFunction.java

/**
 * Returns a memoized (caching) version of this {@link ThrowableObjBiShortToCharFunction}. 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  ava  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 ThrowableObjBiShortToCharFunction}.
 * @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 ThrowableObjBiShortToCharFunction<T, X> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, Short, Short>, Character> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (ThrowableObjBiShortToCharFunction<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.ThrowableObjBiByteToFloatFunction.java

/**
 * Returns a memoized (caching) version of this {@link ThrowableObjBiByteToFloatFunction}. 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 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 ThrowableObjBiByteToFloatFunction}.
 * @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 ThrowableObjBiByteToFloatFunction<T, X> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, Byte, Byte>, Float> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (ThrowableObjBiByteToFloatFunction<T, X> & Memoized) (t, value1, value2) -> {
            final float returnValue;
            synchronized (lock) {
                returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction
                        .of(key -> applyAsFloatThrows(key.getLeft(), key.getMiddle(), key.getRight())));
            }
            return returnValue;
        };
    }
}

From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiByteToShortFunction.java

/**
 * Returns a memoized (caching) version of this {@link ThrowableObjBiByteToShortFunction}. 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 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 ThrowableObjBiByteToShortFunction}.
 * @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 ThrowableObjBiByteToShortFunction<T, X> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, Byte, Byte>, Short> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (ThrowableObjBiByteToShortFunction<T, X> & Memoized) (t, value1, value2) -> {
            final short returnValue;
            synchronized (lock) {
                returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction
                        .of(key -> applyAsShortThrows(key.getLeft(), key.getMiddle(), key.getRight())));
            }
            return returnValue;
        };
    }
}

From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiLongToFloatFunction.java

/**
 * Returns a memoized (caching) version of this {@link ThrowableObjBiLongToFloatFunction}. 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 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 ThrowableObjBiLongToFloatFunction}.
 * @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 ThrowableObjBiLongToFloatFunction<T, X> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, Long, Long>, Float> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (ThrowableObjBiLongToFloatFunction<T, X> & Memoized) (t, value1, value2) -> {
            final float returnValue;
            synchronized (lock) {
                returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction
                        .of(key -> applyAsFloatThrows(key.getLeft(), key.getMiddle(), key.getRight())));
            }
            return returnValue;
        };
    }
}

From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiLongToShortFunction.java

/**
 * Returns a memoized (caching) version of this {@link ThrowableObjBiLongToShortFunction}. 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  . jav  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 ThrowableObjBiLongToShortFunction}.
 * @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 ThrowableObjBiLongToShortFunction<T, X> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, Long, Long>, Short> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (ThrowableObjBiLongToShortFunction<T, X> & Memoized) (t, value1, value2) -> {
            final short returnValue;
            synchronized (lock) {
                returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction
                        .of(key -> applyAsShortThrows(key.getLeft(), key.getMiddle(), key.getRight())));
            }
            return returnValue;
        };
    }
}

From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiCharToFloatFunction.java

/**
 * Returns a memoized (caching) version of this {@link ThrowableObjBiCharToFloatFunction}. 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  a 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 ThrowableObjBiCharToFloatFunction}.
 * @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 ThrowableObjBiCharToFloatFunction<T, X> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, Character, Character>, Float> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (ThrowableObjBiCharToFloatFunction<T, X> & Memoized) (t, value1, value2) -> {
            final float returnValue;
            synchronized (lock) {
                returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction
                        .of(key -> applyAsFloatThrows(key.getLeft(), key.getMiddle(), key.getRight())));
            }
            return returnValue;
        };
    }
}

From source file:at.gridtec.lambda4j.function.tri.obj.ThrowableObjBiCharToShortFunction.java

/**
 * Returns a memoized (caching) version of this {@link ThrowableObjBiCharToShortFunction}. 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  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 ThrowableObjBiCharToShortFunction}.
 * @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 ThrowableObjBiCharToShortFunction<T, X> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, Character, Character>, Short> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (ThrowableObjBiCharToShortFunction<T, X> & Memoized) (t, value1, value2) -> {
            final short returnValue;
            synchronized (lock) {
                returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), ThrowableFunction
                        .of(key -> applyAsShortThrows(key.getLeft(), key.getMiddle(), key.getRight())));
            }
            return returnValue;
        };
    }
}