Class TypeValidator


  • public class TypeValidator
    extends Object
    The TypeValidator allows to define which classes and packages may be handled by a codec. It thus represents a marshalling whitelist.
    • Method Detail

      • addClass

        public void addClass​(Class<?> clazz)
        Adds a class to the list.
        Parameters:
        clazz - class that should be added
      • addPackage

        public void addPackage​(String p)
        Adds a package to the list.
        Parameters:
        p - package that should be added
      • removeClass

        public void removeClass​(Class<?> clazz)
        Removes a class from the list.
        Parameters:
        clazz - class that should be removed
      • removePackage

        public void removePackage​(String p)
        Removes a package from the list.
        Parameters:
        p - package that should be removed
      • unwrapArrayComponentType

        public static Class<?> unwrapArrayComponentType​(Class<?> clazzToUnwrap)
        Returns the Class representing the component type of an array. If this class does not represent an array class this method returns the clazzToUnwrap.
        Parameters:
        clazzToUnwrap - class that should be unwrapped
        Returns:
        the Class representing the component type of this class if this class is an array, otherwise the input is returned
      • validate

        public boolean validate​(Class<?> clazzToTest)
        Validates a given Class if it is allowed or not.
        Parameters:
        clazzToTest - class that should be validated
        Returns:
        if the class is allowed or not
      • isTypeOf

        public static boolean isTypeOf​(Class<?> clazz,
                                       Class<?> superClass)
        Checks if clazz is a subclass of superClass.
        Parameters:
        clazz - possible subclass
        superClass - the superclass
        Returns:
        if clazz is a subclass of superClass true, otherwise false