List of usage examples for org.apache.commons.lang3.tuple Triple of
public static <L, M, R> Triple<L, M, R> of(final L left, final M middle, final R right)
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.
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiLongFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiLongFunction}. 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 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 ObjBiLongFunction}. * @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 ObjBiLongFunction<T, R> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Long, Long>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiLongFunction<T, R> & Memoized) (t, value1, value2) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> apply(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiByteFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiByteFunction}. 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 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 ObjBiByteFunction}. * @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 ObjBiByteFunction<T, R> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Byte, Byte>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiByteFunction<T, R> & Memoized) (t, value1, value2) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> apply(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiCharFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiCharFunction}. 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 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 ObjBiCharFunction}. * @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 ObjBiCharFunction<T, R> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Character, Character>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiCharFunction<T, R> & Memoized) (t, value1, value2) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> apply(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiFloatFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiFloatFunction}. 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 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 ObjBiFloatFunction}. * @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 ObjBiFloatFunction<T, R> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Float, Float>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiFloatFunction<T, R> & Memoized) (t, value1, value2) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> apply(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiShortFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiShortFunction}. 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 ObjBiShortFunction}. * @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 ObjBiShortFunction<T, R> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Short, Short>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiShortFunction<T, R> & Memoized) (t, value1, value2) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> apply(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:com.formkiq.core.service.workflow.WorkflowServiceImplTest.java
/** * testStartSigning02().// ww w . j a va 2s.c o m * test changing before submit to required immediate * @throws IOException IOException */ @Test public void testStartSigning02() throws IOException { // given final int sigId = 8; FormJSON allfields = TestDataBuilder.createAllFields(); FormJSONField field = findField(allfields, sigId).get(); assertEquals(FormJSONFieldType.SIGNATURE, field.getType()); field.setRequired(FormJSONRequiredType.BEFORE_SUBMIT); Map<String, FormJSON> formsMap = ImmutableMap.of("k1", allfields); String document = UUID.randomUUID().toString(); String stoken = UUID.randomUUID().toString(); // when expect(this.signingService.findAssets(document, stoken)) .andReturn(Triple.of(this.docmsg, this.archive, this.queueMessage)); expect(this.archive.getForms()).andReturn(formsMap); expect(this.docmsg.getFolderid()).andReturn(this.folder); replayAll(); Pair<ModelAndView, WebFlow> result = this.ws.startSigning(this.req, document, stoken); // then verifyAll(); final int numberOfStates = 3; assertEquals("redirect:/flow/workflow?execution=s1e1", result.getLeft().getViewName()); WebFlow flow = result.getRight(); assertEquals(numberOfStates, flow.getStates().size()); assertEquals("flow/summary", flow.getCurrentState().getViewName()); assertEquals(Boolean.TRUE, flow.getCurrentState().getParameter("geoLocation")); assertEquals(this.docmsg, flow.getParameter("docsignmsg")); assertEquals(FormJSONRequiredType.IMMEDIATE, field.getRequired()); }
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiDoubleFunction.java
/** * Returns a memoized (caching) version of this {@link ObjBiDoubleFunction}. 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 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 ObjBiDoubleFunction}. * @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 ObjBiDoubleFunction<T, R> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, Double, Double>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (ObjBiDoubleFunction<T, R> & Memoized) (t, value1, value2) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, value1, value2), key -> apply(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.predicate.tri.TriPredicate.java
/** * Returns a memoized (caching) version of this {@link TriPredicate}. 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 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 TriPredicate}. * @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 TriPredicate<T, U, V> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, V>, Boolean> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (TriPredicate<T, U, V> & Memoized) (t, u, v) -> { final boolean returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, v), key -> test(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.BiObjIntFunction.java
/** * Returns a memoized (caching) version of this {@link BiObjIntFunction}. 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 .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 BiObjIntFunction}. * @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 BiObjIntFunction<T, U, R> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Integer>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (BiObjIntFunction<T, U, R> & Memoized) (t, u, value) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), key -> apply(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.BiObjBooleanFunction.java
/** * Returns a memoized (caching) version of this {@link BiObjBooleanFunction}. 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 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 BiObjBooleanFunction}. * @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 BiObjBooleanFunction<T, U, R> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Boolean>, R> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (BiObjBooleanFunction<T, U, R> & Memoized) (t, u, value) -> { final R returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), key -> apply(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }