KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > spoon > support > reflect > declaration > CtInterfaceImpl


1 package spoon.support.reflect.declaration;
2
3 import java.util.Set JavaDoc;
4 import java.util.TreeSet JavaDoc;
5
6 import spoon.reflect.declaration.CtInterface;
7 import spoon.reflect.declaration.CtMethod;
8 import spoon.reflect.declaration.CtType;
9 import spoon.reflect.reference.CtTypeReference;
10 import spoon.reflect.visitor.CtVisitor;
11
12 public class CtInterfaceImpl<T> extends CtTypeImpl<T> implements CtInterface<T> {
13     private static final long serialVersionUID = 1L;
14
15 // @Override
16
// public List<CtField<?>> getAllFields() {
17
// List<CtField<?>> ret = new ArrayList<CtField<?>>();
18
// ret.addAll(getFields());
19
// for (CtTypeReference<?> ref : getSuperInterfaces()) {
20
// if (ref.getDeclaration() != null) {
21
// ret.addAll(ref.getDeclaration().getAllFields());
22
// }
23
// }
24
// return ret;
25
// }
26

27     public Set JavaDoc<CtMethod<?>> getAllMethods() {
28         Set JavaDoc<CtMethod<?>> ret = new TreeSet JavaDoc<CtMethod<?>>();
29         ret.addAll(getMethods());
30
31         for (CtTypeReference<?> ref : getSuperInterfaces()) {
32             if (ref.getDeclaration() != null) {
33                 CtType<?> t = (CtType<?>) ref.getDeclaration();
34                 ret.addAll(t.getAllMethods());
35             }
36         }
37         return ret;
38     }
39     
40     public void accept(CtVisitor visitor) {
41         visitor.visitCtInterface(this);
42     }
43
44     public boolean isSubtypeOf(CtTypeReference<?> type) {
45         for (CtTypeReference<?> ref : getSuperInterfaces()) {
46             if (ref.isSubtypeOf(type))
47                 return true;
48         }
49         return false;
50     }
51 }
52
Popular Tags