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 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 inspect
      aGenericInterfaceClass - 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 provided JvmType. 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 a JvmType to its basic class name (= without array indicators, even if the JvmType is an JvmArrayType).
      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 basic JvmType for the provided JvmType. This strips out JvmArrayTypes 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