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.conversion.ThrowableTriCharToLongFunction.java

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

From source file:at.gridtec.lambda4j.function.tri.conversion.ThrowableTriFloatToIntFunction.java

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

From source file:at.gridtec.lambda4j.function.tri.conversion.ThrowableTriShortToIntFunction.java

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

From source file:at.gridtec.lambda4j.function.tri.conversion.ThrowableTriIntToDoubleFunction.java

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

From source file:at.gridtec.lambda4j.function.tri.conversion.ThrowableTriByteToFloatFunction.java

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

From source file:at.gridtec.lambda4j.function.tri.conversion.ThrowableTriByteToShortFunction.java

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

From source file:at.gridtec.lambda4j.function.tri.conversion.ThrowableTriLongToFloatFunction.java

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

From source file:at.gridtec.lambda4j.function.tri.conversion.ThrowableTriLongToShortFunction.java

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

From source file:at.gridtec.lambda4j.function.tri.conversion.ThrowableTriCharToFloatFunction.java

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

From source file:at.gridtec.lambda4j.function.tri.conversion.ThrowableTriCharToShortFunction.java

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