Skip to content

Commit 30a3246

Browse files
ctruedenGabriel Selzer
and
Gabriel Selzer
committed
Types: Refactor parameterizeWithOwner params
This breaks backwards compatibility. But there was a type argument clash with the other methods called parameterize, so it's better to rename this one to something unique, to avoid confusion. We'll call it "new API". ;-) Co-authored-by: Gabriel Selzer <gselzer@wisc.edu>
1 parent fbf4248 commit 30a3246

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111

1212
<artifactId>scijava-common</artifactId>
13-
<version>2.77.1-SNAPSHOT</version>
13+
<version>2.78.0-SNAPSHOT</version>
1414

1515
<name>SciJava Common</name>
1616
<description>SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by downstream projects in the SciJava ecosystem, such as ImageJ and SCIFIO.</description>

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@
7070
import java.util.Objects;
7171
import java.util.Set;
7272

73-
import org.scijava.util.FileUtils;
74-
7573
/**
7674
* Utility class for working with generic types, fields and methods.
7775
* <p>
@@ -86,6 +84,7 @@
8684
* </ul>
8785
*
8886
* @author Curtis Rueden
87+
* @author Gabe Selzer
8988
*/
9089
public final class Types {
9190

@@ -791,22 +790,22 @@ public static <T> T enumValue(final String name, final Class<T> dest) {
791790
public static ParameterizedType parameterize(final Class<?> rawType,
792791
final Type... typeArgs)
793792
{
794-
return parameterize(rawType, rawType.getDeclaringClass(), typeArgs);
793+
return parameterizeWithOwner(null, rawType, typeArgs);
795794
}
796795

797796
/**
798797
* Creates a new {@link ParameterizedType} of the given class together with
799798
* the specified type arguments.
800799
*
801-
* @param rawType The class of the {@link ParameterizedType}.
802800
* @param ownerType The owner type of the parameterized class.
801+
* @param rawType The class of the {@link ParameterizedType}.
803802
* @param typeArgs The type arguments to use in parameterizing it.
804803
* @return The newly created {@link ParameterizedType}.
805804
*/
806-
public static ParameterizedType parameterize(final Class<?> rawType,
807-
final Type ownerType, final Type... typeArgs)
805+
public static ParameterizedType parameterizeWithOwner(final Type ownerType,
806+
final Class<?> rawType, final Type... typeArgs)
808807
{
809-
return new TypeUtils.ParameterizedTypeImpl(rawType, ownerType, typeArgs);
808+
return TypeUtils.parameterizeWithOwner(ownerType, rawType, typeArgs);
810809
}
811810

812811
/**
@@ -3206,7 +3205,7 @@ else if (isMissingTypeParameters(clazz)) {
32063205
Arrays.fill(arguments, UNBOUND_WILDCARD);
32073206
final Type owner = clazz.getDeclaringClass() == null ? null
32083207
: addWildcardParameters(clazz.getDeclaringClass());
3209-
return parameterize(clazz, owner, arguments);
3208+
return parameterizeWithOwner(owner, clazz, arguments);
32103209
}
32113210
else {
32123211
return clazz;
@@ -3584,9 +3583,9 @@ public static Type capture(final Type type) {
35843583
for (final CaptureTypeImpl captured : toInit) {
35853584
captured.init(varMap);
35863585
}
3587-
final Type ownerType = (pType.getOwnerType() == null) ? null : capture(
3586+
final Type ownerType = pType.getOwnerType() == null ? null : capture(
35883587
pType.getOwnerType());
3589-
return parameterize(clazz, ownerType, capturedArguments);
3588+
return parameterizeWithOwner(ownerType, clazz, capturedArguments);
35903589
}
35913590
return type;
35923591
}
@@ -3764,9 +3763,10 @@ else if (type instanceof TypeVariable) {
37643763
}
37653764
else if (type instanceof ParameterizedType) {
37663765
final ParameterizedType pType = (ParameterizedType) type;
3767-
return parameterize((Class<?>) pType.getRawType(), pType
3768-
.getOwnerType() == null ? pType.getOwnerType() : map(pType
3769-
.getOwnerType()), map(pType.getActualTypeArguments()));
3766+
final Type ownerType = pType.getOwnerType() == null ? //
3767+
pType.getOwnerType() : map(pType.getOwnerType());
3768+
return parameterizeWithOwner(ownerType, (Class<?>) pType.getRawType(),
3769+
map(pType.getActualTypeArguments()));
37703770
}
37713771
else if (type instanceof WildcardType) {
37723772
final WildcardType wType = (WildcardType) type;

0 commit comments

Comments
 (0)