private static JsonStructure toJson ( IVarDef varDef ) { JsonObjectBuilder builder = Json . createObjectBuilder ( ) ; addAnnotations ( builder , varDef ) ; ConditionJson . toJson ( varDef ) . ifPresent ( json -> builder . add ( WHEN_KEY , json ) ) ; if ( varDef . getValues ( ) != null ) { JsonObjectBuilder valuesBuilder = Json . createObjectBuilder ( ) ; toStream ( varDef . getValues ( ) ) . forEach ( value -> valuesBuilder . add ( String . valueOf ( value . getName ( ) ) , toJson ( value ) ) ) ; builder . add ( VALUES_KEY , valuesBuilder . build ( ) ) ; } else if ( varDef . getMembers ( ) != null ) { JsonObjectBuilder membersBuilder = Json . createObjectBuilder ( ) ; toStream ( varDef . getMembers ( ) ) . forEach ( member -> membersBuilder . add ( member . getName ( ) , toJson ( member ) ) ) ; builder . add ( MEMBERS_KEY , membersBuilder . build ( ) ) ; } return builder . build ( ) ; }
Returns the JSON object that represents the given variable definition .