Interface FilenameFilterWithException<E extends Exception>
-
- Type Parameters:
E- the type of the potential exception of the function
- All Superinterfaces:
ExceptionHandlerSupport<FilenameFilter,FilenameFilter,FilenameFilterWithException<E>>,PrimitiveReturnExceptionHandlerSupport<FilenameFilter,FilenameFilterWithException<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 FilenameFilterWithException<E extends Exception> extends PrimitiveReturnExceptionHandlerSupport<FilenameFilter,FilenameFilterWithException<E>>
Instances of classes that implement this interface are used to filter filenames and may throw exception.General contract
boolean accept(File dir, String name) throws E- The functional method.- uncheck - Return a
FilenameFilter - lift - Return a
FilenameFilter - ignore - Return a
FilenameFilter
- See Also:
FilenameFilter
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description booleanaccept(File dir, String name)Tests if a specified file should be included in a file list.default FilenameFilterWithException<E>and(FilenameFilterWithException<? extends E> other)Returns a composed FilenameFilter that represents a short-circuiting logical AND of this FilenameFilter and another.default booleandefaultValue()Defines the default value returned by the ignore and ignored method.static <E extends Exception>
FilenameFilterWithException<E>failing(Supplier<E> exceptionBuilder)Returns a FilenameFilter that always throw exception.static <E extends Exception>
FilenameFilterignored(FilenameFilterWithException<E> predicate)Converts aFilenameFilterWithExceptionto a liftedFilenameFilterreturningfalsein case of exception.static <E extends Exception>
FilenameFilterignored(FilenameFilterWithException<E> predicate, boolean defaultValue)Converts aFilenameFilterWithExceptionto a liftedFilenameFilterreturning a default value in case of exception.static <E extends Exception>
FilenameFilterlifted(FilenameFilterWithException<E> predicate)Converts aFilenameFilterWithExceptionto a liftedFilenameFilterreturningfalsein case of exception.default FilenameFilterWithException<E>negate()Returns a FilenameFilter that represents the logical negation of this FilenameFilter.static <E extends Exception>
FilenameFilterWithException<E>negate(FilenameFilterWithException<E> predicate)Negate aDoublePredicateWithException.default FilenameFilterWithException<E>or(FilenameFilterWithException<? extends E> other)Returns a composed FilenameFilter that represents a short-circuiting logical OR of this FilenameFilter and another.static <E extends Exception>
FilenameFilterunchecked(FilenameFilterWithException<E> predicate)Converts aFilenameFilterWithExceptionto aFilenameFilterthat wraps toRuntimeException.static <E extends Exception>
FilenameFilterunchecked(FilenameFilterWithException<E> predicate, Function<Exception,RuntimeException> exceptionMapper)Converts aFilenameFilterWithExceptionto aFilenameFilterthat wraps toRuntimeExceptionby using the provided mapping function.default FilenameFilteruncheckOrIgnore(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
-
accept
boolean accept(File dir, String name) throws E extends Exception
Tests if a specified file should be included in a file list.- Parameters:
dir- the directory in which the file was found.name- the name of the file.- Returns:
trueif and only if the name should be included in the file list;falseotherwise.- Throws:
E- any exceptionE extends Exception- See Also:
FilenameFilter.accept(File, String)
-
uncheckOrIgnore
default FilenameFilter uncheckOrIgnore(boolean uncheck)
Description copied from interface:PrimitiveReturnExceptionHandlerSupportUsed internally to implements the ignore or uncheck operation.- Specified by:
uncheckOrIgnorein interfacePrimitiveReturnExceptionHandlerSupport<FilenameFilter,FilenameFilterWithException<E extends Exception>>- Parameters:
uncheck- create unchecked version of the function when true, else ignored version.- Returns:
- the function
-
and
default FilenameFilterWithException<E> and(FilenameFilterWithException<? extends E> other)
Returns a composed FilenameFilter that represents a short-circuiting logical AND of this FilenameFilter and another. When evaluating the composed FilenameFilter, if this FilenameFilter isfalse, then theotherFilenameFilter is not evaluated.Any exceptions thrown during evaluation of either FilenameFilter are relayed to the caller; if evaluation of this FilenameFilter throws an exception, the
otherFilenameFilter will not be evaluated.- Parameters:
other- a FilenameFilter that will be logically-ANDed with this predicate- Returns:
- a composed FilenameFilter that represents the short-circuiting
logical AND of this FilenameFilter and the
otherFilenameFilter - Throws:
NullPointerException- if other is null- See Also:
or(FilenameFilterWithException),negate()
-
negate
default FilenameFilterWithException<E> negate()
Returns a FilenameFilter that represents the logical negation of this FilenameFilter.- Returns:
- a FilenameFilter that represents the logical negation of this FilenameFilter
- See Also:
and(FilenameFilterWithException),or(FilenameFilterWithException)
-
negate
static <E extends Exception> FilenameFilterWithException<E> negate(FilenameFilterWithException<E> predicate)
Negate aDoublePredicateWithException.- Type Parameters:
E- the type of the potential exception- Parameters:
predicate- to be negate- Returns:
- the negated FilenameFilter
- See Also:
negate()
-
or
default FilenameFilterWithException<E> or(FilenameFilterWithException<? extends E> other)
Returns a composed FilenameFilter that represents a short-circuiting logical OR of this FilenameFilter and another. When evaluating the composed FilenameFilter, if this FilenameFilter istrue, then theotherFilenameFilter is not evaluated.Any exceptions thrown during evaluation of either FilenameFilter are relayed to the caller; if evaluation of this FilenameFilter throws an exception, the
otherFilenameFilter will not be evaluated.- Parameters:
other- a FilenameFilter that will be logically-ORed with this FilenameFilter- Returns:
- a composed FilenameFilter that represents the short-circuiting
logical OR of this FilenameFilter and the
otherFilenameFilter - Throws:
NullPointerException- if other is null- See Also:
and(FilenameFilterWithException),negate()
-
failing
static <E extends Exception> FilenameFilterWithException<E> failing(Supplier<E> exceptionBuilder)
Returns a FilenameFilter that always throw exception.- Type Parameters:
E- the type of the exception- Parameters:
exceptionBuilder- the supplier to create the exception- Returns:
- a predicate that always throw exception
-
unchecked
static <E extends Exception> FilenameFilter unchecked(FilenameFilterWithException<E> predicate)
Converts aFilenameFilterWithExceptionto aFilenameFilterthat wraps toRuntimeException.- Type Parameters:
E- the type of the potential exception- Parameters:
predicate- to be unchecked- Returns:
- the unchecked FilenameFilter
- Throws:
NullPointerException- if predicate is null- See Also:
PrimitiveReturnExceptionHandlerSupport.uncheck(),unchecked(FilenameFilterWithException, Function)
-
unchecked
static <E extends Exception> FilenameFilter unchecked(FilenameFilterWithException<E> predicate, Function<Exception,RuntimeException> exceptionMapper)
Converts aFilenameFilterWithExceptionto aFilenameFilterthat wraps toRuntimeExceptionby 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 FilenameFilter
- Throws:
NullPointerException- if predicate or exceptionMapper is null- See Also:
PrimitiveReturnExceptionHandlerSupport.uncheck(),unchecked(FilenameFilterWithException)
-
lifted
static <E extends Exception> FilenameFilter lifted(FilenameFilterWithException<E> predicate)
Converts aFilenameFilterWithExceptionto a liftedFilenameFilterreturningfalsein case of exception.- Type Parameters:
E- the type of the potential exception- Parameters:
predicate- to be lifted- Returns:
- the lifted FilenameFilter
- Throws:
NullPointerException- if predicate is null- See Also:
PrimitiveReturnExceptionHandlerSupport.lift()
-
ignored
static <E extends Exception> FilenameFilter ignored(FilenameFilterWithException<E> predicate)
Converts aFilenameFilterWithExceptionto a liftedFilenameFilterreturningfalsein case of exception.- Type Parameters:
E- the type of the potential exception- Parameters:
predicate- to be lifted- Returns:
- the lifted FilenameFilter
- Throws:
NullPointerException- if predicate is null- See Also:
PrimitiveReturnExceptionHandlerSupport.ignore()
-
ignored
static <E extends Exception> FilenameFilter ignored(FilenameFilterWithException<E> predicate, boolean defaultValue)
Converts aFilenameFilterWithExceptionto a liftedFilenameFilterreturning 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 FilenameFilter
- Throws:
NullPointerException- if predicate is null- Since:
- 3.0.0
- See Also:
PrimitiveReturnExceptionHandlerSupport.ignore(),ignored(FilenameFilterWithException)
-
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
-
-