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

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

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

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

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

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

From source file:at.gridtec.lambda4j.predicate.tri.TriIntPredicate.java

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

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

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

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

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

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

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

From source file:at.gridtec.lambda4j.predicate.tri.TriLongPredicate.java

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

From source file:at.gridtec.lambda4j.predicate.tri.TriBytePredicate.java

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