Class JavaQualifiedName
- java.lang.Object
-
- net.sourceforge.pmd.lang.java.ast.JavaQualifiedName
-
- All Implemented Interfaces:
net.sourceforge.pmd.lang.ast.QualifiedName
- Direct Known Subclasses:
JavaOperationQualifiedName
,JavaTypeQualifiedName
public abstract class JavaQualifiedName extends java.lang.Object implements net.sourceforge.pmd.lang.ast.QualifiedName
Unambiguous identifier for a java method or class. This implementation approaches the qualified name format found in stack traces for example, using a custom format specification (seeQualifiedNameFactory.ofString(String)
).Instances of this class are immutable. They can be obtained from the factory methods of
QualifiedNameFactory
, or fromJavaQualifiableNode.getQualifiedName()
on AST nodes that support it.Class qualified names follow the binary name spec.
Method qualified names don't follow a specification but allow to distinguish overloads of the same method, using parameter types and order.
- Since:
- 5.8.1
- Author:
- Clément Fournier
- See Also:
JavaTypeQualifiedName
,JavaOperationQualifiedName
-
-
Constructor Summary
Constructors Constructor Description JavaQualifiedName()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected abstract int
buildHashCode()
Computes the hashcode.protected abstract java.lang.String
buildToString()
Construct the toString once.boolean
equals(java.lang.Object o)
java.lang.String[]
getClasses()
Deprecated.abstract JavaTypeQualifiedName
getClassName()
java.lang.String
getClassSimpleName()
Deprecated.java.lang.String
getOperation()
Deprecated.java.lang.String[]
getPackages()
Deprecated.int
hashCode()
boolean
isLocalClass()
Deprecated.boolean
isUnnamedPackage()
Deprecated.static JavaQualifiedName
ofClass(java.lang.Class<?> clazz)
Deprecated.static JavaQualifiedName
ofString(java.lang.String name)
Deprecated.protected abstract boolean
structurallyEquals(JavaQualifiedName qname)
Returns true if the given qname is identical to this qname.java.lang.String
toString()
Returns the string representation of this qualified name.
-
-
-
Method Detail
-
getClassName
public abstract JavaTypeQualifiedName getClassName()
- Specified by:
getClassName
in interfacenet.sourceforge.pmd.lang.ast.QualifiedName
-
isLocalClass
@Deprecated public boolean isLocalClass()
Deprecated.UseJavaTypeQualifiedName.isLocalClass()
. Will be removed in 7.0.0Returns true if this qualified name identifies a local class.
-
getClassSimpleName
@Deprecated public java.lang.String getClassSimpleName()
Deprecated.UseJavaTypeQualifiedName.getClassSimpleName()
. Will be removed in 7.0.0Get the simple name of the class.
-
isUnnamedPackage
@Deprecated public boolean isUnnamedPackage()
Deprecated.UseJavaTypeQualifiedName.isUnnamedPackage()
. Will be removed in 7.0.0Returns true if the class represented by this qualified name is in the unnamed package.
-
getOperation
@Deprecated public java.lang.String getOperation()
Deprecated.UseJavaOperationQualifiedName.getOperation()
. Will be removed in 7.0.0Returns the operation specific part of the name. It identifies an operation in its namespace. Returnsnull
ifQualifiedName.isOperation()
returns false.- Returns:
- The operation string, or
null
.
-
getPackages
@Deprecated public java.lang.String[] getPackages()
Deprecated.UseJavaTypeQualifiedName.getPackageList()
()}. Will be removed in 7.0.0Returns the packages in order.
-
getClasses
@Deprecated public java.lang.String[] getClasses()
Deprecated.Use {JavaTypeQualifiedName.getClassList()
. Will be removed in 7.0.0Returns the classes in order.
-
equals
public final boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
structurallyEquals
protected abstract boolean structurallyEquals(JavaQualifiedName qname)
Returns true if the given qname is identical to this qname. Performs a structural comparison. Used in the implementation ofequals(Object)
after taking shortcuts.- Parameters:
qname
- The other comparand. Can always be casted down to the subclass type in which this method is overridden
-
hashCode
public final int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
buildHashCode
protected abstract int buildHashCode()
Computes the hashcode. Called once, then cached. Since QualifiedNames are mostly used as the keys of a map, caching the hashcode makes sense.
-
toString
public final java.lang.String toString()
Returns the string representation of this qualified name. The representation follows the format defined forQualifiedNameFactory.ofString(String)
.- Specified by:
toString
in interfacenet.sourceforge.pmd.lang.ast.QualifiedName
- Overrides:
toString
in classjava.lang.Object
-
ofString
@Deprecated public static JavaQualifiedName ofString(java.lang.String name)
Deprecated.UseQualifiedNameFactory.ofString(String)
. Will be removed in 7.0.0
-
ofClass
@Deprecated public static JavaQualifiedName ofClass(java.lang.Class<?> clazz)
Deprecated.UseQualifiedNameFactory.ofClass(Class)
. Will be removed in 7.0.0
-
buildToString
protected abstract java.lang.String buildToString()
Construct the toString once. Called only once per instance
-
-