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

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

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

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

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

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

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

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

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

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

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

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

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

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

From source file:at.gridtec.lambda4j.operator.ternary.ThrowableByteTernaryOperator.java

/**
 * Returns a memoized (caching) version of this {@link ThrowableByteTernaryOperator}. 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 . ja va 2s .  c o m*/
 * Unless the operator and therefore the used cache will be garbage-collected, it will keep all memoized values
 * forever.
 *
 * @return A memoized (caching) version of this {@code ThrowableByteTernaryOperator}.
 * @implSpec This implementation does not allow the input parameters or return value to be {@code null} for the
 * resulting memoized operator, as the cache used internally does not permit {@code null} keys or values.
 * @implNote The returned memoized operator can be safely used concurrently from multiple threads which makes it
 * thread-safe.
 */
@Nonnull
default ThrowableByteTernaryOperator<X> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<Byte, Byte, Byte>, Byte> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (ThrowableByteTernaryOperator<X> & Memoized) (value1, value2, value3) -> {
            final byte returnValue;
            synchronized (lock) {
                returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), ThrowableFunction
                        .of(key -> applyAsByteThrows(key.getLeft(), key.getMiddle(), key.getRight())));
            }
            return returnValue;
        };
    }
}

From source file:at.gridtec.lambda4j.operator.ternary.ThrowableLongTernaryOperator.java

/**
 * Returns a memoized (caching) version of this {@link ThrowableLongTernaryOperator}. 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  ava2s  .co  m
 * Unless the operator and therefore the used cache will be garbage-collected, it will keep all memoized values
 * forever.
 *
 * @return A memoized (caching) version of this {@code ThrowableLongTernaryOperator}.
 * @implSpec This implementation does not allow the input parameters or return value to be {@code null} for the
 * resulting memoized operator, as the cache used internally does not permit {@code null} keys or values.
 * @implNote The returned memoized operator can be safely used concurrently from multiple threads which makes it
 * thread-safe.
 */
@Nonnull
default ThrowableLongTernaryOperator<X> memoized() {
    if (isMemoized()) {
        return this;
    } else {
        final Map<Triple<Long, Long, Long>, Long> cache = new ConcurrentHashMap<>();
        final Object lock = new Object();
        return (ThrowableLongTernaryOperator<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.obj.ObjBiIntToDoubleFunction.java

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