Class TypeResolver
- java.lang.Object
-
- de.iip_ecosphere.platform.services.spring.descriptor.TypeResolver
-
public class TypeResolver extends java.lang.ObjectResolves declared types to dynamic Java classes (just attributes).- Author:
- Holger Eichelberger, SSE
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.lang.Class<?>>classesprivate java.lang.ClassLoaderloaderprivate static java.util.Map<java.lang.String,java.lang.Class<?>>PRIMITIVES
-
Constructor Summary
Constructors Constructor Description TypeResolver(java.util.List<? extends Type> declarations)Creates a type resolver and creates internal classes fordeclarations.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleancreateClasses(Type type)Creates the classes for a given descriptor-defined type.private java.util.List<Type>createClasses(java.util.List<? extends Type> declarations)Creates classes for all given typedeclarations.static booleanisPrimitive(java.lang.String name)Returns whether a given type name is considered to be pre-defined/primitive (including "String").java.lang.Class<?>resolve(java.lang.String name)Resolve a type name to a type.
-
-
-
Constructor Detail
-
TypeResolver
public TypeResolver(java.util.List<? extends Type> declarations)
Creates a type resolver and creates internal classes fordeclarations.- Parameters:
declarations- the type declarations to be used as descriptor-defined types
-
-
Method Detail
-
createClasses
private java.util.List<Type> createClasses(java.util.List<? extends Type> declarations)
Creates classes for all given typedeclarations.- Parameters:
declarations- the declarations- Returns:
- the left-over types that cannot be resolved, e.g., due to cyclic dependencies; empty if completely successful
-
isPrimitive
public static boolean isPrimitive(java.lang.String name)
Returns whether a given type name is considered to be pre-defined/primitive (including "String").- Parameters:
name- the name to look for- Returns:
truefor primitive/pre-defined,falseelse
-
createClasses
private boolean createClasses(Type type)
Creates the classes for a given descriptor-defined type.- Parameters:
type- the type- Returns:
trueif thetypeis resolvable, the class was created and registered;falseif the resolution failed, e.g., as required types are not (yet) defined.
-
resolve
public java.lang.Class<?> resolve(java.lang.String name)
Resolve a type name to a type. Considers pre-defined types (PRIMITIVES) as well as descriptor-defined types used as input to this instance.- Parameters:
name- the type name- Returns:
- the type, may be null
-
-