jodd-bean/src/main/java/jodd/typeconverter/impl/FloatArrayConverter.java
protected float[] convertValueToArray(final Object value) {
		if (value instanceof Collection) {
			final Collection collection = (Collection) value;
			final float[] target = new float[collection.size()];

			int i = 0;
			for (final Object element : collection) {
				target[i] = convertType(element);
				i++;
			}

			return target;
		}

		if (value instanceof Iterable) {
			final Iterable iterable = (Iterable) value;

			final ArrayList<Float> floatArrayList = new ArrayList<>();

			for (final Object element : iterable) {
				final float convertedValue = convertType(element);
				floatArrayList.add(Float.valueOf(convertedValue));
			}

			final float[] array = new float[floatArrayList.size()];

			for (int i = 0; i < floatArrayList.size(); i++) {
				final Float f = floatArrayList.get(i);
				array[i] = f.floatValue();
			}

			return array;
		}

		if (value instanceof CharSequence) {
			final String[] strings = StringUtil.splitc(value.toString(), ArrayConverter.NUMBER_DELIMITERS);
			return convertArrayToArray(strings);
		}

		// everything else:
		return convertToSingleElementArray(value);
	}
protected float[] convertValueToArray(final Object value) {
		if (value instanceof Collection) {
			final Collection collection = (Collection) value;
			final float[] target = new float[collection.size()];

			int i = 0;
			for (final Object element : collection) {
				target[i] = convertType(element);
				i++;
			}

			return target;
		}

		if (value instanceof Iterable) {
			final Iterable iterable = (Iterable) value;

			final ArrayList<Float> floatArrayList = new ArrayList<>();

			for (final Object element : iterable) {
				final float convertedValue = convertType(element);
				floatArrayList.add(Float.valueOf(convertedValue));
			}

			final float[] array = new float[floatArrayList.size()];

			for (int i = 0; i < floatArrayList.size(); i++) {
				final Float f = floatArrayList.get(i);
				array[i] = f.floatValue();
			}

			return array;
		}

		if (value instanceof CharSequence) {
			final String[] strings = StringUtil.splitc(value.toString(), ArrayConverter.NUMBER_DELIMITERS);
			return convertArrayToArray(strings);
		}

		// everything else:
		return convertToSingleElementArray(value);
	}
protected float [ ] convertValueToArray ( final Object value ) { if ( value instanceof Collection ) { final Collection collection = ( Collection ) value ; final float [ ] target = new float [ collection . size ( ) ] ; int i = 0 ; for ( final Object element : collection ) { target [ i ] = convertType ( element ) ; i ++ ; } return target ; } if ( value instanceof Iterable ) { final Iterable iterable = ( Iterable ) value ; final ArrayList < Float > floatArrayList = new ArrayList <> ( ) ; for ( final Object element : iterable ) { final float convertedValue = convertType ( element ) ; floatArrayList . add ( Float . valueOf ( convertedValue ) ) ; } final float [ ] array = new float [ floatArrayList . size ( ) ] ; for ( int i = 0 ; i < floatArrayList . size ( ) ; i ++ ) { final Float f = floatArrayList . get ( i ) ; array [ i ] = f . floatValue ( ) ; } return array ; } if ( value instanceof CharSequence ) { final String [ ] strings = StringUtil . splitc ( value . toString ( ) , ArrayConverter . NUMBER_DELIMITERS ) ; return convertArrayToArray ( strings ) ; } // everything else: return convertToSingleElementArray ( value ) ; }
Converts non-array value to array. Detects various
collection types and iterates them to make conversion
and to create target array.
Converts non - array value to array . Detects various collection types and iterates them to make conversion and to create target array .