diff --git a/leona-mvc-client/src/main/java/com/sylvona/leona/mvc/client/ClientExecutionView.java b/leona-mvc-client/src/main/java/com/sylvona/leona/mvc/client/ClientExecutionView.java index 98d0585..c922960 100644 --- a/leona-mvc-client/src/main/java/com/sylvona/leona/mvc/client/ClientExecutionView.java +++ b/leona-mvc-client/src/main/java/com/sylvona/leona/mvc/client/ClientExecutionView.java @@ -1,7 +1,7 @@ package com.sylvona.leona.mvc.client; import com.sylvona.leona.mvc.components.containers.ContextView; -import com.sylvona.leona.mvc.components.containers.ExecutionView; +import com.sylvona.leona.core.commons.containers.ExecutionView; import org.springframework.http.ResponseEntity; /** diff --git a/leona-mvc-client/src/main/java/com/sylvona/leona/mvc/client/DefaultClientLogger.java b/leona-mvc-client/src/main/java/com/sylvona/leona/mvc/client/DefaultClientLogger.java index 608ac7c..c039c68 100644 --- a/leona-mvc-client/src/main/java/com/sylvona/leona/mvc/client/DefaultClientLogger.java +++ b/leona-mvc-client/src/main/java/com/sylvona/leona/mvc/client/DefaultClientLogger.java @@ -37,7 +37,7 @@ public DefaultClientLogger(LoggerConfiguration loggerConfiguration) { @Override public void log(ClientExecutionView executionView) { if (!predicate.test(executionView)) return; - if (executionView.isError()) logger.error("Encountered exception", executionView.error()); + if (executionView.hasRight()) logger.error("Encountered exception", executionView.right()); else logger.atLevel(level).log(message.apply(executionView)); } diff --git a/leona-mvc-client/src/main/java/com/sylvona/leona/mvc/client/retry/ClientEchoedRetryView.java b/leona-mvc-client/src/main/java/com/sylvona/leona/mvc/client/retry/ClientEchoedRetryView.java index ea11d06..c04074d 100644 --- a/leona-mvc-client/src/main/java/com/sylvona/leona/mvc/client/retry/ClientEchoedRetryView.java +++ b/leona-mvc-client/src/main/java/com/sylvona/leona/mvc/client/retry/ClientEchoedRetryView.java @@ -42,17 +42,22 @@ public Retryer retryer() { } @Override - public ResponseEntity result() { - return view.result(); + public Throwable right() { + return view.right(); } @Override - public Throwable error() { - return view.error(); + public Duration executionTime() { + return view.executionTime(); } @Override - public Duration executionTime() { - return view.executionTime(); + public ResponseEntity result() { + return view.result(); + } + + @Override + public Throwable error() { + return null; } } diff --git a/leona-mvc-components/src/main/java/com/sylvona/leona/mvc/components/containers/Containers.java b/leona-mvc-components/src/main/java/com/sylvona/leona/mvc/components/containers/Containers.java index 0c98966..61e44b8 100644 --- a/leona-mvc-components/src/main/java/com/sylvona/leona/mvc/components/containers/Containers.java +++ b/leona-mvc-components/src/main/java/com/sylvona/leona/mvc/components/containers/Containers.java @@ -1,5 +1,9 @@ package com.sylvona.leona.mvc.components.containers; +import com.sylvona.leona.core.commons.containers.Quadruple; +import com.sylvona.leona.core.commons.containers.Triple; +import com.sylvona.leona.core.commons.containers.Tuple; + public class Containers { public static Tuple of(T1 item1, T2 item2) { return new Tuple<>(item1, item2); diff --git a/leona-mvc-components/src/main/java/com/sylvona/leona/mvc/components/containers/ExecutionView.java b/leona-mvc-components/src/main/java/com/sylvona/leona/mvc/components/containers/ExecutionView.java deleted file mode 100644 index 5fa4a5e..0000000 --- a/leona-mvc-components/src/main/java/com/sylvona/leona/mvc/components/containers/ExecutionView.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.sylvona.leona.mvc.components.containers; - -import com.sylvona.leona.core.commons.containers.Either; - -import java.time.Duration; - -/** - * An interface representing the result of an execution, which can be either a successful result of type T - * or an error represented by a Throwable. Additionally, it provides information about the overall execution time. - * - * @param The type of the successful result. - */ -public interface ExecutionView extends Either { - - /** - * Retrieves the execution time of the operation. - * - * @return The duration representing the execution time. - */ - Duration executionTime(); -} diff --git a/leona-mvc-components/src/main/java/com/sylvona/leona/mvc/components/containers/Quadruple.java b/leona-mvc-components/src/main/java/com/sylvona/leona/mvc/components/containers/Quadruple.java deleted file mode 100644 index 5cf75e0..0000000 --- a/leona-mvc-components/src/main/java/com/sylvona/leona/mvc/components/containers/Quadruple.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.sylvona.leona.mvc.components.containers; - -import com.google.common.collect.Iterators; -import com.sylvona.leona.core.commons.streams.Streamable; -import jakarta.validation.constraints.NotNull; - -import java.util.Iterator; -import java.util.Objects; -import java.util.function.Function; - -/** - * A record representing a tuple of four elements (quadruple), each with distinct types. - * This record provides utility methods for mapping elements and converting the tuple to an array. - * - * @param The type of the first element. - * @param The type of the second element. - * @param The type of the third element. - * @param The type of the fourth element. - */ -public record Quadruple(@NotNull T1 item1, @NotNull T2 item2, @NotNull T3 item3, @NotNull T4 item4) implements Streamable { - - /** - * Constructs a new {@code Quatra} instance with the provided items. - * - * @param item1 The first element of the quadruple. - * @param item2 The second element of the quadruple. - * @param item3 The third element of the quadruple. - * @param item4 The fourth element of the quadruple. - */ - public Quadruple { - Objects.requireNonNull(item1, "item1"); - Objects.requireNonNull(item2, "item2"); - Objects.requireNonNull(item3, "item3"); - Objects.requireNonNull(item4, "item4"); - } - - /** - * Maps the first element of the quadruple using the provided mapper function, - * creating a new quadruple with the mapped element. - * - * @param mapper The function to map the first element. - * @param The type of the mapped element. - * @return A new quadruple with the mapped first element. - */ - public Quadruple mapT1(Function mapper) { - return new Quadruple<>(mapper.apply(item1), item2, item3, item4); - } - - /** - * Maps the second element of the quadruple using the provided mapper function, - * creating a new quadruple with the mapped element. - * - * @param mapper The function to map the second element. - * @param The type of the mapped element. - * @return A new quadruple with the mapped second element. - */ - public Quadruple mapT2(Function mapper) { - return new Quadruple<>(item1, mapper.apply(item2), item3, item4); - } - - /** - * Maps the third element of the quadruple using the provided mapper function, - * creating a new quadruple with the mapped element. - * - * @param mapper The function to map the third element. - * @param The type of the mapped element. - * @return A new quadruple with the mapped third element. - */ - public Quadruple mapT3(Function mapper) { - return new Quadruple<>(item1, item2, mapper.apply(item3), item4); - } - - /** - * Maps the fourth element of the quadruple using the provided mapper function, - * creating a new quadruple with the mapped element. - * - * @param mapper The function to map the fourth element. - * @param The type of the mapped element. - * @return A new quadruple with the mapped fourth element. - */ - public Quadruple mapT4(Function mapper) { - return new Quadruple<>(item1, item2, item3, mapper.apply(item4)); - } - - /** - * Converts the quadruple to an array containing the first three elements. - * - * @return An array containing the first three elements of the quadruple. - */ - public Object[] toArray() { - return new Object[] {item1, item2, item3}; - } - - /** - * Returns an iterator over the first three elements of the quadruple as an array. - * - * @return An iterator over the first three elements of the quadruple. - */ - @Override - public Iterator iterator() { - return Iterators.forArray(toArray()); - } -} - diff --git a/leona-mvc-components/src/main/java/com/sylvona/leona/mvc/components/containers/Triple.java b/leona-mvc-components/src/main/java/com/sylvona/leona/mvc/components/containers/Triple.java deleted file mode 100644 index 029cbe3..0000000 --- a/leona-mvc-components/src/main/java/com/sylvona/leona/mvc/components/containers/Triple.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.sylvona.leona.mvc.components.containers; - -import com.google.common.collect.Iterators; -import com.sylvona.leona.core.commons.streams.Streamable; -import jakarta.validation.constraints.NotNull; - -import java.util.Iterator; -import java.util.Objects; -import java.util.function.Function; - -/** - * A record representing a tuple of three elements (triple), each with distinct types. - * This record provides utility methods for mapping elements and converting the tuple to an array. - * - * @param The type of the first element. - * @param The type of the second element. - * @param The type of the third element. - */ -public record Triple(@NotNull T1 item1, @NotNull T2 item2, @NotNull T3 item3) implements Streamable { - - /** - * Constructs a new {@code Triple} instance with the provided items. - * - * @param item1 The first element of the triple. - * @param item2 The second element of the triple. - * @param item3 The third element of the triple. - */ - public Triple { - Objects.requireNonNull(item1, "item1"); - Objects.requireNonNull(item2, "item2"); - Objects.requireNonNull(item3, "item3"); - } - - /** - * Maps the first element of the triple using the provided mapper function, - * creating a new triple with the mapped element. - * - * @param mapper The function to map the first element. - * @param The type of the mapped element. - * @return A new triple with the mapped first element. - */ - public Triple mapT1(Function mapper) { - return new Triple<>(mapper.apply(item1), item2, item3); - } - - /** - * Maps the second element of the triple using the provided mapper function, - * creating a new triple with the mapped element. - * - * @param mapper The function to map the second element. - * @param The type of the mapped element. - * @return A new triple with the mapped second element. - */ - public Triple mapT2(Function mapper) { - return new Triple<>(item1, mapper.apply(item2), item3); - } - - /** - * Maps the third element of the triple using the provided mapper function, - * creating a new triple with the mapped element. - * - * @param mapper The function to map the third element. - * @param The type of the mapped element. - * @return A new triple with the mapped third element. - */ - public Triple mapT3(Function mapper) { - return new Triple<>(item1, item2, mapper.apply(item3)); - } - - /** - * Converts the triple to an array containing all three elements. - * - * @return An array containing all three elements of the triple. - */ - public Object[] toArray() { - return new Object[] {item1, item2, item3}; - } - - /** - * Returns an iterator over all three elements of the triple as an array. - * - * @return An iterator over all three elements of the triple. - */ - @Override - public Iterator iterator() { - return Iterators.forArray(toArray()); - } -} - diff --git a/leona-mvc-components/src/main/java/com/sylvona/leona/mvc/components/containers/Tuple.java b/leona-mvc-components/src/main/java/com/sylvona/leona/mvc/components/containers/Tuple.java deleted file mode 100644 index 4f46f26..0000000 --- a/leona-mvc-components/src/main/java/com/sylvona/leona/mvc/components/containers/Tuple.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.sylvona.leona.mvc.components.containers; - -import com.google.common.collect.Iterators; -import com.sylvona.leona.core.commons.streams.Streamable; -import jakarta.validation.constraints.NotNull; - -import java.util.Iterator; -import java.util.Objects; -import java.util.function.Function; - -/** - * A record representing a tuple of two elements, each with distinct types. - * This record provides utility methods for appending elements, concatenating tuples, - * mapping elements, and converting the tuple to an array. - * - * @param The type of the first element. - * @param The type of the second element. - */ -public record Tuple(@NotNull T1 item1, @NotNull T2 item2) implements Streamable { - - /** - * Constructs a new {@code Tuple} instance with the provided items. - * - * @param item1 The first element of the tuple. - * @param item2 The second element of the tuple. - */ - public Tuple { - Objects.requireNonNull(item1, "item1"); - Objects.requireNonNull(item2, "item2"); - } - - /** - * Appends a third element to the tuple, creating a new {@code Triple} instance. - * - * @param item3 The third element to append. - * @param The type of the third element. - * @return A new triple with the appended third element. - */ - public Triple append(T3 item3) { - return new Triple<>(item1, item2, item3); - } - - /** - * Concatenates the tuple with a third element, creating a new tuple containing the original tuple and the third element. - * - * @param item3 The third element to concatenate. - * @param The type of the third element. - * @return A new tuple containing the original tuple and the concatenated third element. - */ - public Tuple, T3> concat(T3 item3) { - return new Tuple<>(this, item3); - } - - /** - * Maps the first element of the tuple using the provided mapper function, - * creating a new tuple with the mapped first element. - * - * @param mapper The function to map the first element. - * @param The type of the mapped element. - * @return A new tuple with the mapped first element. - */ - public Tuple mapT1(Function mapper) { - return new Tuple<>(mapper.apply(item1), item2); - } - - /** - * Maps the second element of the tuple using the provided mapper function, - * creating a new tuple with the mapped second element. - * - * @param mapper The function to map the second element. - * @param The type of the mapped element. - * @return A new tuple with the mapped second element. - */ - public Tuple mapT2(Function mapper) { - return new Tuple<>(item1, mapper.apply(item2)); - } - - /** - * Converts the tuple to an array containing both elements. - * - * @return An array containing both elements of the tuple. - */ - public Object[] toArray() { - return new Object[] {item1, item2}; - } - - /** - * Returns an iterator over both elements of the tuple as an array. - * - * @return An iterator over both elements of the tuple. - */ - @Override - public Iterator iterator() { - return Iterators.forArray(toArray()); - } -} diff --git a/leona-mvc-components/src/main/java/com/sylvona/leona/mvc/components/containers/TupleOperators.java b/leona-mvc-components/src/main/java/com/sylvona/leona/mvc/components/containers/TupleOperators.java deleted file mode 100644 index 76c00c8..0000000 --- a/leona-mvc-components/src/main/java/com/sylvona/leona/mvc/components/containers/TupleOperators.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.sylvona.leona.mvc.components.containers; - -import com.sylvona.leona.core.commons.streams.LINQ; -import com.sylvona.leona.core.commons.streams.LINQStream; - -import java.util.Iterator; - -public class TupleOperators { - /** - * Unpacks a tuple's elements into a {@link LINQStream}. - * - * @param packedTuple The tuple to unpack. - * @param unpackRight If true, unpacks the right element; otherwise, unpacks the left element. - * @return A {@link LINQStream} containing the unpacked elements. - */ - public static LINQStream unpack(Tuple packedTuple, boolean unpackRight) { - return LINQ.stream(new TupleIterator(packedTuple, unpackRight)); - } - - /** - * Unpacks a tuple's elements into a {@link LINQStream}, assuming the left element by default. - * - * @param packedTuple The tuple to unpack. - * @return A {@link LINQStream} containing the unpacked elements. - */ - public static LINQStream unpack(Tuple packedTuple) { - return unpack(packedTuple, false); - } - - /** - * An iterator implementation for unpacking a tuple's elements. - */ - public static class TupleIterator implements Iterable, Iterator { - private final boolean rightSided; - private Object standby; - - public TupleIterator(Tuple packedTuple, boolean rightSided) { - standby = packedTuple; - this.rightSided = rightSided; - } - - public TupleIterator(Tuple packedTuple) { - this(packedTuple, false); - } - - @Override - public Iterator iterator() { - return this; - } - - @Override - public boolean hasNext() { - return standby != null; - } - - @Override - public Object next() { - if (standby instanceof Tuple tuple) { - standby = rightSided ? tuple.item2() : tuple.item1(); - return rightSided ? tuple.item1() : tuple.item2(); - } - - Object value = standby; - standby = null; - return value; - } - } -} diff --git a/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/AsyncExecutionHandle.java b/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/AsyncExecutionHandle.java index bffe680..7c222e2 100644 --- a/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/AsyncExecutionHandle.java +++ b/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/AsyncExecutionHandle.java @@ -1,7 +1,7 @@ package com.sylvona.leona.mvc.services; -import com.sylvona.leona.mvc.components.containers.ExecutionView; -import com.sylvona.leona.mvc.components.containers.Tuple; +import com.sylvona.leona.core.commons.containers.ExecutionView; +import com.sylvona.leona.core.commons.containers.Tuple; import java.util.concurrent.Executor; import java.util.function.Consumer; diff --git a/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/AsyncService.java b/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/AsyncService.java index 7133bae..c090350 100644 --- a/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/AsyncService.java +++ b/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/AsyncService.java @@ -1,5 +1,6 @@ package com.sylvona.leona.mvc.services; +import com.sylvona.leona.core.commons.containers.Tuple; import com.sylvona.leona.mvc.components.Decorators; import com.sylvona.leona.core.commons.VoidLike; import com.sylvona.leona.mvc.components.containers.*; diff --git a/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/DefaultServiceLogger.java b/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/DefaultServiceLogger.java index d561160..b1e843e 100644 --- a/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/DefaultServiceLogger.java +++ b/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/DefaultServiceLogger.java @@ -1,6 +1,6 @@ package com.sylvona.leona.mvc.services; -import com.sylvona.leona.mvc.components.containers.ExecutionView; +import com.sylvona.leona.core.commons.containers.ExecutionView; import com.sylvona.leona.mvc.components.utils.ClassConstructor; import com.sylvona.leona.mvc.services.logging.LoggerConfiguration; import com.sylvona.leona.mvc.services.logging.MdcAwareServiceLogger; @@ -40,7 +40,7 @@ public void log(ServiceExecutionView executionView) { Optional, String>> messageProvider = executionView.context().getOrEmpty("LOGGING_PROVIDER"); - if (executionView.isError()) executionView.metadata().logger().error("Encountered exception", executionView.error()); + if (executionView.hasRight()) executionView.metadata().logger().error("Encountered exception", executionView.right()); else if (messageProvider.isPresent()) executionView.metadata().logger().atLevel(level).log(messageProvider.get().apply(executionView)); else executionView.metadata().logger().atLevel(level).log(message.apply(executionView)); } diff --git a/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/ExecutionHandle.java b/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/ExecutionHandle.java index 8af3321..274e83f 100644 --- a/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/ExecutionHandle.java +++ b/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/ExecutionHandle.java @@ -1,7 +1,7 @@ package com.sylvona.leona.mvc.services; import com.sylvona.leona.core.commons.containers.Either; -import com.sylvona.leona.mvc.components.containers.ExecutionView; +import com.sylvona.leona.core.commons.containers.ExecutionView; import reactor.core.publisher.Mono; import java.util.function.Function; @@ -44,7 +44,7 @@ public interface ExecutionHandle { /** * Immediately executes the deferred function, emitting an {@link ExecutionView} to a resolver, before returning the resolved result. *

- * If manipulation of the {@link ExecutionView} is unnecessary, it's preferable to call {@link #get()} or to use {@link Either#result()} + * If manipulation of the {@link ExecutionView} is unnecessary, it's preferable to call {@link #get()} or to use {@link Either#left()} * to extract only the result. *

* Note: This function invokes the deferred function every time it's called. For a cached approach, use any of the {@link #cached()} methods. @@ -62,7 +62,7 @@ public interface ExecutionHandle { * @return The result of the deferred function. */ default T get() { - return get(Either::result); + return get(Either::left); } /** diff --git a/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/MdcServiceCaptures.java b/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/MdcServiceCaptures.java index 4b112aa..104ee32 100644 --- a/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/MdcServiceCaptures.java +++ b/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/MdcServiceCaptures.java @@ -14,7 +14,7 @@ public MdcServiceCaptures() { execution(MdcLoggingConstants.BACKEND_NAME).capture(sev -> sev.metadata().serviceName()); execution(MdcLoggingConstants.EVENT_TYPE).capture(i -> EventType.SERVICE); execution(MdcLoggingConstants.RESPONSE_TIME).capture(i -> i.executionTime().toMillis()); - execution(MdcLoggingConstants.STATUS_CODE).capture(i -> i.isError() ? ERROR_STATUS_CODE :OK_STATUS_CODE); + execution(MdcLoggingConstants.STATUS_CODE).capture(i -> i.hasRight() ? ERROR_STATUS_CODE :OK_STATUS_CODE); contingent(MdcLoggingConstants.EXECUTION_TARGET) .condition(sev -> sev.metadata().executionTarget() != null) .capture(sev -> sev.metadata().executionTarget()); diff --git a/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/MonoBackedExecutionHandle.java b/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/MonoBackedExecutionHandle.java index 8b6d360..815640a 100644 --- a/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/MonoBackedExecutionHandle.java +++ b/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/MonoBackedExecutionHandle.java @@ -1,6 +1,8 @@ package com.sylvona.leona.mvc.services; import com.sylvona.leona.core.commons.containers.Either; +import com.sylvona.leona.core.commons.containers.ExecutionView; +import com.sylvona.leona.core.commons.containers.Tuple; import com.sylvona.leona.mvc.components.containers.*; import reactor.core.publisher.Mono; import reactor.core.publisher.Signal; @@ -104,7 +106,7 @@ public T cached(Function, T> resolver) { @Override public T cached() { - return result != null ? result.result() : get(); + return result != null ? result.left() : get(); } @Override @@ -119,7 +121,7 @@ public SynchronousExecutionHandle toSync() { @Override public Mono toMono() { - return mono.map(Either::result); + return mono.map(Either::left); } private Mono> setupMono(Supplier>> monoSupplier) { diff --git a/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/MutableServiceExecutionResult.java b/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/MutableServiceExecutionResult.java index 1e32591..d85d722 100644 --- a/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/MutableServiceExecutionResult.java +++ b/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/MutableServiceExecutionResult.java @@ -41,12 +41,12 @@ public void setResult(T result) { } @Override - public boolean isError() { + public boolean hasRight() { return isError; } @Override - public boolean isSuccess() { + public boolean hasLeft() { return !isError; } diff --git a/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/ServiceExecutionView.java b/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/ServiceExecutionView.java index 223daac..b9f6d65 100644 --- a/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/ServiceExecutionView.java +++ b/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/ServiceExecutionView.java @@ -1,7 +1,7 @@ package com.sylvona.leona.mvc.services; import com.sylvona.leona.mvc.components.containers.Context; -import com.sylvona.leona.mvc.components.containers.ExecutionView; +import com.sylvona.leona.core.commons.containers.ExecutionView; /** * An interface representing a view of the execution of a service method. diff --git a/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/SimpleExecutionHandle.java b/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/SimpleExecutionHandle.java index 29994c5..052add1 100644 --- a/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/SimpleExecutionHandle.java +++ b/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/SimpleExecutionHandle.java @@ -1,6 +1,8 @@ package com.sylvona.leona.mvc.services; import com.sylvona.leona.core.commons.containers.Either; +import com.sylvona.leona.core.commons.containers.ExecutionView; +import com.sylvona.leona.core.commons.containers.Tuple; import com.sylvona.leona.mvc.components.containers.*; import reactor.core.publisher.Mono; @@ -30,7 +32,7 @@ public T cached(Function, T> resolver) { @Override public T cached() { - return result != null ? result.result() : get(); + return result != null ? result.left() : get(); } @Override @@ -66,7 +68,7 @@ public AsyncExecutionHandle toAsync() { @Override public Mono toMono() { - return Mono.fromSupplier(this::execute).map(Either::result); + return Mono.fromSupplier(this::execute).map(Either::left); } protected MutableServiceExecutionResult execute() { diff --git a/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/SynchronousExecutionHandle.java b/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/SynchronousExecutionHandle.java index 182b7ed..c06579b 100644 --- a/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/SynchronousExecutionHandle.java +++ b/leona-mvc-services/src/main/java/com/sylvona/leona/mvc/services/SynchronousExecutionHandle.java @@ -1,7 +1,7 @@ package com.sylvona.leona.mvc.services; -import com.sylvona.leona.mvc.components.containers.ExecutionView; -import com.sylvona.leona.mvc.components.containers.Tuple; +import com.sylvona.leona.core.commons.containers.ExecutionView; +import com.sylvona.leona.core.commons.containers.Tuple; import java.util.function.Function; import java.util.function.Supplier;