Class Constants


  • public class Constants
    extends Object
    Author:
    scf
    • Method Detail

      • throwIfNullOrTypeNot

        public static <T> T throwIfNullOrTypeNot​(Object entity,
                                                 Class<T> targetClass)
        Throws an IllegalArgumentException if entity is not an instance of targetClass, or if entity is null. Returns the entity so calls can be chained.
        Type Parameters:
        T - The type of the entity (auto detected)
        Parameters:
        entity - The entity to check the class of.
        targetClass - The class to check the entity against.
        Returns:
        The entity to check.
      • throwIfTypeNot

        public static <T> T throwIfTypeNot​(Object entity,
                                           Class<T> targetClass)
        Throws an IllegalArgumentException if entity is not an instance of targetClass. Does not throw if entity is null. Returns the entity so calls can be chained.
        Type Parameters:
        T - The type of the entity (auto detected)
        Parameters:
        entity - The entity to check the class of.
        targetClass - The class to check the entity against.
        Returns:
        The entity to check.