src/de/plpt/ArgumentParser/ArgumentParser.java
/**
	 * Parses a value from given String into expected (primitive) type
	 *
	 * @param paramString String representation of parameter to Parse
	 * @param type        Type declaration to transform String
	 * @return Object holding strongly typed parsed value
	 */
Parses a value from given String into expected (primitive) type
@param paramString String representation of parameter to Parse
@param type        Type declaration to transform String
@return Object holding strongly typed parsed value
Parses a value from given String into expected ( primitive ) type @param paramString String representation of parameter to Parse @param type Type declaration to transform String @return Object holding strongly typed parsed value
private Object parseValue(String paramString, Class<?> type) throws ArgumentParserException {
		Object parsedValue = null;
		if (type == String.class) {
			parsedValue = paramString;
		} else if (type == int.class || type == Integer.class) {
			parsedValue = Integer.parseInt(paramString);
		} else if (type == long.class || type == Long.class) {
			parsedValue = Long.parseLong(paramString);
		} else if (type == boolean.class || type == Boolean.class) {
			int value = Integer.parseInt(paramString);
			if (value != 1 && value != 0) {
				throw new ArgumentParserException(String.format("Integer '%s' cannot be converted to boolean", value));
			}
			parsedValue = (boolean) (Boolean.valueOf(paramString) || value == 1);
		} else if (type == short.class || type == Short.class) {
			parsedValue = Short.parseShort(paramString);
		} else if (type == byte.class || type == Byte.class) {
			parsedValue = Byte.parseByte(paramString);
		} else if (type == double.class || type == Double.class) {
			parsedValue = Double.parseDouble(paramString);
		} else if (type == float.class || type == Float.class) {
			parsedValue = Float.parseFloat(paramString);
		} else {
			try {
				parsedValue = type.getDeclaredConstructor(String.class).newInstance(paramString);
			} catch (InstantiationException e) {
				throw new ArgumentParserException("InstantiationException", e);
			} catch (IllegalAccessException e) {
				throw new ArgumentParserException("IllegalAccessException", e);
			} catch (InvocationTargetException e) {
				throw new ArgumentParserException("InvocationTargetException", e);
			} catch (NoSuchMethodException e) {
				throw new ArgumentParserException("NoSuchMethodException", e);
			}
		}
		return parsedValue;
	}
private Object parseValue ( String paramString , Class < ? > type ) throws ArgumentParserException { Object parsedValue = null ; if ( type == String . class ) { parsedValue = paramString ; } else if ( type == int . class || type == Integer . class ) { parsedValue = Integer . parseInt ( paramString ) ; } else if ( type == long . class || type == Long . class ) { parsedValue = Long . parseLong ( paramString ) ; } else if ( type == boolean . class || type == Boolean . class ) { int value = Integer . parseInt ( paramString ) ; if ( value != 1 && value != 0 ) { throw new ArgumentParserException ( String . format ( "Integer '%s' cannot be converted to boolean" , value ) ) ; } parsedValue = ( boolean ) ( Boolean . valueOf ( paramString ) || value == 1 ) ; } else if ( type == short . class || type == Short . class ) { parsedValue = Short . parseShort ( paramString ) ; } else if ( type == byte . class || type == Byte . class ) { parsedValue = Byte . parseByte ( paramString ) ; } else if ( type == double . class || type == Double . class ) { parsedValue = Double . parseDouble ( paramString ) ; } else if ( type == float . class || type == Float . class ) { parsedValue = Float . parseFloat ( paramString ) ; } else { try { parsedValue = type . getDeclaredConstructor ( String . class ) . newInstance ( paramString ) ; } catch ( InstantiationException e ) { throw new ArgumentParserException ( "InstantiationException" , e ) ; } catch ( IllegalAccessException e ) { throw new ArgumentParserException ( "IllegalAccessException" , e ) ; } catch ( InvocationTargetException e ) { throw new ArgumentParserException ( "InvocationTargetException" , e ) ; } catch ( NoSuchMethodException e ) { throw new ArgumentParserException ( "NoSuchMethodException" , e ) ; } } return parsedValue ; }
Parses a value from given String into expected (primitive) type
 @param paramString String representation of parameter to Parse
 @param type        Type declaration to transform String
 @return Object holding strongly typed parsed value
Parses a value from given String into expected ( primitive ) type @param paramString String representation of parameter to Parse @param type Type declaration to transform String @return Object holding strongly typed parsed value