jodd-bean/src/main/java/jodd/typeconverter/impl/CharacterArrayConverter.java
protected char[] convertValueToArray(final Object value) {
		if (value instanceof Collection) {
			final Collection collection = (Collection) value;
			final char[] target = new char[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<Character> charArrayList = new ArrayList<>();

			for (final Object element : iterable) {
				final char convertedValue = convertType(element);
				charArrayList.add(Character.valueOf(convertedValue));
			}

			final char[] array = new char[charArrayList.size()];

			for (int i = 0; i < charArrayList.size(); i++) {
				final Character c = charArrayList.get(i);
				array[i] = c.charValue();
			}

			return array;

		}

		if (value instanceof CharSequence) {
			final CharSequence charSequence = (CharSequence) value;

			final char[] result = new char[charSequence.length()];

			for (int i = 0; i < result.length; i++) {
				result[i] = charSequence.charAt(i);
			}

			return result;
		}

		// everything else:
		return convertToSingleElementArray(value);
	}
protected char[] convertValueToArray(final Object value) {
		if (value instanceof Collection) {
			final Collection collection = (Collection) value;
			final char[] target = new char[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<Character> charArrayList = new ArrayList<>();

			for (final Object element : iterable) {
				final char convertedValue = convertType(element);
				charArrayList.add(Character.valueOf(convertedValue));
			}

			final char[] array = new char[charArrayList.size()];

			for (int i = 0; i < charArrayList.size(); i++) {
				final Character c = charArrayList.get(i);
				array[i] = c.charValue();
			}

			return array;

		}

		if (value instanceof CharSequence) {
			final CharSequence charSequence = (CharSequence) value;

			final char[] result = new char[charSequence.length()];

			for (int i = 0; i < result.length; i++) {
				result[i] = charSequence.charAt(i);
			}

			return result;
		}

		// everything else:
		return convertToSingleElementArray(value);
	}
protected char [ ] convertValueToArray ( final Object value ) { if ( value instanceof Collection ) { final Collection collection = ( Collection ) value ; final char [ ] target = new char [ 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 < Character > charArrayList = new ArrayList <> ( ) ; for ( final Object element : iterable ) { final char convertedValue = convertType ( element ) ; charArrayList . add ( Character . valueOf ( convertedValue ) ) ; } final char [ ] array = new char [ charArrayList . size ( ) ] ; for ( int i = 0 ; i < charArrayList . size ( ) ; i ++ ) { final Character c = charArrayList . get ( i ) ; array [ i ] = c . charValue ( ) ; } return array ; } if ( value instanceof CharSequence ) { final CharSequence charSequence = ( CharSequence ) value ; final char [ ] result = new char [ charSequence . length ( ) ] ; for ( int i = 0 ; i < result . length ; i ++ ) { result [ i ] = charSequence . charAt ( i ) ; } return result ; } // 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 .