Skip to content

Commit f843c98

Browse files
committed
Types: unify name and getTypeName methods
The difference was that getTypeName(Type) handled array types, too.
1 parent a61b506 commit f843c98

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

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

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,11 @@ public static Class<?> load(final String name, final ClassLoader classLoader,
219219
* @return The name of the given type.
220220
*/
221221
public static String name(final Type t) {
222-
// NB: It is annoying that Class.toString() prepends "class " or
223-
// "interface "; this method exists to work around that behavior.
224-
return t instanceof Class ? ((Class<?>) t).getName() : t.toString();
222+
if (t instanceof Class) {
223+
final Class<?> c = (Class<?>) t;
224+
return c.isArray() ? (name(component(c)) + "[]") : c.getName();
225+
}
226+
return t.toString();
225227
}
226228

227229
/**
@@ -3345,18 +3347,6 @@ public static Type capture(final Type type) {
33453347
return type;
33463348
}
33473349

3348-
/**
3349-
* Returns the display name of a Type.
3350-
*/
3351-
public static String getTypeName(final Type type) {
3352-
if (type instanceof Class) {
3353-
final Class<?> clazz = (Class<?>) type;
3354-
return clazz.isArray() ? (getTypeName(clazz.getComponentType()) + "[]")
3355-
: clazz.getName();
3356-
}
3357-
return type.toString();
3358-
}
3359-
33603350
/**
33613351
* Returns list of classes and interfaces that are supertypes of the given
33623352
* type. For example given this class:

0 commit comments

Comments
 (0)