Package de.gebit.integrity.utils
Class JavaTypeUtil
- java.lang.Object
-
- de.gebit.integrity.utils.JavaTypeUtil
-
public final class JavaTypeUtil extends Object
Util containing some helper methods dealing with Java types.- Author:
- Rene Schneider - initial API and implementation
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ParameterizedType
findGenericInterfaceOrSuperType(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 String
getBasicClassNameFromJvmType(org.eclipse.xtext.common.types.JvmType aType)
Resolves aJvmType
to its basic class name (= without array indicators, even if theJvmType
is anJvmArrayType
).static org.eclipse.xtext.common.types.JvmType
getBasicTypeFromJvmType(org.eclipse.xtext.common.types.JvmType aType)
Returns the underlying basicJvmType
for the providedJvmType
.static String
getReadableJavaTypeName(String aQualifiedTypeName)
Determines the readable java type name for the provided qualified name.static String
getReadableJavaTypeName(org.eclipse.xtext.common.types.JvmType aType)
Determines the readable java type name for the providedJvmType
.
-
-
-
Method Detail
-
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
public static String getReadableJavaTypeName(String aQualifiedTypeName)
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
public static String getReadableJavaTypeName(org.eclipse.xtext.common.types.JvmType aType)
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
public static String getBasicClassNameFromJvmType(org.eclipse.xtext.common.types.JvmType aType)
Resolves aJvmType
to its basic class name (= without array indicators, even if theJvmType
is 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 basicJvmType
for the providedJvmType
. This strips outJvmArrayType
s 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
-
-