From 9997b5c8df5703c4c96f412de55b4d0359ab154a Mon Sep 17 00:00:00 2001 From: Ralph Sanders <59902221+rlsanders4@users.noreply.github.com> Date: Wed, 13 Nov 2024 14:36:30 -0600 Subject: [PATCH] Update model for interfaces extending interfaces (#4663) * Add new test * Apply suggestions from code review * Fix test * Clean up * Added javadoc --------- Co-authored-by: Ralph-Sanders Co-authored-by: Tim te Beek --- .../src/main/java/org/openrewrite/java/tree/J.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/rewrite-java/src/main/java/org/openrewrite/java/tree/J.java b/rewrite-java/src/main/java/org/openrewrite/java/tree/J.java index 1f4ab2a97a6..8e16d3b757d 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/tree/J.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/tree/J.java @@ -1222,6 +1222,12 @@ public ClassDeclaration withPrimaryConstructor(@Nullable List primary @Nullable JLeftPadded extendings; + /** + * This is used to access the parent class. + * + * @return The parent class of the ClassDeclaration. If the ClassDeclaration is a class, this will return the + * class specified by the 'extends' keyword. If the ClassDeclaration is an interface, this will return null. + */ public @Nullable TypeTree getExtends() { return extendings == null ? null : extendings.getElement(); } @@ -1233,6 +1239,13 @@ public ClassDeclaration withExtends(@Nullable TypeTree extendings) { @Nullable JContainer implementings; + /** + * This is used to access the parent interfaces. + * + * @return A list of the parent interfaces of the ClassDeclaration. If the ClassDeclaration is a class, this + * will return the interfaces specified by the 'implements' keyword. If the ClassDeclaration is an interface, + * this will return the interfaces specified by the 'extends' keyword. + */ public @Nullable List getImplements() { return implementings == null ? null : implementings.getElements(); }