Skip to content

Commit 25a4e94

Browse files
committed
Types: shorten names of type creator methods
The following methods are renamed: * newWildcardType -> wildcard * newParameterizedType -> parameterize I was originally concerned that without the "new" prefix, it would not be clear that these methods are creating new Type instances, rather than somehow extracting them. But the distinction is sort of artificial -- there are other methods in Types that also create new Type instances internally, but do not have a "new" prefix. I think the new names read just fine (e.g., Types.wildcard()) and the "new" is not needed here.
1 parent 84c21d4 commit 25a4e94

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -631,10 +631,10 @@ public static <T> T cast(final Object src, final Class<T> dest) {
631631
* @param typeArgs The type arguments to use in parameterizing it.
632632
* @return The newly created {@link ParameterizedType}.
633633
*/
634-
public static ParameterizedType newParameterizedType(final Class<?> rawType,
634+
public static ParameterizedType parameterize(final Class<?> rawType,
635635
final Type... typeArgs)
636636
{
637-
return newParameterizedType(rawType, rawType.getDeclaringClass(), typeArgs);
637+
return parameterize(rawType, rawType.getDeclaringClass(), typeArgs);
638638
}
639639

640640
/**
@@ -646,7 +646,7 @@ public static ParameterizedType newParameterizedType(final Class<?> rawType,
646646
* @param typeArgs The type arguments to use in parameterizing it.
647647
* @return The newly created {@link ParameterizedType}.
648648
*/
649-
public static ParameterizedType newParameterizedType(final Class<?> rawType,
649+
public static ParameterizedType parameterize(final Class<?> rawType,
650650
final Type ownerType, final Type... typeArgs)
651651
{
652652
return new TypeUtils.ParameterizedTypeImpl(rawType, ownerType, typeArgs);
@@ -658,8 +658,8 @@ public static ParameterizedType newParameterizedType(final Class<?> rawType,
658658
*
659659
* @return The newly created {@link WildcardType}.
660660
*/
661-
public static WildcardType newWildcardType() {
662-
return newWildcardType(null, null);
661+
public static WildcardType wildcard() {
662+
return wildcard((Type) null, (Type) null);
663663
}
664664

665665
/**
@@ -669,7 +669,7 @@ public static WildcardType newWildcardType() {
669669
* @param lowerBound Lower bound of the wildcard, or null for none.
670670
* @return The newly created {@link WildcardType}.
671671
*/
672-
public static WildcardType newWildcardType(final Type upperBound,
672+
public static WildcardType wildcard(final Type upperBound,
673673
final Type lowerBound)
674674
{
675675
return new TypeUtils.WildcardTypeImpl(upperBound, lowerBound);
@@ -2998,7 +2998,7 @@ else if (isMissingTypeParameters(clazz)) {
29982998
Arrays.fill(arguments, UNBOUND_WILDCARD);
29992999
final Type owner = clazz.getDeclaringClass() == null ? null
30003000
: addWildcardParameters(clazz.getDeclaringClass());
3001-
return newParameterizedType(clazz, owner, arguments);
3001+
return parameterize(clazz, owner, arguments);
30023002
}
30033003
else {
30043004
return clazz;
@@ -3378,7 +3378,7 @@ public static Type capture(final Type type) {
33783378
}
33793379
final Type ownerType = (pType.getOwnerType() == null) ? null : capture(
33803380
pType.getOwnerType());
3381-
return newParameterizedType(clazz, ownerType, capturedArguments);
3381+
return parameterize(clazz, ownerType, capturedArguments);
33823382
}
33833383
return type;
33843384
}
@@ -3556,7 +3556,7 @@ else if (type instanceof TypeVariable) {
35563556
}
35573557
else if (type instanceof ParameterizedType) {
35583558
final ParameterizedType pType = (ParameterizedType) type;
3559-
return newParameterizedType((Class<?>) pType.getRawType(), pType
3559+
return parameterize((Class<?>) pType.getRawType(), pType
35603560
.getOwnerType() == null ? pType.getOwnerType() : map(pType
35613561
.getOwnerType()), map(pType.getActualTypeArguments()));
35623562
}

0 commit comments

Comments
 (0)