/** * Creates an array with single element. */ protected char[] convertToSingleElementArray(Object value) { return new char[] {convertType(value)}; }
/** * Creates an array with single element. */ protected double[] convertToSingleElementArray(Object value) { return new double[] {convertType(value)}; }
/** * Creates an array with single element. */ protected byte[] convertToSingleElementArray(Object value) { return new byte[] {convertType(value)}; }
public Collection<T> convert(Object value) { if (value == null) { return null; } if (!(value instanceof Collection)) { // source is not an array return convertValueToCollection(value); } // source is a collection return convertCollectionToCollection((Collection)value); }
/** * Creates an array with single element. */ protected T[] convertToSingleElementArray(Object value) { T[] singleElementArray = createArray(1); singleElementArray[0] = convertType(value); return singleElementArray; }
/** * Converts collection value to target collection. * Each element is converted to target component type. */ protected Collection<T> convertCollectionToCollection(Collection value) { Collection<T> collection = createCollection(value.size()); for (Object v : value) { collection.add(convertType(v)); } return collection; }
/** * Creates an array with single element. */ protected float[] convertToSingleElementArray(Object value) { return new float[] {convertType(value)}; }
/** * Creates an array with single element. */ protected int[] convertToSingleElementArray(Object value) { return new int[] {convertType(value)}; }
/** * Creates an array with single element. */ protected long[] convertToSingleElementArray(Object value) { return new long[] {convertType(value)}; }
/** * Creates an array with single element. */ protected short[] convertToSingleElementArray(Object value) { return new short[] {convertType(value)}; }
/** * Creates an array with single element. */ protected boolean[] convertToSingleElementArray(Object value) { return new boolean[] {convertType(value)}; }
/** * Creates a collection with single element. */ protected Collection<T> convertToSingleElementCollection(Object value) { Collection<T> collection = createCollection(0); collection.add((T) value); return collection; }
@Override public Collection<T> convert(final Object value) { if (value == null) { return null; } if (!(value instanceof Collection)) { // source is not an array return convertValueToCollection(value); } // source is a collection return convertCollectionToCollection((Collection)value); }
/** * Creates an array with single element. */ protected T[] convertToSingleElementArray(final Object value) { T[] singleElementArray = createArray(1); singleElementArray[0] = convertType(value); return singleElementArray; }
/** * Creates an array with single element. */ protected char[] convertToSingleElementArray(final Object value) { return new char[] {convertType(value)}; }
/** * Creates an array with single element. */ protected double[] convertToSingleElementArray(final Object value) { return new double[] {convertType(value)}; }
/** * Creates an array with single element. */ protected float[] convertToSingleElementArray(final Object value) { return new float[] {convertType(value)}; }
/** * Creates an array with single element. */ protected int[] convertToSingleElementArray(final Object value) { return new int[] {convertType(value)}; }
/** * Creates an array with single element. */ protected long[] convertToSingleElementArray(final Object value) { return new long[] {convertType(value)}; }
/** * Creates an array with single element. */ protected short[] convertToSingleElementArray(final Object value) { return new short[] {convertType(value)}; }