Interface ObjectInputFilterWithException<E extends Exception>
-
- Type Parameters:
E
- the type of the potential exception of the function
- All Superinterfaces:
ExceptionHandlerSupport<ObjectInputFilter,Function<ObjectInputFilter.FilterInfo,Optional<ObjectInputFilter.Status>>,ObjectInputFilterWithException<E>>
,ObjectReturnExceptionHandlerSupport<ObjectInputFilter,Function<ObjectInputFilter.FilterInfo,Optional<ObjectInputFilter.Status>>,Function<ObjectInputFilter.FilterInfo,CompletionStage<ObjectInputFilter.Status>>,ObjectInputFilter.Status,ObjectInputFilterWithException<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 ObjectInputFilterWithException<E extends Exception> extends ObjectReturnExceptionHandlerSupport<ObjectInputFilter,Function<ObjectInputFilter.FilterInfo,Optional<ObjectInputFilter.Status>>,Function<ObjectInputFilter.FilterInfo,CompletionStage<ObjectInputFilter.Status>>,ObjectInputFilter.Status,ObjectInputFilterWithException<E>>
Filter classes, array lengths, and graph metrics during deserialization that may throw exception. If set on anObjectInputStream
, thecheckInput(FilterInfo)
method is called to validate classes, the length of each array, the number of objects being read from the stream, the depth of the graph, and the total number of bytes read from the stream.General contract
Status checkInput(FilterInfo filterInfo) throws E
- The functional method.- uncheck - Return a
ObjectInputFilter
- lift - Return a
Function<FilterInfo, Optional<Status>>
- ignore - Return a
ObjectInputFilter
- Since:
- 2.0.0
- See Also:
ObjectInputFilter
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ObjectInputFilter.Status
checkInput(ObjectInputFilter.FilterInfo filterInfo)
Check the class, array length, number of object references, depth, stream size, and other available filtering information.default ObjectInputFilter.Status
defaultValue()
Defines the default value (by defaultnull
) returned by the ignore and ignored method.static <E extends Exception>
ObjectInputFilterWithException<E>failing(Supplier<E> exceptionBuilder)
Returns a ObjectInputFilter that always throw exception.default ObjectInputFilter
ignore()
Converts thisObjectInputFilterWithException
to a liftedObjectInputFilter
returningStatus.UNDECIDED
(or the value redefined by the methoddefaultValue()
) in case of exception.static <E extends Exception>
ObjectInputFilterignored(ObjectInputFilterWithException<E> function)
Converts aObjectInputFilterWithException
to a liftedObjectInputFilter
returningStatus.UNDECIDED
in case of exception.static <E extends Exception>
ObjectInputFilterignored(ObjectInputFilterWithException<E> function, ObjectInputFilter.Status defaultValue)
Converts aObjectInputFilterWithException
to a liftedObjectInputFilter
returning a default value in case of exception.default Function<ObjectInputFilter.FilterInfo,Optional<ObjectInputFilter.Status>>
lift()
Converts thisObjectInputFilterWithException
to a liftedFunction
usingOptional
as return value.static <E extends Exception>
Function<ObjectInputFilter.FilterInfo,Optional<ObjectInputFilter.Status>>lifted(ObjectInputFilterWithException<E> function)
Converts aObjectInputFilterWithException
to a liftedObjectInputFilter
usingOptional
as return value.default Function<ObjectInputFilter.FilterInfo,CompletionStage<ObjectInputFilter.Status>>
stage()
Convert thisObjectInputFilterWithException
to a liftedObjectInputFilter
returnCompletionStage
as return value.static <E extends Exception>
Function<ObjectInputFilter.FilterInfo,CompletionStage<ObjectInputFilter.Status>>staged(ObjectInputFilterWithException<E> function)
Convert thisObjectInputFilterWithException
to a liftedFunction
returnCompletionStage
as return value.default ObjectInputFilter
uncheck()
Converts thisObjectInputFilterWithException
to aObjectInputFilter
that convert exception toRuntimeException
.static <E extends Exception>
ObjectInputFilterunchecked(ObjectInputFilterWithException<E> function)
Converts aObjectInputFilterWithException
to aObjectInputFilter
that convert exception toRuntimeException
.static <E extends Exception>
ObjectInputFilterunchecked(ObjectInputFilterWithException<E> function, Function<Exception,RuntimeException> exceptionMapper)
Converts aObjectInputFilterWithException
to aObjectInputFilter
that wraps exception toRuntimeException
by using the provided mapping function.-
Methods inherited from interface ch.powerunit.extensions.exceptions.ExceptionHandlerSupport
documented, exceptionMapper
-
Methods inherited from interface ch.powerunit.extensions.exceptions.ObjectReturnExceptionHandlerSupport
notThrowingHandler, throwingHandler
-
-
-
-
Method Detail
-
checkInput
ObjectInputFilter.Status checkInput(ObjectInputFilter.FilterInfo filterInfo) throws E extends Exception
Check the class, array length, number of object references, depth, stream size, and other available filtering information. Implementations of this method check the contents of the object graph being created during deserialization. The filter returnsStatus.ALLOWED
,Status.REJECTED
, orStatus.UNDECIDED
.- Parameters:
filterInfo
- provides information about the current object being deserialized, if any, and the status of theObjectInputStream
- Returns:
Status.ALLOWED
if accepted,Status.REJECTED
if rejected,Status.UNDECIDED
if undecided.- Throws:
E
- any exceptionE extends Exception
- See Also:
ObjectInputFilter.checkInput(java.io.ObjectInputFilter.FilterInfo)
-
uncheck
default ObjectInputFilter uncheck()
Converts thisObjectInputFilterWithException
to aObjectInputFilter
that convert exception toRuntimeException
.- Specified by:
uncheck
in interfaceExceptionHandlerSupport<ObjectInputFilter,Function<ObjectInputFilter.FilterInfo,Optional<ObjectInputFilter.Status>>,ObjectInputFilterWithException<E extends Exception>>
- Specified by:
uncheck
in interfaceObjectReturnExceptionHandlerSupport<ObjectInputFilter,Function<ObjectInputFilter.FilterInfo,Optional<ObjectInputFilter.Status>>,Function<ObjectInputFilter.FilterInfo,CompletionStage<ObjectInputFilter.Status>>,ObjectInputFilter.Status,ObjectInputFilterWithException<E extends Exception>>
- Returns:
- the unchecked ObjectInputFilter
- See Also:
unchecked(ObjectInputFilterWithException)
,unchecked(ObjectInputFilterWithException, Function)
,ObjectInputFilter
-
lift
default Function<ObjectInputFilter.FilterInfo,Optional<ObjectInputFilter.Status>> lift()
Converts thisObjectInputFilterWithException
to a liftedFunction
usingOptional
as return value.- Specified by:
lift
in interfaceExceptionHandlerSupport<ObjectInputFilter,Function<ObjectInputFilter.FilterInfo,Optional<ObjectInputFilter.Status>>,ObjectInputFilterWithException<E extends Exception>>
- Specified by:
lift
in interfaceObjectReturnExceptionHandlerSupport<ObjectInputFilter,Function<ObjectInputFilter.FilterInfo,Optional<ObjectInputFilter.Status>>,Function<ObjectInputFilter.FilterInfo,CompletionStage<ObjectInputFilter.Status>>,ObjectInputFilter.Status,ObjectInputFilterWithException<E extends Exception>>
- Returns:
- the lifted function
- See Also:
lifted(ObjectInputFilterWithException)
,Function
-
defaultValue
default ObjectInputFilter.Status defaultValue()
Description copied from interface:ObjectReturnExceptionHandlerSupport
Defines the default value (by defaultnull
) returned by the ignore and ignored method.- Specified by:
defaultValue
in interfaceObjectReturnExceptionHandlerSupport<ObjectInputFilter,Function<ObjectInputFilter.FilterInfo,Optional<ObjectInputFilter.Status>>,Function<ObjectInputFilter.FilterInfo,CompletionStage<ObjectInputFilter.Status>>,ObjectInputFilter.Status,ObjectInputFilterWithException<E extends Exception>>
- Returns:
- the default value for the ignore/ignored method.
-
ignore
default ObjectInputFilter ignore()
Converts thisObjectInputFilterWithException
to a liftedObjectInputFilter
returningStatus.UNDECIDED
(or the value redefined by the methoddefaultValue()
) in case of exception.- Specified by:
ignore
in interfaceExceptionHandlerSupport<ObjectInputFilter,Function<ObjectInputFilter.FilterInfo,Optional<ObjectInputFilter.Status>>,ObjectInputFilterWithException<E extends Exception>>
- Specified by:
ignore
in interfaceObjectReturnExceptionHandlerSupport<ObjectInputFilter,Function<ObjectInputFilter.FilterInfo,Optional<ObjectInputFilter.Status>>,Function<ObjectInputFilter.FilterInfo,CompletionStage<ObjectInputFilter.Status>>,ObjectInputFilter.Status,ObjectInputFilterWithException<E extends Exception>>
- Returns:
- the function that ignore error
- See Also:
ignored(ObjectInputFilterWithException)
,Function
-
stage
default Function<ObjectInputFilter.FilterInfo,CompletionStage<ObjectInputFilter.Status>> stage()
Convert thisObjectInputFilterWithException
to a liftedObjectInputFilter
returnCompletionStage
as return value.- Specified by:
stage
in interfaceObjectReturnExceptionHandlerSupport<ObjectInputFilter,Function<ObjectInputFilter.FilterInfo,Optional<ObjectInputFilter.Status>>,Function<ObjectInputFilter.FilterInfo,CompletionStage<ObjectInputFilter.Status>>,ObjectInputFilter.Status,ObjectInputFilterWithException<E extends Exception>>
- Returns:
- the lifted function
- See Also:
staged(ObjectInputFilterWithException)
,CompletionStage
-
failing
static <E extends Exception> ObjectInputFilterWithException<E> failing(Supplier<E> exceptionBuilder)
Returns a ObjectInputFilter that always throw exception.- Type Parameters:
E
- the type of the exception- Parameters:
exceptionBuilder
- the supplier to create the ObjectInputFilter the type of the result of the function- Returns:
- a ObjectInputFilter that always throw exception
-
unchecked
static <E extends Exception> ObjectInputFilter unchecked(ObjectInputFilterWithException<E> function)
Converts aObjectInputFilterWithException
to aObjectInputFilter
that convert exception toRuntimeException
.- Type Parameters:
E
- the type of the potential exception- Parameters:
function
- to be unchecked- Returns:
- the unchecked exception
- Throws:
NullPointerException
- if function is null- See Also:
uncheck()
,unchecked(ObjectInputFilterWithException, Function)
-
unchecked
static <E extends Exception> ObjectInputFilter unchecked(ObjectInputFilterWithException<E> function, Function<Exception,RuntimeException> exceptionMapper)
Converts aObjectInputFilterWithException
to aObjectInputFilter
that wraps exception toRuntimeException
by using the provided mapping function.- Type Parameters:
E
- the type of the potential exception- Parameters:
function
- the be uncheckedexceptionMapper
- a function to convert the exception to the runtime exception.- Returns:
- the unchecked exception
- Throws:
NullPointerException
- if function or exceptionMapper is null- See Also:
uncheck()
,unchecked(ObjectInputFilterWithException)
-
lifted
static <E extends Exception> Function<ObjectInputFilter.FilterInfo,Optional<ObjectInputFilter.Status>> lifted(ObjectInputFilterWithException<E> function)
Converts aObjectInputFilterWithException
to a liftedObjectInputFilter
usingOptional
as return value.- Type Parameters:
E
- the type of the potential exception- Parameters:
function
- to be lifted- Returns:
- the lifted function
- Throws:
NullPointerException
- if function is null- See Also:
lift()
-
ignored
static <E extends Exception> ObjectInputFilter ignored(ObjectInputFilterWithException<E> function)
Converts aObjectInputFilterWithException
to a liftedObjectInputFilter
returningStatus.UNDECIDED
in case of exception.- Type Parameters:
E
- the type of the potential exception- Parameters:
function
- to be lifted- Returns:
- the lifted function
- Throws:
NullPointerException
- if function is null- See Also:
ignore()
-
ignored
static <E extends Exception> ObjectInputFilter ignored(ObjectInputFilterWithException<E> function, ObjectInputFilter.Status defaultValue)
Converts aObjectInputFilterWithException
to a liftedObjectInputFilter
returning a default value in case of exception.- Type Parameters:
E
- the type of the potential exception- Parameters:
function
- to be lifteddefaultValue
- the default value in case of exception. Can't be null.- Returns:
- the lifted function
- Throws:
NullPointerException
- if function or defaultValue is null- Since:
- 3.0.0
- See Also:
ignore()
,ignored(ObjectInputFilterWithException)
-
staged
static <E extends Exception> Function<ObjectInputFilter.FilterInfo,CompletionStage<ObjectInputFilter.Status>> staged(ObjectInputFilterWithException<E> function)
Convert thisObjectInputFilterWithException
to a liftedFunction
returnCompletionStage
as return value.- Type Parameters:
E
- the type of the potential exception- Parameters:
function
- to be lifted- Returns:
- the lifted function
- Throws:
NullPointerException
- if function is null- See Also:
stage()
-
-