Interface FileFilterWithException<E extends Exception>
-
- Type Parameters:
E
- the type of the potential exception of the function
- All Superinterfaces:
ExceptionHandlerSupport<FileFilter,FileFilter,FileFilterWithException<E>>
,PrimitiveReturnExceptionHandlerSupport<FileFilter,FileFilterWithException<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 FileFilterWithException<E extends Exception> extends PrimitiveReturnExceptionHandlerSupport<FileFilter,FileFilterWithException<E>>
A filter for abstract pathnames and may throw an exception.General contract
boolean accept(File path) throws E
- The functional method.- uncheck - Return a
FileFilter
- lift - Return a
FileFilter
- ignore - Return a
FileFilter
- Since:
- 1.1.0
- See Also:
FileFilter
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
accept(File pathname)
Tests whether or not the specified abstract pathname should be included in a pathname list.default FileFilterWithException<E>
and(FileFilterWithException<? extends E> other)
Returns a composed FileFilter that represents a short-circuiting logical AND of this FileFilter and another.default boolean
defaultValue()
Defines the default value returned by the ignore and ignored method.static <E extends Exception>
FileFilterWithException<E>failing(Supplier<E> exceptionBuilder)
Returns a FileFilter that always throw exception.static <E extends Exception>
FileFilterignored(FileFilterWithException<E> predicate)
Converts aFileFilterWithException
to a liftedFileFilter
returningfalse
in case of exception.static <E extends Exception>
FileFilterignored(FileFilterWithException<E> predicate, boolean defaultValue)
Converts aFileFilterWithException
to a liftedFileFilter
returning a default value in case of exception.static <E extends Exception>
FileFilterlifted(FileFilterWithException<E> predicate)
Converts aFileFilterWithException
to a liftedFileFilter
returningfalse
in case of exception.default FileFilterWithException<E>
negate()
Returns a FileFilter that represents the logical negation of this FileFilter.static <E extends Exception>
FileFilterWithException<E>negate(FileFilterWithException<E> predicate)
Negate aPredicateWithException
.default FileFilterWithException<E>
or(FileFilterWithException<? extends E> other)
Returns a composed FileFilter that represents a short-circuiting logical OR of this FileFilter and another.static <E extends Exception>
FileFilterunchecked(FileFilterWithException<E> predicate)
Converts aFileFilterWithException
to aFileFilter
that wraps exception toRuntimeException
.static <E extends Exception>
FileFilterunchecked(FileFilterWithException<E> predicate, Function<Exception,RuntimeException> exceptionMapper)
Converts aFileFilterWithException
to aFileFilter
that wraps exception toRuntimeException
by using the provided mapping function.default FileFilter
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
-
accept
boolean accept(File pathname) throws E extends Exception
Tests whether or not the specified abstract pathname should be included in a pathname list.- Parameters:
pathname
- The abstract pathname to be tested- Returns:
true
if and only ifpathname
should be included- Throws:
E
- any exceptionE extends Exception
- See Also:
FileFilter.accept(File)
-
uncheckOrIgnore
default FileFilter uncheckOrIgnore(boolean uncheck)
Description copied from interface:PrimitiveReturnExceptionHandlerSupport
Used internally to implements the ignore or uncheck operation.- Specified by:
uncheckOrIgnore
in interfacePrimitiveReturnExceptionHandlerSupport<FileFilter,FileFilterWithException<E extends Exception>>
- Parameters:
uncheck
- create unchecked version of the function when true, else ignored version.- Returns:
- the function
-
and
default FileFilterWithException<E> and(FileFilterWithException<? extends E> other)
Returns a composed FileFilter that represents a short-circuiting logical AND of this FileFilter and another. When evaluating the composed predicate, if this predicate isfalse
, then theother
predicate is not evaluated.Any exceptions thrown during evaluation of either FileFilter are relayed to the caller; if evaluation of this predicate throws an exception, the
other
FileFilter will not be evaluated.- Parameters:
other
- a FileFilter that will be logically-ANDed with this predicate- Returns:
- a composed FileFilter that represents the short-circuiting logical
AND of this FileFilter and the
other
FileFilter - Throws:
NullPointerException
- if other is null- See Also:
or(FileFilterWithException)
,negate()
-
negate
default FileFilterWithException<E> negate()
Returns a FileFilter that represents the logical negation of this FileFilter.- Returns:
- a FileFilter that represents the logical negation of this FileFilter
- See Also:
and(FileFilterWithException)
,or(FileFilterWithException)
-
negate
static <E extends Exception> FileFilterWithException<E> negate(FileFilterWithException<E> predicate)
Negate aPredicateWithException
.- Type Parameters:
E
- the type of the potential exception- Parameters:
predicate
- to be negate- Returns:
- the negated FileFilter
- Throws:
NullPointerException
- if predicate is null- See Also:
negate()
-
or
default FileFilterWithException<E> or(FileFilterWithException<? extends E> other)
Returns a composed FileFilter that represents a short-circuiting logical OR of this FileFilter and another. When evaluating the composed FileFilter, if this FileFilter istrue
, then theother
predicate is not evaluated.Any exceptions thrown during evaluation of either FileFilter are relayed to the caller; if evaluation of this FileFilter throws an exception, the
other
FileFilter will not be evaluated.- Parameters:
other
- a FileFilter that will be logically-ORed with this predicate- Returns:
- a composed FileFilter that represents the short-circuiting logical OR
of this predicate and the
other
FileFilter - Throws:
NullPointerException
- if other is null- See Also:
and(FileFilterWithException)
,negate()
-
failing
static <E extends Exception> FileFilterWithException<E> failing(Supplier<E> exceptionBuilder)
Returns a FileFilter that always throw exception.- Type Parameters:
E
- the type of the exception- Parameters:
exceptionBuilder
- the supplier to create the exception- Returns:
- a FileFilter that always throw exception
-
unchecked
static <E extends Exception> FileFilter unchecked(FileFilterWithException<E> predicate)
Converts aFileFilterWithException
to aFileFilter
that wraps exception toRuntimeException
.- Type Parameters:
E
- the type of the potential exception- Parameters:
predicate
- to be unchecked- Returns:
- the unchecked FileFilter
- Throws:
NullPointerException
- if predicate is null- See Also:
PrimitiveReturnExceptionHandlerSupport.uncheck()
,unchecked(FileFilterWithException, Function)
-
unchecked
static <E extends Exception> FileFilter unchecked(FileFilterWithException<E> predicate, Function<Exception,RuntimeException> exceptionMapper)
Converts aFileFilterWithException
to aFileFilter
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 FileFilter
- Throws:
NullPointerException
- if predicate or exceptionMapper is null- See Also:
PrimitiveReturnExceptionHandlerSupport.uncheck()
,unchecked(FileFilterWithException)
-
lifted
static <E extends Exception> FileFilter lifted(FileFilterWithException<E> predicate)
Converts aFileFilterWithException
to a liftedFileFilter
returningfalse
in case of exception.- Type Parameters:
E
- the type of the potential exception- Parameters:
predicate
- to be lifted- Returns:
- the lifted FileFilter
- Throws:
NullPointerException
- if predicate is null- See Also:
PrimitiveReturnExceptionHandlerSupport.lift()
-
ignored
static <E extends Exception> FileFilter ignored(FileFilterWithException<E> predicate)
Converts aFileFilterWithException
to a liftedFileFilter
returningfalse
in case of exception.- Type Parameters:
E
- the type of the potential exception- Parameters:
predicate
- to be lifted- Returns:
- the lifted FileFilter
- Throws:
NullPointerException
- if predicate is null- See Also:
PrimitiveReturnExceptionHandlerSupport.ignore()
-
ignored
static <E extends Exception> FileFilter ignored(FileFilterWithException<E> predicate, boolean defaultValue)
Converts aFileFilterWithException
to a liftedFileFilter
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 FileFilter
- Throws:
NullPointerException
- if predicate is null- Since:
- 3.0.0
- See Also:
PrimitiveReturnExceptionHandlerSupport.ignore()
,ignored(FileFilterWithException)
-
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
-
-