Class DefaultTypeName

java.lang.Object
io.helidon.common.types.DefaultTypeName
All Implemented Interfaces:
TypeName, Comparable<TypeName>

public class DefaultTypeName extends Object implements TypeName
Default implementation for TypeName.
  • Constructor Details

  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      the fqName().
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(TypeName o)
      Specified by:
      compareTo in interface Comparable<TypeName>
    • create

      public static DefaultTypeName create(String packageName, String className)
      Creates a type name from a package name and simple class name.
      Parameters:
      packageName - the package name
      className - the simple class type name
      Returns:
      the TypeName for the provided package and class names
    • create

      public static DefaultTypeName create(Class<?> classType)
      Creates a type name from a class.
      Parameters:
      classType - the class type
      Returns:
      the TypeName for the provided class type
    • createFromGenericDeclaration

      public static DefaultTypeName createFromGenericDeclaration(String genericAliasTypeName)
      Creates a type name from a generic alias type name.
      Parameters:
      genericAliasTypeName - the generic alias type name
      Returns:
      the TypeName for the provided type name
    • createFromTypeName

      public static DefaultTypeName createFromTypeName(String typeName)
      Creates a type name from a fully qualified class name.
      Parameters:
      typeName - the FQN of the class type
      Returns:
      the TypeName for the provided type name
    • createExtendsTypeName

      public static TypeName createExtendsTypeName(TypeName typeName)
      Given a typeName X, will return an typeName of "? extends X".
      Parameters:
      typeName - the typeName
      Returns:
      the wildcard extension of the given typeName
    • ensureIsFQN

      public static void ensureIsFQN(TypeName name)
      Throws an exception if the provided type name is not fully qualified, having a package and class name representation.
      Parameters:
      name - the type name to check
      Throws:
      IllegalStateException - if the name is invalid
    • isFQN

      public static boolean isFQN(TypeName name)
      Returns true if the provided type name is fully qualified, having a package and class name representation.
      Parameters:
      name - the type name to check
      Returns:
      true if the provided name is fully qualified
    • packageName

      public String packageName()
      Description copied from interface: TypeName
      Functions the same as Class.getPackageName().
      Specified by:
      packageName in interface TypeName
      Returns:
      the package name, never null
    • className

      public String className()
      Description copied from interface: TypeName
      Functions the same as Class.getSimpleName().
      Specified by:
      className in interface TypeName
      Returns:
      the simple class name
    • primitive

      public boolean primitive()
      Description copied from interface: TypeName
      Functions the same as Class.isPrimitive().
      Specified by:
      primitive in interface TypeName
      Returns:
      true if this type represents a primitive type.
    • array

      public boolean array()
      Description copied from interface: TypeName
      Functions the same as Class.isArray().
      Specified by:
      array in interface TypeName
      Returns:
      true if this type represents a primitive array [].
    • generic

      public boolean generic()
      Description copied from interface: TypeName
      Indicates whether this type is using generics.
      Specified by:
      generic in interface TypeName
      Returns:
      used to represent a generic (e.g., "Optional<CB>").
    • wildcard

      public boolean wildcard()
      Description copied from interface: TypeName
      Indicates whether this type is using wildcard generics.
      Specified by:
      wildcard in interface TypeName
      Returns:
      used to represent a wildcard (e.g., "? extends SomeType").
    • typeArguments

      public List<TypeName> typeArguments()
      Description copied from interface: TypeName
      Returns the list of generic type parameters, or an empty list if no generics are in use.
      Specified by:
      typeArguments in interface TypeName
      Returns:
      the type arguments of this type, if this type supports generics/parameterized type.
    • name

      public String name()
      Description copied from interface: TypeName
      The base name that includes the package name concatenated with the class name. Similar to Type.getTypeName().
      Specified by:
      name in interface TypeName
      Returns:
      the base type name given the set package and class name, but not including the generics/parameterized types.
    • declaredName

      public String declaredName()
      Description copied from interface: TypeName
      Typically used as part of code-gen, when ".class" is tacked onto the suffix of what this returns.
      Specified by:
      declaredName in interface TypeName
      Returns:
      same as getName() unless the type is an array, and then will add "[]" to the return.
    • fqName

      public String fqName()
      Description copied from interface: TypeName
      The fully qualified type name. This will include the generic portion of the declaration, as well as any array declaration, etc.
      Specified by:
      fqName in interface TypeName
      Returns:
      the fully qualified name which includes the use of generics/parameterized types, arrays, etc.
    • calcName

      protected String calcName()
      Calculates the name - this is lazily deferred until referenced in name().
      Returns:
      the name
    • calcFQName

      protected String calcFQName()
      Calculates the fully qualified name - this is lazily deferred until referenced in fqName().
      Returns:
      the fully qualified name
    • builder

      public static DefaultTypeName.Builder builder()
      Creates a builder for TypeName.
      Returns:
      a fluent builder
    • toBuilder

      public static DefaultTypeName.Builder toBuilder(TypeName val)
      Creates a builder initialized with a value passed.
      Parameters:
      val - the value
      Returns:
      a fluent builder
    • toBuilder

      public DefaultTypeName.Builder toBuilder()
      Creates a builder initialized with the current values.
      Returns:
      a fluent builder