Class ArgumentValidator<T>
- java.lang.Object
-
- me.s3ns3iw00.jcommands.argument.validator.ArgumentValidator<T>
-
- Type Parameters:
T
- the argument's input type
- All Implemented Interfaces:
java.util.function.Function<T,java.util.Optional<ArgumentMismatchEventListener>>
public class ArgumentValidator<T> extends java.lang.Object implements java.util.function.Function<T,java.util.Optional<ArgumentMismatchEventListener>>
AFunction
that validates the argument's value by specific validation aspects
-
-
Constructor Summary
Constructors Constructor Description ArgumentValidator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<ArgumentMismatchEventListener>
apply(T value)
Checks whether the given value is validstatic <T> ArgumentValidator<T>
build()
Instantiates the class staticallyArgumentValidation<T>
when(java.util.function.Predicate<T> predicate)
Creates a validationArgumentValidation<T>
when(ArgumentPredicate<T> predicate)
Creates a validation withArgumentPredicate
-
-
-
Method Detail
-
when
public ArgumentValidation<T> when(java.util.function.Predicate<T> predicate)
Creates a validation- Parameters:
predicate
- is thePredicate
- Returns:
- the
ArgumentValidation
-
when
public ArgumentValidation<T> when(ArgumentPredicate<T> predicate)
Creates a validation withArgumentPredicate
- Parameters:
predicate
- is thePredicate
- Returns:
- the
ArgumentValidation
-
apply
public java.util.Optional<ArgumentMismatchEventListener> apply(T value)
Checks whether the given value is valid- Specified by:
apply
in interfacejava.util.function.Function<T,java.util.Optional<ArgumentMismatchEventListener>>
- Parameters:
value
- the function argument- Returns:
- an
Optional
with the validator'sArgumentMismatchEventListener
that is for which the value is not valid
-
build
public static <T> ArgumentValidator<T> build()
Instantiates the class statically- Type Parameters:
T
- the generic type of theArgumentValidator
- Returns:
- the
ArgumentValidator
-
-