public static RegistrationRequest fromJson ( Map < String , Object > raw ) throws JsonException { // If we could, we'd just get Json to coerce this for us, but that would lead to endless // recursion as the first thing it would do would be to call this very method. *sigh* Json json = new Json ( ) ; RegistrationRequest request = new RegistrationRequest ( ) ; if ( raw . get ( "name" ) instanceof String ) { request . name = ( String ) raw . get ( "name" ) ; } if ( raw . get ( "description" ) instanceof String ) { request . description = ( String ) raw . get ( "description" ) ; } if ( raw . get ( "configuration" ) instanceof Map ) { // This is nasty. Look away now! String converted = json . toJson ( raw . get ( "configuration" ) ) ; request . configuration = GridConfiguredJson . toType ( converted , GridNodeConfiguration . class ) ; } if ( raw . get ( "configuration" ) instanceof GridNodeConfiguration ) { request . configuration = ( GridNodeConfiguration ) raw . get ( "configuration" ) ; } return request ; }
Create an object from a registration request formatted as a json string .