public interface ClassNameMapper
Interface for a simple component capable of
This interface is designed for frameworks that need to do heavy generic stuff. It should not be used by end-users and the
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:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumType ofClasses managed by thisClassNameMapper. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanstatic ClassNameMapperget()When you need to use this method, you need to have the following "requires [transitive]" statement in your module.Class<?> getClasses(ClassNameMapper.ClassType classType) getNameOrQualified(Class<?> javaClass)
-
Method Details
-
getName
- Parameters:
javaClass- theClassreflecting the type (class, interface, etc.) to map.- Returns:
- the name of the given
Class. By default this is thequalified namebut it may also be thesimple nameor something else as long as it is unique. - Throws:
io.github.mmm.base.exception.ObjectNotFoundException- if the givenClassis not mapped.
-
getNameOrQualified
- Parameters:
javaClass- theClassreflecting the type (class, interface, etc.) to map.- Returns:
- the name of the given
Class. By default this is thequalified namebut it may also be thesimple nameor something else as long as it is unique. If the givenClassis notmapped, thequalified nameof the givenClassis returned.
-
getClass
- Parameters:
name- thenameof theClass.- Returns:
- the
Classreflecting the type with the givenname. Will benullif 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 givennameis not mapped.
-
contains
- Parameters:
javaClass- theclassto check.- Returns:
trueif the givenclassis mapped by thisClassNameMapper,falseotherwise.
-
contains
- Parameters:
name- thenameto check.- Returns:
trueif the givennameis mapped by thisClassNameMapper,falseotherwise.
-
getClasses
- Parameters:
classType- theClassNameMapper.ClassTypefor which theClasses are requested.- Returns:
- an
Iteratorof allClasses registered for the givenClassNameMapper.ClassType.
-
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.
-