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

public class ObjectValidator<T> extends Validator<T>
Validator for generic objects, including arrays.
  • Constructor Details

    • ObjectValidator

      public ObjectValidator(String propertyName, T propertyValue)
      Constructs a new validator.
      Parameters:
      propertyName - the property name corresponding to the object
      propertyValue - the object
  • Method Details

    • isNotNull

      public final void isNotNull()
      Asserts the object is not null.
    • isNotEmpty

      public final void isNotEmpty()
      Asserts the given object is not empty. An empty object is defined as:
      1. A null value,
      2. An array with length 0, or
      3. An Iterable that contains no elements, which applies to practically all collection types, .
    • isA

      public final <R extends T> R isA(Class<R> type)
      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