Package de.mnl.osgi.bnd.maven
Class RepositoryUtils
- java.lang.Object
-
- de.mnl.osgi.bnd.maven.RepositoryUtils
-
public final class RepositoryUtils extends Object
The Class Utils.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceRepositoryUtils.ThrowingRunnableA runnable that may throw an exception.
-
Field Summary
Fields Modifier and Type Field Description static PatternLIST_ITEM_SEPARATORThe Constant LIST_ITEM_SEPARATOR.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stream<String>itemizeList(String list)Itemize list.static <E extends Throwable>
voidrethrow(Class<E> rethrown, RepositoryUtils.ThrowingRunnable runnable)CatchesUndeclaredThrowableExceptions and unwraps any underlying exception of the given type.static <T,E extends Throwable>
Trethrow(Class<E> rethrown, Callable<T> supplier)CatchesUndeclaredThrowableExceptions and unwraps any underlying exception of the given type.static <T,E1 extends Throwable,E2 extends Throwable>
Trethrow(Class<E1> rethrown1, Class<E2> rethrown2, Callable<T> function)CatchesUndeclaredThrowableExceptions and unwraps any underlying exception of the given type.static voidrunIgnoring(RepositoryUtils.ThrowingRunnable runnable)Run ignoring any throwable.static <T> TrunIgnoring(Callable<T> callable, T fallback)Run ignoring any throwable.static voidunthrow(RepositoryUtils.ThrowingRunnable runnable)Converts any exception thrown by the runnable to anUndeclaredThrowableException.static <T> Tunthrow(Callable<T> supplier)Converts any exception thrown by the supplier to anUndeclaredThrowableException.
-
-
-
Field Detail
-
LIST_ITEM_SEPARATOR
public static final Pattern LIST_ITEM_SEPARATOR
The Constant LIST_ITEM_SEPARATOR.
-
-
Method Detail
-
itemizeList
public static Stream<String> itemizeList(String list)
Itemize list.- Parameters:
list- the list- Returns:
- the stream
-
runIgnoring
public static void runIgnoring(RepositoryUtils.ThrowingRunnable runnable)
Run ignoring any throwable.- Parameters:
runnable- the function to be executed
-
runIgnoring
public static <T> T runIgnoring(Callable<T> callable, T fallback)
Run ignoring any throwable. If an exception occurs, the fallback value is returned.- Type Parameters:
T- the return type- Parameters:
callable- the function to be executedfallback- the fallback value- Returns:
- the t
-
unthrow
public static <T> T unthrow(Callable<T> supplier)
Converts any exception thrown by the supplier to anUndeclaredThrowableException.- Type Parameters:
T- the return value- Parameters:
supplier- the supplier- Returns:
- the t
-
unthrow
public static void unthrow(RepositoryUtils.ThrowingRunnable runnable)
Converts any exception thrown by the runnable to anUndeclaredThrowableException.- Parameters:
runnable- the runnable
-
rethrow
public static <T,E extends Throwable> T rethrow(Class<E> rethrown, Callable<T> supplier) throws E extends Throwable
CatchesUndeclaredThrowableExceptions and unwraps any underlying exception of the given type.- Type Parameters:
T- the return typeE- the type of exception that is unwrapped- Parameters:
rethrown- the type of exception that is rethrownsupplier- the supplier- Returns:
- the result from invoking the
supplier - Throws:
E- the exception typeE extends Throwable
-
rethrow
public static <T,E1 extends Throwable,E2 extends Throwable> T rethrow(Class<E1> rethrown1, Class<E2> rethrown2, Callable<T> function) throws E1 extends Throwable, E2 extends Throwable
CatchesUndeclaredThrowableExceptions and unwraps any underlying exception of the given type.- Type Parameters:
T- the return typeE1- the first exception typeE2- the second exception type- Parameters:
rethrown1- the class of the first rethrown exception typerethrown2- the class of the second rethrown exception typefunction- the function to be executed- Returns:
- the result from invoking the
supplier - Throws:
E1- the e1E2- the e2E1 extends Throwable
-
rethrow
public static <E extends Throwable> void rethrow(Class<E> rethrown, RepositoryUtils.ThrowingRunnable runnable) throws E extends Throwable
CatchesUndeclaredThrowableExceptions and unwraps any underlying exception of the given type.- Type Parameters:
E- the type of exception that is unwrapped- Parameters:
rethrown- the type of exception that is rethrownrunnable- the runnable- Throws:
E- the exception typeE extends Throwable
-
-