Skip to content

Commit f2d8a3b

Browse files
Treiblesschorlegselzer
authored andcommitted
WIP: Add methods
1 parent a9ad155 commit f2d8a3b

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,19 @@ public static Class<?> erase(final Type type)
12281228
return GenericTypeReflector.erase(type);
12291229
}
12301230

1231+
/**
1232+
* See {@link GenericTypeReflector#getExactSuperType(Type, Class)}
1233+
*
1234+
* @param type
1235+
* @param searchClass
1236+
* @return
1237+
*/
1238+
public static Type getExactSuperType(final Type type,
1239+
final Class<?> searchClass)
1240+
{
1241+
return GenericTypeReflector.getExactSuperType(type, searchClass);
1242+
}
1243+
12311244
/**
12321245
* See {@link TypeUtils#unrollVariables(Map, Type, boolean)}
12331246
*
@@ -1242,6 +1255,23 @@ public static Type unrollVariables(Map<TypeVariable<?>, Type> typeArguments,
12421255
return TypeUtils.unrollVariables(typeArguments, type, followTypeVars);
12431256
}
12441257

1258+
/**
1259+
* Tries to parameterize the given raw type with its type parameters. If
1260+
* type is not raw, it will be returned. Otherwise, a parameterized type
1261+
* containing the type variables of the specified is returned.
1262+
*
1263+
* @param rawType
1264+
* the raw type to parameterize
1265+
* @return either the input of not raw, or a parameterized type
1266+
*/
1267+
public static Type parameterizeRaw(Class<?> rawType) {
1268+
TypeVariable<?>[] typeParams = rawType.getTypeParameters();
1269+
if (typeParams.length == 0) {
1270+
return rawType;
1271+
}
1272+
return Types.parameterize(rawType, typeParams);
1273+
}
1274+
12451275
// -- Helper methods --
12461276

12471277
private static IllegalArgumentException iae(final String... s) {

0 commit comments

Comments
 (0)