Class JavaTypeName
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 Summary
Modifier and TypeMethodDescriptionabstract booleancanCreateEnclosed(String simpleName) Check if an enclosed type with specified name can be created.static JavaTypeNameCreate a TypeName for an existing class.static JavaTypeNameCreate a TypeName for a top-level class.abstract JavaTypeNamecreateEnclosed(String simpleName) Create a TypeName for a class immediately enclosed by this class.final JavaTypeNamecreateEnclosed(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.abstract JavaTypeNamecreateSibling(String simpleName) Create a TypeName for a class that is a sibling of this class.final booleanfinal inthashCode()abstract Optional<JavaTypeName>Return the enclosing class JavaTypeName, if present.abstract StringReturn the package-local name by which this type can be referenced by classes living in the same package.Return broken-down package-local name components.abstract StringReturn the package name in which this class resides.final StringReturn the simple name of the class.abstract JavaTypeNameReturn the top-level class JavaTypeName which is containing this type, or self if this type is a top-level one.abstract StringtoString()Return the Fully-Qualified Class Name string of this TypeName.
-
Method Details
-
create
Create a TypeName for an existing class.- Parameters:
clazz- Class instance- Returns:
- A new TypeName
- Throws:
NullPointerException- if clazz is null
-
create
Create a TypeName for a top-level class.- Parameters:
packageName- Class package namesimpleName- Class simple name- Returns:
- A new TypeName.
- Throws:
NullPointerException- if any of the arguments is nullIllegalArgumentException- if any of the arguments is empty
-
canCreateEnclosed
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 emptyUnsupportedOperationException- if this type name does not support nested type
-
createEnclosed
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 nullIllegalArgumentException- if the simpleName hides any of the enclosing types or if it is emptyUnsupportedOperationException- if this type name does not support nested type
-
createEnclosed
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 classfallbackSuffix- Suffix to append if thesimpleNameis cannot be created due to JLS- Returns:
- A new TypeName.
- Throws:
NullPointerException- if any argument is nullIllegalArgumentException- if simpleName is empty or if both simpleName and fallback both hide any of the enclosing typesUnsupportedOperationException- if this type name does not support nested type
-
createSibling
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 nullIllegalArgumentException- if the simpleName is empty
-
simpleName
Return the simple name of the class.- Returns:
- Simple name of the class.
-
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
Return the enclosing class JavaTypeName, if present.- Returns:
- Enclosing class 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
Return the package-local name by which this type can be referenced by classes living in the same package.- Returns:
- Local name.
-
localNameComponents
Return broken-down package-local name components.- Returns:
- List of package-local components.
-
hashCode
public final int hashCode() -
equals
-
toString
Return the Fully-Qualified Class Name string of this TypeName.
-