Skip to content

Commit

Permalink
Add constructors method to ClassInfo
Browse files Browse the repository at this point in the history
The idea was brought up by @mkouba
in quarkusio/quarkus#8321 (comment)
  • Loading branch information
geoand committed Apr 1, 2020
1 parent ad7ce19 commit 9010ef8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/main/java/org/jboss/jandex/ClassInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.jboss.jandex;

import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -301,6 +302,25 @@ public final List<MethodInfo> methods() {
return new MethodInfoGenerator(this, methods);
}

/**
* Returns a list of all constructors declared in this class (which the JVM names "&lt;init&gt;").
* It does not include inherited methods.
* These must be discovered by traversing the class hierarchy.
*
* <p>This list may never be null.</p>
*
* @return the list of constructors declared in this class
*/
public final List<MethodInfo> constructors() {
List<MethodInfo> constructors = new ArrayList<MethodInfo>(1);
for (MethodInfo method : methods()) {
if ("<init>".equals(method.name())) {
constructors.add(method);
}
}
return constructors;
}

final MethodInternal[] methodArray() {
return methods;
}
Expand Down

0 comments on commit 9010ef8

Please sign in to comment.