4848import org .scijava .util .ArrayUtils ;
4949import org .scijava .util .ClassUtils ;
5050import org .scijava .util .ConversionUtils ;
51- import org .scijava .util .GenericUtils ;
51+ import org .scijava .util .Types ;
5252
5353/**
5454 * Default {@link Converter} implementation. Provides useful conversion
@@ -79,8 +79,10 @@ public class DefaultConverter extends AbstractConverter<Object, Object> {
7979 public Object convert (final Object src , final Type dest ) {
8080
8181 // Handle array types, including generic array types.
82- if (isArray (dest )) {
83- return convertToArray (src , GenericUtils .getComponentClass (dest ));
82+ final Type componentType = Types .component (dest );
83+ if (componentType != null ) {
84+ // NB: Destination is an array type.
85+ return convertToArray (src , Types .raw (componentType ));
8486 }
8587
8688 // Handle parameterized collection types.
@@ -89,7 +91,7 @@ public Object convert(final Object src, final Type dest) {
8991 }
9092
9193 // This wasn't a collection or array, so convert it as a single element.
92- return convert (src , GenericUtils . getClass (dest ));
94+ return convert (src , Types . raw (dest ));
9395 }
9496
9597 @ Override
@@ -100,7 +102,7 @@ public <T> T convert(final Object src, final Class<T> dest) {
100102 // Handle array types
101103 if (isArray (dest )) {
102104 @ SuppressWarnings ("unchecked" )
103- T array = (T ) convertToArray (src , GenericUtils . getComponentClass ( dest ));
105+ T array = (T ) convertToArray (src , Types . raw ( Types . component ( dest ) ));
104106 return array ;
105107 }
106108
@@ -216,12 +218,11 @@ private Constructor<?> getConstructor(final Class<?> type,
216218 }
217219
218220 private boolean isArray (final Type type ) {
219- return GenericUtils . getComponentClass (type ) != null ;
221+ return Types . component (type ) != null ;
220222 }
221223
222224 private boolean isCollection (final Type type ) {
223- return ConversionUtils .canCast (GenericUtils .getClass (type ),
224- Collection .class );
225+ return ConversionUtils .canCast (Types .raw (type ), Collection .class );
225226 }
226227
227228 private Object
@@ -247,8 +248,7 @@ private boolean isCollection(final Type type) {
247248 private Object convertToCollection (final Object value ,
248249 final ParameterizedType pType )
249250 {
250- final Collection <Object > collection =
251- createCollection (GenericUtils .getClass (pType ));
251+ final Collection <Object > collection = createCollection (Types .raw (pType ));
252252 if (collection == null ) return null ;
253253
254254 // Populate the collection.
@@ -298,7 +298,7 @@ public boolean canConvert(final Class<?> src, final Type dest) {
298298
299299 // Handle parameterized collection types.
300300 if (dest instanceof ParameterizedType && isCollection (dest ) &&
301- createCollection (GenericUtils . getClass (dest )) != null )
301+ createCollection (Types . raw (dest )) != null )
302302 {
303303 return true ;
304304 }
0 commit comments