Skip to content

Commit

Permalink
improve ClassInfo.recordComponents() in case the class is not a record
Browse files Browse the repository at this point in the history
  • Loading branch information
Ladicek committed May 13, 2024
1 parent fdad231 commit 1d05389
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions core/src/main/java/org/jboss/jandex/ClassInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -885,12 +885,14 @@ public final RecordComponentInfo recordComponent(String name) {

/**
* Returns a list of all record components declared by this class.
* This list may be empty, but never null.
* This list may be empty, but never {@code null}.
* <p>
* If this class is not a record, returns an empty list.
*
* @return a list of record components
* @return immutable list of record components
*/
public final List<RecordComponentInfo> recordComponents() {
if (extra == null || extra.recordComponents == null) {
if (!isRecord() || extra == null || extra.recordComponents == null) {
return Collections.emptyList();
}

Expand All @@ -907,7 +909,7 @@ public final List<RecordComponentInfo> recordComponents() {
* assumes that the bytecode order corresponds to declaration order, which is not guaranteed,
* but practically always holds.
*
* @return a list of record components
* @return immutable list of record components
* @since 2.4
*/
public final List<RecordComponentInfo> unsortedRecordComponents() {
Expand Down

0 comments on commit 1d05389

Please sign in to comment.