Interface ClassNameMapper


public interface ClassNameMapper
Interface for a simple component capable of getting the name for a Class and vice-versa. The implementation is designed in a secure way as described in getClass(String).
This interface is designed for frameworks that need to do heavy generic stuff. It should not be used by end-users and the lazy initialization may consume some time.
Since:
1.0.0
See Also:
  • Method Details

    • getName

      String getName(Class<?> javaClass)
      Parameters:
      javaClass - the Class reflecting the type (class, interface, etc.) to map.
      Returns:
      the name of the given Class. By default this is the qualified name but it may also be the simple name or something else as long as it is unique.
      Throws:
      io.github.mmm.base.exception.ObjectNotFoundException - if the given Class is not mapped.
    • getClass

      Class<?> getClass(String name)
      Parameters:
      name - the name of the Class.
      Returns:
      the Class reflecting the type with the given name. Will be null if the type is not mapped. For security reasons by design no reflective lookup (class-loading) is triggered. This allows to deserialize or unmarshall polymorphic or generic data without allowing external users (or attackers) to trigger class-loading and potential code execution.
      Throws:
      io.github.mmm.base.exception.ObjectNotFoundException - if the given name is not mapped.
    • contains

      boolean contains(Class<?> javaClass)
      Parameters:
      javaClass - the class to check.
      Returns:
      true if the given class is mapped by this ClassNameMapper, false otherwise.
    • contains

      boolean contains(String name)
      Parameters:
      name - the name to check.
      Returns:
      true if the given name is mapped by this ClassNameMapper, false otherwise.
    • getClasses

      Iterator<Class<?>> getClasses(ClassNameMapper.ClassType classType)
      Parameters:
      classType - the ClassNameMapper.ClassType for which the Classes are requested.
      Returns:
      an Iterator of all Classes registered for the given ClassNameMapper.ClassType.
    • get

      static ClassNameMapper get()
      When you need to use this method, you need to have the following "requires [transitive]" statement in your module.
       requires io.github.mmm.bean.factory;
       
      Returns:
      the singleton instance of ClassNameMapper.