private static JsonStructure toJson( ITestCaseGenerator generator)
    {
    JsonObjectBuilder builder = Json.createObjectBuilder();

    if( generator.getClass().equals( TupleGenerator.class))
      {
      TupleGenerator tupleGenerator = (TupleGenerator) generator;
      builder.add( TUPLES_KEY, tupleGenerator.getDefaultTupleSize());
      Optional.ofNullable( tupleGenerator.getRandomSeed()).ifPresent( seed -> builder.add( SEED_KEY, seed));
      
      JsonArrayBuilder combinersBuilder = Json.createArrayBuilder();
      tupleGenerator.getCombiners().stream().forEach( combiner -> combinersBuilder.add( toJson( combiner)));
      JsonArray combiners = combinersBuilder.build();
      if( !combiners.isEmpty())
        {
        builder.add( COMBINERS_KEY, combiners);
        }
      }

    return builder.build();
    }
private static JsonStructure toJson ( ITestCaseGenerator generator ) { JsonObjectBuilder builder = Json . createObjectBuilder ( ) ; if ( generator . getClass ( ) . equals ( TupleGenerator . class ) ) { TupleGenerator tupleGenerator = ( TupleGenerator ) generator ; builder . add ( TUPLES_KEY , tupleGenerator . getDefaultTupleSize ( ) ) ; Optional . ofNullable ( tupleGenerator . getRandomSeed ( ) ) . ifPresent ( seed -> builder . add ( SEED_KEY , seed ) ) ; JsonArrayBuilder combinersBuilder = Json . createArrayBuilder ( ) ; tupleGenerator . getCombiners ( ) . stream ( ) . forEach ( combiner -> combinersBuilder . add ( toJson ( combiner ) ) ) ; JsonArray combiners = combinersBuilder . build ( ) ; if ( ! combiners . isEmpty ( ) ) { builder . add ( COMBINERS_KEY , combiners ) ; } } return builder . build ( ) ; }
Returns the JSON object that represents the given generator.