Class ClassUtils


public final class ClassUtils extends ClassUtils
  • Constructor Details

    • ClassUtils

      public ClassUtils()
  • Method Details

    • buildApplicationObject

      public static <T> T buildApplicationObject(Class<T> interfaceClass, Collection<String> classNamesIterator, T defaultObject)
      Creates ApplicationObjects like NavigationHandler or StateManager and creates the right wrapping chain of the ApplicationObjects known as the decorator pattern.
      Type Parameters:
      T -
      Parameters:
      interfaceClass - The class from which the implementation has to inherit from.
      classNamesIterator - All the class names of the actual ApplicationObject implementations from the faces-config.xml.
      defaultObject - The default implementation for the given ApplicationObject.
      Returns:
    • buildApplicationObject

      public static <T> T buildApplicationObject(Class<T> interfaceClass, Class<? extends T> extendedInterfaceClass, Class<? extends T> extendedInterfaceWrapperClass, Collection<String> classNamesIterator, T defaultObject)
      Creates ApplicationObjects like NavigationHandler or StateManager and creates the right wrapping chain of the ApplicationObjects known as the decorator pattern.
      Type Parameters:
      T -
      Parameters:
      interfaceClass - The class from which the implementation has to inherit from.
      extendedInterfaceClass - A subclass of interfaceClass which specifies a more detailed implementation.
      extendedInterfaceWrapperClass - A wrapper class for the case that you have an ApplicationObject which only implements the interfaceClass but not the extendedInterfaceClass.
      classNamesIterator - All the class names of the actual ApplicationObject implementations from the faces-config.xml.
      defaultObject - The default implementation for the given ApplicationObject.
      Returns:
    • wrapBackwardCompatible

      public static <T> T wrapBackwardCompatible(Class<T> interfaceClass, Class<? extends T> extendedInterfaceClass, Class<? extends T> extendedInterfaceWrapperClass, T defaultObject, T newCurrent)
      Wrap an object using a backwards compatible wrapper if available
      Parameters:
      interfaceClass - The class from which the implementation has to inherit from.
      extendedInterfaceClass - A subclass of interfaceClass which specifies a more detailed implementation.
      extendedInterfaceWrapperClass - A wrapper class for the case that you have an ApplicationObject which only implements the interfaceClass but not the extendedInterfaceClass.
      defaultObject - The default implementation for the given ApplicationObject.
      newCurrent - The new current object
      Returns:
    • classForName

      public static <T> Class<T> classForName(String type) throws ClassNotFoundException
      Tries a Class.loadClass with the context class loader of the current thread first and automatically falls back to the ClassUtils class loader (i.e. the loader of the myfaces.jar lib) if necessary.
      Parameters:
      type - fully qualified name of a non-primitive non-array class
      Returns:
      the corresponding Class
      Throws:
      NullPointerException - if type is null
      ClassNotFoundException
    • simpleClassForName

      public static Class simpleClassForName(String type)
      Same as classForName(String), but throws a RuntimeException (FacesException) instead of a ClassNotFoundException.
      Returns:
      the corresponding Class
      Throws:
      NullPointerException - if type is null
      FacesException - if class not found
    • simpleClassForName

      public static Class simpleClassForName(String type, boolean logException)
      Same as {link simpleClassForName(String), but will only log the exception and rethrow a RunTimeException if logException is true.
      Parameters:
      type -
      logException - - true to log/throw FacesException, false to avoid logging/throwing FacesException
      Returns:
      the corresponding Class
      Throws:
      FacesException - if class not found and logException is true
    • getResource

      public static URL getResource(String resource)
    • getResourceAsStream

      public static InputStream getResourceAsStream(String resource)
    • paramString

      protected static final String paramString(Class<?>... types)