I was wondering if there's a method to retrieve just the implemented
interfaces of a class - I know that they occur in the result-list of the
getSupertypes()/getAllSupertypes() method of a TypeDeclaration together with
the real/inheritance-based supertype(s), but is there also a seperate method
for just getting the interfaces? Or can I assume that each occuring element in
the result of getSupertypes() beside the first one is an interface?
Thanks for your help!
Steffen
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
you can assume that only for ClassDeclarations. There, the first item is
always a class, the rest (if any) interfaces (java.lang.Object doesn't have
any supertype at all, of course). For InterfaceDeclarations and
AnnotationDeclarations, the last item is java.lang.Object. For
EnumDeclarations, the first item is java.lang.Enum (well, a class), the other
interfaces.
A special case are TypeParameterDeclarations. A TypeParameterDeclaration's
supertypes are those defined in the bounds. There, one class and many
interfaces may be present. Recoder reports them in the same order as they are
declared in the source code, e.g., for
<T extends Serializable & AbstractList>
the first item returned by getSupertypes() is an interface, the second a
class.
/Tobias
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi everybody,
I was wondering if there's a method to retrieve just the implemented
interfaces of a class - I know that they occur in the result-list of the
getSupertypes()/getAllSupertypes() method of a TypeDeclaration together with
the real/inheritance-based supertype(s), but is there also a seperate method
for just getting the interfaces? Or can I assume that each occuring element in
the result of getSupertypes() beside the first one is an interface?
Thanks for your help!
Steffen
Hej,
you can assume that only for ClassDeclarations. There, the first item is
always a class, the rest (if any) interfaces (java.lang.Object doesn't have
any supertype at all, of course). For InterfaceDeclarations and
AnnotationDeclarations, the last item is java.lang.Object. For
EnumDeclarations, the first item is java.lang.Enum (well, a class), the other
interfaces.
A special case are TypeParameterDeclarations. A TypeParameterDeclaration's
supertypes are those defined in the bounds. There, one class and many
interfaces may be present. Recoder reports them in the same order as they are
declared in the source code, e.g., for
<T extends Serializable & AbstractList>
the first item returned by getSupertypes() is an interface, the second a
class.
/Tobias