Package de.gebit.integrity.utils
Class JavaTypeUtil
java.lang.Object
de.gebit.integrity.utils.JavaTypeUtil
Util containing some helper methods dealing with Java types.
- Author:
- Rene Schneider - initial API and implementation
-
Method Summary
Modifier and TypeMethodDescriptionstatic ParameterizedTypefindGenericInterfaceOrSuperType(Type aType, Class<?> aGenericInterfaceClass) Searches a class and attempts to find a generic superinterface of a certain type.static List<org.eclipse.xtext.common.types.JvmEnumerationLiteral> getAllEnumLiteralsFromJvmType(org.eclipse.xtext.common.types.JvmType aType) Returns a list of all valid enumeration literals that are defined in the given type.static StringgetBasicClassNameFromJvmType(org.eclipse.xtext.common.types.JvmType aType) Resolves aJvmTypeto its basic class name (= without array indicators, even if theJvmTypeis anJvmArrayType).static org.eclipse.xtext.common.types.JvmTypegetBasicTypeFromJvmType(org.eclipse.xtext.common.types.JvmType aType) Returns the underlying basicJvmTypefor the providedJvmType.static StringgetReadableJavaTypeName(String aQualifiedTypeName) Determines the readable java type name for the provided qualified name.static StringgetReadableJavaTypeName(org.eclipse.xtext.common.types.JvmType aType) Determines the readable java type name for the providedJvmType.
-
Method Details
-
findGenericInterfaceOrSuperType
public static ParameterizedType findGenericInterfaceOrSuperType(Type aType, Class<?> aGenericInterfaceClass) Searches a class and attempts to find a generic superinterface of a certain type. The result can be used to acquire the generic parameters of a class.- Parameters:
aType- the type to inspectaGenericInterfaceClass- the generic interface to search for (may be null, in which case the first generic superinterface that is found is returned)- Returns:
- the
ParameterizedType, if found, otherwise null
-
getReadableJavaTypeName
Determines the readable java type name for the provided qualified name. Returns short (non-fully-qualified) names for all the common Java types and fully qualified names for everything else.- Parameters:
aQualifiedTypeName- the type to investigate- Returns:
- the name
-
getReadableJavaTypeName
Determines the readable java type name for the providedJvmType. Returns short (non-fully-qualified) names for all the common Java types and fully qualified names for everything else.- Parameters:
aType- the type to investigate- Returns:
- the name
-
getBasicClassNameFromJvmType
Resolves aJvmTypeto its basic class name (= without array indicators, even if theJvmTypeis anJvmArrayType).- Parameters:
aType- the type to resolve- Returns:
- the fully-qualified class name of the type
-
getBasicTypeFromJvmType
public static org.eclipse.xtext.common.types.JvmType getBasicTypeFromJvmType(org.eclipse.xtext.common.types.JvmType aType) Returns the underlying basicJvmTypefor the providedJvmType. This strips outJvmArrayTypes and resolves them to the component type.- Parameters:
aType- the type to resolve- Returns:
- the basic type
-
getAllEnumLiteralsFromJvmType
public static List<org.eclipse.xtext.common.types.JvmEnumerationLiteral> getAllEnumLiteralsFromJvmType(org.eclipse.xtext.common.types.JvmType aType) Returns a list of all valid enumeration literals that are defined in the given type.- Parameters:
aType- the type- Returns:
- the enumeration literals, or none if the type reference doesn't refer to an enum type
-