Skip to content

Commit 2bbf597

Browse files
committed
Types: add wildcard method for multiple bounds
In some cases -- especially internally -- it is helpful to have a wildcard type with multiple upper and/or lower bounds. While this is not allowed by the Java compiler at the source level, there are scenarios where it is helpful to have such types when reasoning about generics.
1 parent 25a4e94 commit 2bbf597

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main/java/org/scijava/util/Types.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,20 @@ public static WildcardType wildcard(final Type upperBound,
675675
return new TypeUtils.WildcardTypeImpl(upperBound, lowerBound);
676676
}
677677

678+
/**
679+
* Creates a new {@link WildcardType} with the given upper and/or lower
680+
* bounds.
681+
*
682+
* @param upperBounds Upper bounds of the wildcard, or null for none.
683+
* @param lowerBounds Lower bounds of the wildcard, or null for none.
684+
* @return The newly created {@link WildcardType}.
685+
*/
686+
public static WildcardType wildcard(final Type[] upperBounds,
687+
final Type[] lowerBounds)
688+
{
689+
return new TypeUtils.WildcardTypeImpl(upperBounds, lowerBounds);
690+
}
691+
678692
/**
679693
* Learn, recursively, whether any of the type parameters associated with
680694
* {@code type} are bound to variables.

0 commit comments

Comments
 (0)