Skip to content

Commit 4749590

Browse files
Treiblesschorlegselzer
authored andcommitted
Fix Struct parsing on functional interface level if only one @parameter annotation is present
1 parent bbb9ec5 commit 4749590

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎src/main/java/org/scijava/param/ParameterStructs.java‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,14 @@ public static List<Member<?>> parse(final Class<?> type)
5858

5959
final Class<?> paramsClass = findParametersDeclaration(type);
6060
if (paramsClass != null) {
61-
final Parameters params = paramsClass.getAnnotation(Parameters.class);
6261
final Class<?> functionalType = findFunctionalInterface(paramsClass);
63-
final Parameter[] p = params.value();
62+
Parameter[] p = null;
63+
final Parameters params = paramsClass.getAnnotation(Parameters.class);
64+
if (params != null) {
65+
p = params.value();
66+
} else {
67+
p = new Parameter[] {paramsClass.getAnnotation(Parameter.class)};
68+
}
6469
final int paramCount = functionalType.getTypeParameters().length;
6570
// TODO: Consider allowing partial override of class @Parameters.
6671
if (p.length == paramCount) {
@@ -153,7 +158,8 @@ private static Class<?> findParametersDeclaration(final Class<?> type) {
153158
types.add(type);
154159
while (!types.isEmpty()) {
155160
final Class<?> candidate = types.pop();
156-
if (candidate.getAnnotation(Parameters.class) != null) return candidate;
161+
if (candidate.getAnnotation(Parameters.class) != null ||
162+
candidate.getAnnotation(Parameter.class) != null) return candidate;
157163
final Class<?> superType = candidate.getSuperclass() ;
158164
if (superType != null) types.add(superType);
159165
types.addAll(Arrays.asList(candidate.getInterfaces()));

0 commit comments

Comments
 (0)