1+ /*
2+ * Copyright (c) 2025 Think-it GmbH
3+ *
4+ * This program and the accompanying materials are made available under the
5+ * terms of the Apache License, Version 2.0 which is available at
6+ * https://www.apache.org/licenses/LICENSE-2.0
7+ *
8+ * SPDX-License-Identifier: Apache-2.0
9+ *
10+ * Contributors:
11+ * Think-it GmbH - initial API and implementation
12+ *
13+ */
14+
115package org .eclipse .dataplane .domain ;
216
317import java .util .NoSuchElementException ;
@@ -13,13 +27,15 @@ public static <C> Result<C> success(C content) {
1327 return new Success <>(content );
1428 }
1529
16- public static <R > Result <R > failure (Exception e ){ return new Failure <>(e ); }
30+ public static <R > Result <R > failure (Exception e ) {
31+ return new Failure <>(e );
32+ }
1733
1834 public static <R > Result <R > attempt (ExceptionThrowingSupplier <R > resultSupplier ) {
1935 try {
2036 var resultValue = resultSupplier .get ();
2137 return Result .success (resultValue );
22- } catch (Exception exception ){
38+ } catch (Exception exception ) {
2339 return Result .failure (exception );
2440 }
2541 }
@@ -32,7 +48,7 @@ public static <R> Result<R> attempt(ExceptionThrowingSupplier<R> resultSupplier)
3248
3349 public abstract <X extends Throwable > C orElseThrow (Function <Exception , X > exceptionSupplier ) throws X ;
3450
35- public abstract <T > Result <T > map (ExceptionThrowingFunction <C ,T > transformValue );
51+ public abstract <T > Result <T > map (ExceptionThrowingFunction <C , T > transformValue );
3652
3753 public abstract <T > Result <T > compose (ExceptionThrowingFunction <C , Result <T >> transformValue );
3854
@@ -48,7 +64,7 @@ private static class Success<C> extends Result<C> {
4864
4965 private final C content ;
5066
51- public Success (C content ) {
67+ Success (C content ) {
5268 this .content = content ;
5369 }
5470
@@ -81,7 +97,7 @@ public <T> Result<T> map(ExceptionThrowingFunction<C, T> transformValue) {
8197 public <T > Result <T > compose (ExceptionThrowingFunction <C , Result <T >> transformValue ) {
8298 try {
8399 return transformValue .apply (this .content );
84- } catch (Exception e ) {
100+ } catch (Exception e ) {
85101 return Result .failure (e );
86102 }
87103 }
@@ -90,6 +106,7 @@ public <T> Result<T> compose(ExceptionThrowingFunction<C, Result<T>> transformVa
90106 private static class Failure <C > extends Result <C > {
91107
92108 private final Exception exception ;
109+
93110 private Failure (Exception exception ) {
94111 this .exception = exception ;
95112 }
@@ -126,7 +143,7 @@ public <T> Result<T> compose(ExceptionThrowingFunction<C, Result<T>> transformVa
126143 }
127144
128145 @ FunctionalInterface
129- public interface ExceptionThrowingFunction <T ,R > {
146+ public interface ExceptionThrowingFunction <T , R > {
130147 R apply (T t ) throws Exception ;
131148 }
132149
0 commit comments