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.BiObjByteToLongFunction.java

/**
 * Returns a memoized (caching) version of this {@link BiObjByteToLongFunction}. 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 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 BiObjByteToLongFunction}.
 * @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 BiObjByteToLongFunction<T, U> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, U, Byte>, Long> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (BiObjByteToLongFunction<T, U> & Memoized) (t, u, value) -> {
            final long returnValue;
            synchronized (lock) {
                returnValue = cache.computeIfAbsent(Triple.of(t, u, value),
                        key -> applyAsLong(key.getLeft(), key.getMiddle(), key.getRight()));
            }
            return returnValue;
        };
    }
}

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

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

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

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

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

/**
 * Returns a memoized (caching) version of this {@link BiObjCharToLongFunction}. 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 BiObjCharToLongFunction}.
 * @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 BiObjCharToLongFunction<T, U> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, U, Character>, Long> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (BiObjCharToLongFunction<T, U> & Memoized) (t, u, value) -> {
            final long returnValue;
            synchronized (lock) {
                returnValue = cache.computeIfAbsent(Triple.of(t, u, value),
                        key -> applyAsLong(key.getLeft(), key.getMiddle(), key.getRight()));
            }
            return returnValue;
        };
    }
}

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

/**
 * Returns a memoized (caching) version of this {@link BiObjBooleanToLongFunction}. 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 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 BiObjBooleanToLongFunction}.
 * @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 BiObjBooleanToLongFunction<T, U> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, U, Boolean>, Long> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (BiObjBooleanToLongFunction<T, U> & Memoized) (t, u, value) -> {
            final long returnValue;
            synchronized (lock) {
                returnValue = cache.computeIfAbsent(Triple.of(t, u, value),
                        key -> applyAsLong(key.getLeft(), key.getMiddle(), key.getRight()));
            }
            return returnValue;
        };
    }
}

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

/**
 * Returns a memoized (caching) version of this {@link BiObjBooleanToByteFunction}. 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 . jav  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 BiObjBooleanToByteFunction}.
 * @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 BiObjBooleanToByteFunction<T, U> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, U, Boolean>, Byte> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (BiObjBooleanToByteFunction<T, U> & Memoized) (t, u, value) -> {
            final byte returnValue;
            synchronized (lock) {
                returnValue = cache.computeIfAbsent(Triple.of(t, u, value),
                        key -> applyAsByte(key.getLeft(), key.getMiddle(), key.getRight()));
            }
            return returnValue;
        };
    }
}

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

/**
 * Returns a memoized (caching) version of this {@link BiObjByteToCharFunction}. 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 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 BiObjByteToCharFunction}.
 * @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 BiObjByteToCharFunction<T, U> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, U, Byte>, Character> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (BiObjByteToCharFunction<T, U> & Memoized) (t, u, value) -> {
            final char returnValue;
            synchronized (lock) {
                returnValue = cache.computeIfAbsent(Triple.of(t, u, value),
                        key -> applyAsChar(key.getLeft(), key.getMiddle(), key.getRight()));
            }
            return returnValue;
        };
    }
}

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

/**
 * Returns a memoized (caching) version of this {@link BiObjCharToByteFunction}. 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 .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 BiObjCharToByteFunction}.
 * @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 BiObjCharToByteFunction<T, U> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, U, Character>, Byte> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (BiObjCharToByteFunction<T, U> & Memoized) (t, u, value) -> {
            final byte returnValue;
            synchronized (lock) {
                returnValue = cache.computeIfAbsent(Triple.of(t, u, value),
                        key -> applyAsByte(key.getLeft(), key.getMiddle(), key.getRight()));
            }
            return returnValue;
        };
    }
}

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

/**
 * Returns a memoized (caching) version of this {@link BiObjBooleanToCharFunction}. 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 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 BiObjBooleanToCharFunction}.
 * @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 BiObjBooleanToCharFunction<T, U> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, U, Boolean>, Character> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (BiObjBooleanToCharFunction<T, U> & Memoized) (t, u, value) -> {
            final char returnValue;
            synchronized (lock) {
                returnValue = cache.computeIfAbsent(Triple.of(t, u, value),
                        key -> applyAsChar(key.getLeft(), key.getMiddle(), key.getRight()));
            }
            return returnValue;
        };
    }
}

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

/**
 * Returns a memoized (caching) version of this {@link BiObjDoubleToIntFunction}. 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. 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 BiObjDoubleToIntFunction}.
 * @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 BiObjDoubleToIntFunction<T, U> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<T, U, Double>, Integer> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (BiObjDoubleToIntFunction<T, U> & Memoized) (t, u, value) -> {
            final int returnValue;
            synchronized (lock) {
                returnValue = cache.computeIfAbsent(Triple.of(t, u, value),
                        key -> applyAsInt(key.getLeft(), key.getMiddle(), key.getRight()));
            }
            return returnValue;
        };
    }
}