@ SuppressWarnings ( "unchecked" ) @ Override public < T > T parseDefaultValue ( final NamedParameterNode < T > name ) { final String [ ] vals = name . getDefaultInstanceAsStrings ( ) ; final T [ ] ret = ( T [ ] ) new Object [ vals . length ] ; for ( int i = 0 ; i < vals . length ; i ++ ) { final String val = vals [ i ] ; try { ret [ i ] = parse ( name , val ) ; } catch ( final ParseException e ) { throw new ClassHierarchyException ( "Could not parse default value" , e ) ; } } if ( name . isSet ( ) ) { return ( T ) new HashSet < T > ( Arrays . asList ( ret ) ) ; } else if ( name . isList ( ) ) { return ( T ) new ArrayList < T > ( Arrays . asList ( ret ) ) ; } else { if ( ret . length == 0 ) { return null ; } else if ( ret . length == 1 ) { return ret [ 0 ] ; } else { throw new IllegalStateException ( "Multiple defaults for non-set named parameter! " + name . getFullName ( ) ) ; } } }
A helper method that returns the parsed default value of a given NamedParameter .