Interface EntityValidator

  • All Known Implementing Classes:
    DefaultEntityValidator

    public interface EntityValidator
    Responsible for providing validation for entities.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <T> boolean isNullable​(Entity entity, Attribute<T> attribute)
      Returns true if the property based on the given attribute accepts a null value for the given entity, by default this method simply returns the nullable state of the property.
      boolean isValid​(Entity entity)
      Returns true if the given entity contains only valid values.
      void validate​(Entity entity)
      Checks if the values in the given entity are valid
      <T> void validate​(Entity entity, Attribute<T> attribute)
      Checks if the value associated with the give attribute is valid, throws a ValidationException if not
    • Method Detail

      • isNullable

        <T> boolean isNullable​(Entity entity,
                               Attribute<T> attribute)
        Returns true if the property based on the given attribute accepts a null value for the given entity, by default this method simply returns the nullable state of the property.
        Type Parameters:
        T - the value type
        Parameters:
        entity - the entity being validated
        attribute - the attribute
        Returns:
        true if the attribute accepts a null value
      • isValid

        boolean isValid​(Entity entity)
        Returns true if the given entity contains only valid values.
        Parameters:
        entity - the entity
        Returns:
        true if the given entity contains only valid values
      • validate

        <T> void validate​(Entity entity,
                          Attribute<T> attribute)
                   throws ValidationException
        Checks if the value associated with the give attribute is valid, throws a ValidationException if not
        Type Parameters:
        T - the value type
        Parameters:
        entity - the entity to validate
        attribute - the attribute the value is associated with
        Throws:
        ValidationException - if the given value is not valid for the given attribute