java.lang.Object
org.opendaylight.mdsal.binding.model.api.JavaTypeName
All Implemented Interfaces:
Serializable, org.opendaylight.yangtools.concepts.Identifier, org.opendaylight.yangtools.concepts.Immutable

@Beta @NonNullByDefault public abstract sealed class JavaTypeName extends Object implements org.opendaylight.yangtools.concepts.Identifier, org.opendaylight.yangtools.concepts.Immutable
A type name. This class encloses Java type naming rules laid down in The Java Language Specification, notably sections 4 and 8. It deals with primitive, array and reference types.
Author:
Robert Varga
See Also:
  • Method Details

    • create

      public static JavaTypeName create(Class<?> clazz)
      Create a TypeName for an existing class.
      Parameters:
      clazz - Class instance
      Returns:
      A new TypeName
      Throws:
      NullPointerException - if clazz is null
    • create

      public static JavaTypeName create(String packageName, String simpleName)
      Create a TypeName for a top-level class.
      Parameters:
      packageName - Class package name
      simpleName - Class simple name
      Returns:
      A new TypeName.
      Throws:
      NullPointerException - if any of the arguments is null
      IllegalArgumentException - if any of the arguments is empty
    • canCreateEnclosed

      public abstract boolean canCreateEnclosed(String simpleName)
      Check if an enclosed type with specified name can be created.
      Parameters:
      simpleName - Simple name of the enclosed class
      Returns:
      True if the proposed simple name does not conflict with any enclosing types
      Throws:
      IllegalArgumentException - if the simpleName is empty
      UnsupportedOperationException - if this type name does not support nested type
    • createEnclosed

      public abstract JavaTypeName createEnclosed(String simpleName)
      Create a TypeName for a class immediately enclosed by this class.
      Parameters:
      simpleName - Simple name of the enclosed class
      Returns:
      A new TypeName.
      Throws:
      NullPointerException - if simpleName is null
      IllegalArgumentException - if the simpleName hides any of the enclosing types or if it is empty
      UnsupportedOperationException - if this type name does not support nested type
    • createEnclosed

      public final JavaTypeName createEnclosed(String simpleName, String fallbackSuffix)
      Create a TypeName for a class immediately enclosed by this class, potentially falling back to appending it with a suffix if a JLS hiding conflict occurs.
      Parameters:
      simpleName - Simple name of the enclosed class
      fallbackSuffix - Suffix to append if the simpleName is cannot be created due to JLS
      Returns:
      A new TypeName.
      Throws:
      NullPointerException - if any argument is null
      IllegalArgumentException - if simpleName is empty or if both simpleName and fallback both hide any of the enclosing types
      UnsupportedOperationException - if this type name does not support nested type
    • createSibling

      public abstract JavaTypeName createSibling(String simpleName)
      Create a TypeName for a class that is a sibling of this class. A sibling has the same package name, and the same immediately enclosing class.
      Parameters:
      simpleName - Simple name of the sibling class
      Returns:
      A new TypeName.
      Throws:
      NullPointerException - if simpleName is null
      IllegalArgumentException - if the simpleName is empty
    • simpleName

      public final String simpleName()
      Return the simple name of the class.
      Returns:
      Simple name of the class.
    • packageName

      public abstract String packageName()
      Return the package name in which this class resides. This does not account for any class nesting, i.e. for nested classes this returns the package name of the top-level class in naming hierarchy.
      Returns:
      Package name of the class.
    • immediatelyEnclosingClass

      public abstract Optional<JavaTypeName> immediatelyEnclosingClass()
      Return the enclosing class JavaTypeName, if present.
      Returns:
      Enclosing class JavaTypeName.
    • topLevelClass

      public abstract JavaTypeName topLevelClass()
      Return the top-level class JavaTypeName which is containing this type, or self if this type is a top-level one.
      Returns:
      Top-level JavaTypeName
    • localName

      public abstract String localName()
      Return the package-local name by which this type can be referenced by classes living in the same package.
      Returns:
      Local name.
    • localNameComponents

      public abstract List<String> localNameComponents()
      Return broken-down package-local name components.
      Returns:
      List of package-local components.
    • hashCode

      public final int hashCode()
      Specified by:
      hashCode in interface org.opendaylight.yangtools.concepts.Identifier
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(@Nullable Object obj)
      Specified by:
      equals in interface org.opendaylight.yangtools.concepts.Identifier
      Overrides:
      equals in class Object
    • toString

      public abstract String toString()
      Return the Fully-Qualified Class Name string of this TypeName.
      Specified by:
      toString in interface org.opendaylight.yangtools.concepts.Identifier
      Overrides:
      toString in class Object
      Returns:
      Fully-Qualified Class Name string of this TypeName.