Interface PathMatcherWithException<E extends Exception>
-
- Type Parameters:
E
- the type of the potential exception of the function
- All Superinterfaces:
ExceptionHandlerSupport<PathMatcher,PathMatcher,PathMatcherWithException<E>>
,PrimitiveReturnExceptionHandlerSupport<PathMatcher,PathMatcherWithException<E>>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface PathMatcherWithException<E extends Exception> extends PrimitiveReturnExceptionHandlerSupport<PathMatcher,PathMatcherWithException<E>>
An interface that is implemented by objects that perform match operations on paths and may throw an exception.General contract
boolean matches(Path path) throws E
- The functional method.- uncheck - Return a
PathMatcher
- lift - Return a
PathMatcher
- ignore - Return a
PathMatcher
- Since:
- 1.1.0
- See Also:
PathMatcher
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default PathMatcherWithException<E>
and(PathMatcherWithException<? extends E> other)
Returns a composed PathMatcher that represents a short-circuiting logical AND of this PathMatcher and another.default boolean
defaultValue()
Defines the default value returned by the ignore and ignored method.static <E extends Exception>
PathMatcherWithException<E>failing(Supplier<E> exceptionBuilder)
Returns a PathMatcher that always throw exception.static <E extends Exception>
PathMatcherignored(PathMatcherWithException<E> predicate)
Converts aPathMatcherWithException
to a liftedPathMatcher
returningfalse
in case of exception.static <E extends Exception>
PathMatcherignored(PathMatcherWithException<E> predicate, boolean defaultValue)
Converts aPathMatcherWithException
to a liftedPathMatcher
returning a default value in case of exception.static <E extends Exception>
PathMatcherlifted(PathMatcherWithException<E> predicate)
Converts aPathMatcherWithException
to a liftedPathMatcher
returningfalse
in case of exception.boolean
matches(Path path)
Tells if given path matches this matcher's pattern.default PathMatcherWithException<E>
negate()
Returns a PathMatcher that represents the logical negation of this PathMatcher.static <E extends Exception>
PathMatcherWithException<E>negate(PathMatcherWithException<E> predicate)
Negate aPredicateWithException
.default PathMatcherWithException<E>
or(PathMatcherWithException<? extends E> other)
Returns a composed PathMatcher that represents a short-circuiting logical OR of this PathMatcher and another.static <E extends Exception>
PathMatcherunchecked(PathMatcherWithException<E> predicate)
Converts aPathMatcherWithException
to aPathMatcher
that wraps exception toRuntimeException
.static <E extends Exception>
PathMatcherunchecked(PathMatcherWithException<E> predicate, Function<Exception,RuntimeException> exceptionMapper)
Converts aPathMatcherWithException
to aPathMatcher
that wraps exception toRuntimeException
by using the provided mapping function.default PathMatcher
uncheckOrIgnore(boolean uncheck)
Used internally to implements the ignore or uncheck operation.-
Methods inherited from interface ch.powerunit.extensions.exceptions.ExceptionHandlerSupport
documented, exceptionMapper
-
Methods inherited from interface ch.powerunit.extensions.exceptions.PrimitiveReturnExceptionHandlerSupport
ignore, lift, uncheck
-
-
-
-
Method Detail
-
matches
boolean matches(Path path) throws E extends Exception
Tells if given path matches this matcher's pattern.- Parameters:
path
- the path to match- Returns:
true
if, and only if, the path matches this matcher's pattern- Throws:
E
- any exceptionE extends Exception
- See Also:
PathMatcher.matches(Path)
-
uncheckOrIgnore
default PathMatcher uncheckOrIgnore(boolean uncheck)
Description copied from interface:PrimitiveReturnExceptionHandlerSupport
Used internally to implements the ignore or uncheck operation.- Specified by:
uncheckOrIgnore
in interfacePrimitiveReturnExceptionHandlerSupport<PathMatcher,PathMatcherWithException<E extends Exception>>
- Parameters:
uncheck
- create unchecked version of the function when true, else ignored version.- Returns:
- the function
-
and
default PathMatcherWithException<E> and(PathMatcherWithException<? extends E> other)
Returns a composed PathMatcher that represents a short-circuiting logical AND of this PathMatcher and another. When evaluating the composed predicate, if this predicate isfalse
, then theother
predicate is not evaluated.Any exceptions thrown during evaluation of either PathMatcher are relayed to the caller; if evaluation of this predicate throws an exception, the
other
PathMatcher will not be evaluated.- Parameters:
other
- a PathMatcher that will be logically-ANDed with this predicate- Returns:
- a composed PathMatcher that represents the short-circuiting logical
AND of this PathMatcher and the
other
PathMatcher - Throws:
NullPointerException
- if other is null- See Also:
or(PathMatcherWithException)
,negate()
-
negate
default PathMatcherWithException<E> negate()
Returns a PathMatcher that represents the logical negation of this PathMatcher.- Returns:
- a PathMatcher that represents the logical negation of this PathMatcher
- See Also:
and(PathMatcherWithException)
,or(PathMatcherWithException)
-
negate
static <E extends Exception> PathMatcherWithException<E> negate(PathMatcherWithException<E> predicate)
Negate aPredicateWithException
.- Type Parameters:
E
- the type of the potential exception- Parameters:
predicate
- to be negate- Returns:
- the negated PathMatcher
- Throws:
NullPointerException
- if predicate is null- See Also:
negate()
-
or
default PathMatcherWithException<E> or(PathMatcherWithException<? extends E> other)
Returns a composed PathMatcher that represents a short-circuiting logical OR of this PathMatcher and another. When evaluating the composed PathMatcher, if this PathMatcher istrue
, then theother
predicate is not evaluated.Any exceptions thrown during evaluation of either PathMatcher are relayed to the caller; if evaluation of this PathMatcher throws an exception, the
other
PathMatcher will not be evaluated.- Parameters:
other
- a PathMatcher that will be logically-ORed with this predicate- Returns:
- a composed PathMatcher that represents the short-circuiting logical
OR of this predicate and the
other
PathMatcher - Throws:
NullPointerException
- if other is null- See Also:
and(PathMatcherWithException)
,negate()
-
failing
static <E extends Exception> PathMatcherWithException<E> failing(Supplier<E> exceptionBuilder)
Returns a PathMatcher that always throw exception.- Type Parameters:
E
- the type of the exception- Parameters:
exceptionBuilder
- the supplier to create the exception- Returns:
- a PathMatcher that always throw exception
-
unchecked
static <E extends Exception> PathMatcher unchecked(PathMatcherWithException<E> predicate)
Converts aPathMatcherWithException
to aPathMatcher
that wraps exception toRuntimeException
.- Type Parameters:
E
- the type of the potential exception- Parameters:
predicate
- to be unchecked- Returns:
- the unchecked PathMatcher
- Throws:
NullPointerException
- if predicate is null- See Also:
PrimitiveReturnExceptionHandlerSupport.uncheck()
,unchecked(PathMatcherWithException, Function)
-
unchecked
static <E extends Exception> PathMatcher unchecked(PathMatcherWithException<E> predicate, Function<Exception,RuntimeException> exceptionMapper)
Converts aPathMatcherWithException
to aPathMatcher
that wraps exception toRuntimeException
by using the provided mapping function.- Type Parameters:
E
- the type of the potential exception- Parameters:
predicate
- the be uncheckedexceptionMapper
- a function to convert the exception to the runtime exception.- Returns:
- the unchecked PathMatcher
- Throws:
NullPointerException
- if predicate or exceptionMapper is null- See Also:
PrimitiveReturnExceptionHandlerSupport.uncheck()
,unchecked(PathMatcherWithException)
-
lifted
static <E extends Exception> PathMatcher lifted(PathMatcherWithException<E> predicate)
Converts aPathMatcherWithException
to a liftedPathMatcher
returningfalse
in case of exception.- Type Parameters:
E
- the type of the potential exception- Parameters:
predicate
- to be lifted- Returns:
- the lifted PathMatcher
- Throws:
NullPointerException
- if predicate is null- See Also:
PrimitiveReturnExceptionHandlerSupport.lift()
-
ignored
static <E extends Exception> PathMatcher ignored(PathMatcherWithException<E> predicate)
Converts aPathMatcherWithException
to a liftedPathMatcher
returningfalse
in case of exception.- Type Parameters:
E
- the type of the potential exception- Parameters:
predicate
- to be lifted- Returns:
- the lifted PathMatcher
- Throws:
NullPointerException
- if predicate is null- See Also:
PrimitiveReturnExceptionHandlerSupport.ignore()
-
ignored
static <E extends Exception> PathMatcher ignored(PathMatcherWithException<E> predicate, boolean defaultValue)
Converts aPathMatcherWithException
to a liftedPathMatcher
returning a default value in case of exception.- Type Parameters:
E
- the type of the potential exception- Parameters:
predicate
- to be lifteddefaultValue
- value in case of exception- Returns:
- the lifted PathMatcher
- Throws:
NullPointerException
- if predicate is null- Since:
- 3.0.0
- See Also:
PrimitiveReturnExceptionHandlerSupport.ignore()
,ignored(PathMatcherWithException)
-
defaultValue
default boolean defaultValue()
Defines the default value returned by the ignore and ignored method.- Returns:
- the default value for the ignore/ignored method.
- Since:
- 3.0.0
-
-