blob: fbfe6c0c14fa8300f1bde72d12a73ac4fe38e353 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
package ftbsc.lll.proxies;
/**
* A container for information about a package.
* @since 0.4.0
*/
public class PackageProxy extends QualifiableProxy {
/**
* The {@link PackageProxy} representing the root package.
*/
public static final PackageProxy ROOT = new PackageProxy(null, "");
/**
* The protected constructor, called only from {@link PackageProxy#from(String)}.
* @param parent the {@link PackageProxy} representing the parent
* @param fqn the fully-qualified name of this package
*/
protected PackageProxy(PackageProxy parent, String fqn) {
super(null, 0, parent, fqn);
}
/**
* Builds a {@link PackageProxy} from its fully-qualified name.
* @param fqn the fully-qualified name of the package
* @return the built {@link PackageProxy}
*/
protected static PackageProxy from(String fqn) {
if(fqn == null || fqn.equals("")) return ROOT;
return new PackageProxy(from(extractParentFromFQN(fqn)), fqn);
}
/**
* Builds a {@link PackageProxy} from a reflective {@link Package} object.
* @param p the {@link Package} object
* @return the built {@link PackageProxy}
*/
protected static PackageProxy from(Package p) {
return from(extractParentFromFQN(p.getName()));
}
/**
* Indicates whether the given object is a proxy for the same element as this.
* @param obj the object to perform
* @return true if it's equal
*/
@Override
public boolean equals(Object obj) {
return obj instanceof PackageProxy && super.equals(obj);
}
}
|