Class Wrappers
- java.lang.Object
-
- org.faktorips.devtools.abstraction.Wrappers
-
public class Wrappers extends java.lang.ObjectUtility class to wrap, unwrap and implementwrappers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWrappers.ArrayUnwrapper<A extends AAbstraction>static classWrappers.CollectionUnwrapperstatic interfaceWrappers.CoreExceptionThrowingRunnableARunnablethat may throw aCoreException.static interfaceWrappers.CoreExceptionThrowingSupplier<T>ASupplierthat may throw aCoreException.static classWrappers.WrapperBuilder
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Tget(Wrappers.CoreExceptionThrowingSupplier<T> supplier)Calls the given supplier and returns the result.static voidrun(Wrappers.CoreExceptionThrowingRunnable runnable)Runs the given runnable.static <A extends AAbstraction>
Wrappers.ArrayUnwrapper<A>unwrap(A[] wrappers)Returns aWrappers.ArrayUnwrapperthat allows unwrapping the given array of wrappers to an array or list of the wrapped class.static Wrappers.CollectionUnwrapperunwrap(java.util.Collection<? extends AAbstraction> wrappers)Returns aWrappers.CollectionUnwrapperthat allows unwrapping the given collection of wrappers to an array of the wrapped class.static <T> Tunwrap(AAbstraction wrapper)Unwraps the givenabstractionto the call-site's typestatic Wrappers.WrapperBuilderwrap(java.lang.Object original)Returns aWrappers.WrapperBuilderfor the given object that allows it to be wrapped in an implementation-specificwrapper.static <T> Wrappers.WrapperBuilderwrapSupplier(Wrappers.CoreExceptionThrowingSupplier<T> supplier)Returns aWrappers.WrapperBuilderfor the object produced by the given supplier that allows that object to be wrapped in an implementation-specificwrapper.
-
-
-
Method Detail
-
wrap
public static Wrappers.WrapperBuilder wrap(java.lang.Object original)
Returns aWrappers.WrapperBuilderfor the given object that allows it to be wrapped in an implementation-specificwrapper.
-
wrapSupplier
public static <T> Wrappers.WrapperBuilder wrapSupplier(Wrappers.CoreExceptionThrowingSupplier<T> supplier)
Returns aWrappers.WrapperBuilderfor the object produced by the given supplier that allows that object to be wrapped in an implementation-specificwrapper.Any
CoreExceptionthrown by the supplier is rethrown as aIpsException.
-
run
public static void run(Wrappers.CoreExceptionThrowingRunnable runnable)
Runs the given runnable.Any
CoreExceptionthrown by the runnable is rethrown as aIpsException.
-
get
public static <T> T get(Wrappers.CoreExceptionThrowingSupplier<T> supplier)
Calls the given supplier and returns the result.Any
CoreExceptionthrown by the supplier is rethrown as aIpsException.
-
unwrap
@CheckForNull public static <T> T unwrap(@CheckForNull AAbstraction wrapper)Unwraps the givenabstractionto the call-site's type- Type Parameters:
T- the expected unwrapped type- Parameters:
wrapper- a wrapper wrapping the expected type- Returns:
- the unwrapped T object or
nullif the given wrapper isnull - Throws:
java.lang.ClassCastException- if called with a wrapper not wrapping the expected type
-
unwrap
public static <A extends AAbstraction> Wrappers.ArrayUnwrapper<A> unwrap(A[] wrappers)
Returns aWrappers.ArrayUnwrapperthat allows unwrapping the given array of wrappers to an array or list of the wrapped class.
-
unwrap
public static Wrappers.CollectionUnwrapper unwrap(java.util.Collection<? extends AAbstraction> wrappers)
Returns aWrappers.CollectionUnwrapperthat allows unwrapping the given collection of wrappers to an array of the wrapped class.
-
-