01: package spoon.support.reflect.cu;
02:
03: import spoon.reflect.cu.Import;
04: import spoon.reflect.reference.CtFieldReference;
05: import spoon.reflect.reference.CtPackageReference;
06: import spoon.reflect.reference.CtReference;
07: import spoon.reflect.reference.CtTypeReference;
08:
09: public class ImportImpl implements Import {
10:
11: public ImportImpl(CtTypeReference<?> type) {
12: reference = type;
13: }
14:
15: public ImportImpl(CtPackageReference pack) {
16: reference = pack;
17: }
18:
19: public ImportImpl(CtFieldReference<?> field) {
20: reference = field;
21: }
22:
23: CtReference reference;
24:
25: @Override
26: public String toString() {
27: String str = "import " + reference.toString();
28: if (reference instanceof CtPackageReference) {
29: str += ".*";
30: }
31: return str;
32: }
33:
34: @Override
35: public boolean equals(Object obj) {
36: if (obj instanceof Import) {
37: return reference.equals(((Import) obj).getReference());
38: }
39: return false;
40: }
41:
42: public CtReference getReference() {
43: return reference;
44: }
45:
46: }
|