Package me.croabeast.common.applier
Interface Applier<T>
- Type Parameters:
T- the type of the object being transformed.
- All Known Subinterfaces:
StringApplier
public interface Applier<T>
Represents a generic applier that allows successive transformations on an object.
Implementations of ObjectApplier enable chaining of UnaryOperator transformations
based on an optional priority. After applying a series of operators, the final result can be obtained
via the result() method.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumRepresents the priority levels for transformation operators. -
Method Summary
Modifier and TypeMethodDescriptionapply(UnaryOperator<T> operator) Applies the given transformation operator at the default priority (NORMAL).apply(Applier.Priority priority, UnaryOperator<T> operator) Applies the given transformation operator with the specified priority.static <T> Applier<T> prioritized(Applier<T> applier) Creates a prioritizedObjectApplierby extracting the result from an existing applier.static <T> Applier<T> prioritized(T object) Creates a prioritizedObjectApplierfor the provided object.result()Returns the final result after applying all the transformations.static <T> Applier<T> simplified(Applier<T> applier) Creates a simplifiedObjectApplierby extracting the result from an existing applier.static <T> Applier<T> simplified(T object) Creates a simplifiedObjectApplierfor the provided object.
-
Method Details
-
apply
Applies the given transformation operator with the specified priority.- Parameters:
priority- the priority at which to apply the operator.operator- the transformation to apply.- Returns:
- this
ObjectApplierinstance for chaining. - Throws:
NullPointerException- ifoperatorisnull.
-
apply
Applies the given transformation operator at the default priority (NORMAL).- Parameters:
operator- the transformation to apply.- Returns:
- this
ObjectApplierinstance for chaining. - Throws:
NullPointerException- ifoperatorisnull.
-
result
T result()Returns the final result after applying all the transformations.- Returns:
- the transformed object.
-
simplified
Creates a simplifiedObjectApplierfor the provided object.- Type Parameters:
T- the type of the object.- Parameters:
object- the object to transform.- Returns:
- a new instance of a simplified
ObjectApplier.
-
simplified
Creates a simplifiedObjectApplierby extracting the result from an existing applier.- Type Parameters:
T- the type of the object.- Parameters:
applier- the existing applier.- Returns:
- a new instance of a simplified
ObjectApplierinitialized with the result.
-
prioritized
Creates a prioritizedObjectApplierfor the provided object.- Type Parameters:
T- the type of the object.- Parameters:
object- the object to transform.- Returns:
- a new instance of a prioritized
ObjectApplier.
-
prioritized
Creates a prioritizedObjectApplierby extracting the result from an existing applier.- Type Parameters:
T- the type of the object.- Parameters:
applier- the existing applier.- Returns:
- a new instance of a prioritized
ObjectApplierinitialized with the result.
-