public final class Util extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Util.TryFunction<T,R>
Deprecated.
1.3.0 use
Fun.ThrowingFunction |
Modifier and Type | Method and Description |
---|---|
static <T,I,R> Function<T,R> |
compose(Function<T,I> before,
Function<I,R> after)
Deprecated.
1.3.0 use
Fun.compose1(Function, Function) instead |
static <M,T,R> Function<T,M> |
composeTry(Function<R,M> monadUnit,
Supplier<M> monadZero,
Util.TryFunction<T,R> onElement,
BiConsumer<T,Exception> onError)
Deprecated.
1.3.0 use
Fun.composeTry1(Function, Supplier, Fun.ThrowingFunction, BiConsumer) |
static <T> Predicate<T> |
debugFilter(org.slf4j.Logger logger,
String format)
Logger function to inject into a stream by way of
filter() method. |
static String |
escapeManifestHeaderValue(String... values) |
static String |
escapeManifestHeaderValues(@NotNull List<String> values) |
static List<String> |
getManifestHeaderValues(Manifest manifest,
String headerName) |
static Map<URL,List<URL>> |
mapManifestHeaderResources(String headerName,
ClassLoader classLoader) |
static Map<URL,List<URL>> |
mapManifestHeaderResources(String headerName,
List<File> files) |
static Map<URL,List<URL>> |
mapManifestHeaderResources(String headerName,
URL manifestUrl) |
static <T,R> Function<T,Optional<R>> |
optFunc(Function<T,R> inputFunc)
Deprecated.
1.3.0 use
Fun.compose(Optional::ofNullable, inputFunc) |
static List<URL> |
resolveManifestResources(URL manifestUrl,
List<String> resources) |
static <T> Predicate<T> |
traceFilter(org.slf4j.Logger logger,
String format)
Logger function to inject into a stream by way of
filter() method. |
static javax.jcr.Session |
wrapSessionReadOnly(javax.jcr.Session session)
Public utility method to wrap an existing session with a facade that blocks writes.
|
public static javax.jcr.Session wrapSessionReadOnly(javax.jcr.Session session)
session
- the existing session to wrappublic static List<String> getManifestHeaderValues(Manifest manifest, String headerName)
public static String escapeManifestHeaderValues(@NotNull @NotNull List<String> values)
public static List<URL> resolveManifestResources(URL manifestUrl, List<String> resources)
public static Map<URL,List<URL>> mapManifestHeaderResources(String headerName, ClassLoader classLoader) throws IOException
IOException
public static Map<URL,List<URL>> mapManifestHeaderResources(String headerName, List<File> files) throws IOException
IOException
public static Map<URL,List<URL>> mapManifestHeaderResources(String headerName, URL manifestUrl) throws IOException
IOException
public static <T> Predicate<T> debugFilter(org.slf4j.Logger logger, String format)
filter()
method. Calls logger.debug()
with the
provided format
string and the current stream element as a format argument.T
- the captured type parameter for the stream elementlogger
- the logger to useformat
- the SLF4j format string (use curly braces for placeholders)Stream.filter()
methodpublic static <T> Predicate<T> traceFilter(org.slf4j.Logger logger, String format)
filter()
method. Calls logger.trace()
with the
provided format
string and the current stream element as a format argument.T
- the captured type parameter for the stream elementlogger
- the logger to useformat
- the SLF4j format string (use curly braces for placeholders)Stream.filter()
method@Deprecated public static <M,T,R> Function<T,M> composeTry(Function<R,M> monadUnit, Supplier<M> monadZero, Util.TryFunction<T,R> onElement, BiConsumer<T,Exception> onError)
Fun.composeTry1(Function, Supplier, Fun.ThrowingFunction, BiConsumer)
Stream
,
Optional
, etc. Useful for eliminating clumsy try/catch blocks from lambdas.M
- The captured monad type, which must match the return types of the monadUnit
and
monadZero
functions, but which is not involved in the onElement
or
onError
functions.T
- The input type mapped by the monad, i.e. the String type in Stream<String>
.R
- The output type mapped by the monad, i.e. the URL type in Stream<URL>
.monadUnit
- the "unit" (or "single") function defined by the appropriate monad. I.E. Stream::of,
Optional::of, or Optional::ofNullable.monadZero
- the "zero" (or "empty") function defined by the appropriate monad, as in Stream::empty,
or Optional::emptyonElement
- some function that produces type R
when given an object of type T
, or fails
with an Exception.onError
- an optional consumer function to perform some logic when the parser function throws.
Receives both the failing input element and the caught Exception.Fun.composeTry1(Function, Supplier, Fun.ThrowingFunction, BiConsumer)
@Deprecated public static <T,R> Function<T,Optional<R>> optFunc(Function<T,R> inputFunc)
Fun.compose(Optional::ofNullable, inputFunc)
Optional::ofNullable
to wrap the output type.T
- input typeR
- input function return typeinputFunc
- the input function@Deprecated public static <T,I,R> Function<T,R> compose(Function<T,I> before, Function<I,R> after)
Fun.compose1(Function, Function)
insteadT
- the input typeI
- the intermediate typeR
- the output typebefore
- the left functionafter
- the right functionT
to R
Copyright © 2017–2020. All rights reserved.