public static Map < String , Object > getCommonParams ( JsonNode paramsNode ) { Map < String , Object > parameters = new HashMap <> ( ) ; for ( JsonNode child : paramsNode ) { // If there isn't a name then the response from GS must be erroneous. if ( ! child . hasNonNull ( "name" ) ) { logger . error ( "Common Parameter JsonNode encountered with " + "no parameter name!" ) ; continue ; } // Look up the parameter based on the "name" attribute of the node. String paramName = child . path ( "name" ) . asText ( ) ; // What type of value is it and what's the value? if ( ! child . hasNonNull ( "value" ) ) { logger . debug ( "No value found for Common Parameter {}" , child . path ( "name" ) . asText ( ) ) ; continue ; } if ( STRING_PARAMS . contains ( paramName . toUpperCase ( ) ) ) { parameters . put ( paramName , child . path ( "value" ) . asText ( ) ) ; } else if ( INT_PARAMS . contains ( paramName . toUpperCase ( ) ) ) { parameters . put ( paramName , child . path ( "value" ) . asInt ( ) ) ; } else if ( BOOLEAN_PARAMS . contains ( paramName . toUpperCase ( ) ) ) { parameters . put ( paramName , child . path ( "value" ) . asBoolean ( ) ) ; } else { logger . debug ( "Unknown Common Parameter: {}" , paramName ) ; } logger . debug ( "Parameter {}: {}" , paramName , child . path ( "value" ) . asText ( ) ) ; } return parameters ; }
Helper function to parse a JsonNode from a GS response containing CommonParameters emitting an EnumMap of parameters