protected Object getDefaultValue ( String propName , Class < ? > returnType ) { Object ret = null ; if ( returnType . isPrimitive ( ) ) { if ( returnType . equals ( boolean . class ) ) { return false ; } else if ( returnType . equals ( char . class ) ) { return ' ' ; } else { try { Class < ? > wrapperClass = Primitives . wrap ( returnType ) ; return wrapperClass . getMethod ( "valueOf" , String . class ) . invoke ( null , "0" ) ; } catch ( Throwable e ) { throw new WicketRuntimeException ( "Can't create default value for '" + propName + "' which should have type '" + returnType . getName ( ) + "'" ) ; } } } return ret ; }
Method for obtaining default value of required property