1 package spoon.support.reflect.declaration; 2 3 import java.util.Set ; 4 import java.util.TreeSet ; 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 27 public Set <CtMethod<?>> getAllMethods() { 28 Set <CtMethod<?>> ret = new TreeSet <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 |