Skip to content

Commit

Permalink
Update model for interfaces extending interfaces (openrewrite#4663)
Browse files Browse the repository at this point in the history
* Add new test

* Apply suggestions from code review

* Fix test

* Clean up

* Added javadoc

---------

Co-authored-by: Ralph-Sanders <[email protected]>
Co-authored-by: Tim te Beek <[email protected]>
  • Loading branch information
3 people authored and MBoegers committed Dec 18, 2024
1 parent 64845de commit 1923939
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions rewrite-java/src/main/java/org/openrewrite/java/tree/J.java
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,12 @@ public ClassDeclaration withPrimaryConstructor(@Nullable List<Statement> primary
@Nullable
JLeftPadded<TypeTree> 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();
}
Expand All @@ -1233,6 +1239,13 @@ public ClassDeclaration withExtends(@Nullable TypeTree extendings) {
@Nullable
JContainer<TypeTree> 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<TypeTree> getImplements() {
return implementings == null ? null : implementings.getElements();
}
Expand Down

0 comments on commit 1923939

Please sign in to comment.