public final class PackageAndClass extends java.lang.Object
Constructor and Description |
---|
PackageAndClass(java.lang.String packageName,
java.lang.String className)
Makes a new package and class definition.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
className() |
PackageAndClass |
createInnerClass(java.lang.String name)
Create an inner class.
|
PackageAndClass |
createSiblingClass(java.lang.String name)
Create a sibling class.
|
PackageAndClass |
createSubPackage(java.lang.String name)
Create a sub-package.
|
boolean |
equals(java.lang.Object o) |
static PackageAndClass |
fromString(java.lang.String qualifiedName)
Extracts a package and class definition from a string.
|
int |
hashCode() |
boolean |
hasPackage()
Check if this
PackageAndClass has a package component. |
PackageAndClass |
inPackage(PackageAndClass parent)
Create a class in the same package as another one.
|
PackageAndClass |
inPackage(java.lang.String qualifiedName)
Create a class in another package.
|
java.lang.String |
mangledName() |
java.lang.String |
packageName() |
PackageAndClass |
parentPackage() |
java.lang.String |
toJVMRef() |
java.lang.String |
toJVMType() |
java.lang.String |
toString() |
public PackageAndClass(java.lang.String packageName, java.lang.String className)
packageName
- the package name.className
- the class name.public static PackageAndClass fromString(java.lang.String qualifiedName)
qualifiedName
- a qualified name.public PackageAndClass createInnerClass(java.lang.String name)
For instance:
PackageAndClass cls = new PackageAndClass("foo.bar", "Spam");
PackageAndClass inner = cls.createInnerClass("Egg"); // foo.bar.Spam$Egg
PackageAndClass
identifying an inner class of this class.public PackageAndClass createSiblingClass(java.lang.String name)
For instance:
PackageAndClass list = new PackageAndClass("java.util", "List");
PackageAndClass set = list.createSiblingClass("Set"); // java.util.Set
PackageAndClass
identifying an alternate class in the same package.public PackageAndClass createSubPackage(java.lang.String name)
For instance:
PackageAndClass pc = new PackageAndClass("foo.bar", "Module");
PackageAndClass sub = pc.createSubPackage("types"); // foo.bar.Modules.types
PackageAndClass
identifying a sub-package of this package.public PackageAndClass inPackage(java.lang.String qualifiedName)
For instance:
PackageAndClass pc = PackageAndClass.fromString("foo.bar.Baz");
PackageAndClass other = pc.inPackage("plic.ploc"); // plic.ploc.Baz
qualifiedName
- the qualified name of the new package.PackageAndClass
representing the same class in another package.public PackageAndClass inPackage(PackageAndClass parent)
For instance:
PackageAndClass pc = PackageAndClass.fromString("foo.bar.Baz");
PackageAndClass other = PackageAndClass.fromString("plic.ploc.Foo");
PackageAndClass newOne = pc.inPackage(other); // plic.ploc.Baz
parent
- the PackageAndClass
representing the new package.PackageAndClass
representing the same class in another package.public java.lang.String packageName()
public boolean hasPackage()
PackageAndClass
has a package component.public PackageAndClass parentPackage()
PackageAndClass
public java.lang.String className()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toJVMType()
foo.Bar
gives foo/Bar
.public java.lang.String toJVMRef()
foo.Bar
gives
Lfoo/Bar;
public java.lang.String mangledName()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object