Package org.moeaframework.util.validate
Class ObjectValidator<T>
java.lang.Object
org.moeaframework.util.validate.Validator<T>
org.moeaframework.util.validate.ObjectValidator<T>
- Type Parameters:
T- the object type
- Direct Known Subclasses:
ProblemValidator
Validator for generic objects, including arrays.
-
Constructor Summary
ConstructorsConstructorDescriptionObjectValidator(String propertyName, T propertyValue) Constructs a new validator. -
Method Summary
Modifier and TypeMethodDescriptionfinal <R extends T>
RAsserts the given object is the requested type.final voidAsserts the given object is not empty.final voidAsserts the object is notnull.Methods inherited from class org.moeaframework.util.validate.Validator
fails, failUnsupportedOption, failUnsupportedOption, getPropertyName, getPropertyValue
-
Constructor Details
-
ObjectValidator
Constructs a new validator.- Parameters:
propertyName- the property name corresponding to the objectpropertyValue- the object
-
-
Method Details
-
isNotNull
public final void isNotNull()Asserts the object is notnull. -
isNotEmpty
public final void isNotEmpty()Asserts the given object is not empty. An empty object is defined as:- A
nullvalue, - An array with length 0, or
- An
Iterablethat contains no elements, which applies to practically all collection types, .
- A
-
isA
Asserts the given object is the requested type. This method also returns the object cast to the type.- Type Parameters:
R- the return type- Parameters:
type- the requested type- Returns:
- the object cast to the requested type
-