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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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