public static Optional<Variable> freshBuilder(SourceBuilder code, Datatype datatype) {
    if (!datatype.getBuilderFactory().isPresent()) {
      return Optional.empty();
    }
    return Optional.of(code.scope().computeIfAbsent(Declaration.FRESH_BUILDER, () -> {
      Variable defaults = new Variable("defaults");
      code.addLine("%s %s = %s;",
          datatype.getGeneratedBuilder(),
          defaults,
          datatype.getBuilderFactory().get()
              .newBuilder(datatype.getBuilder(), TypeInference.INFERRED_TYPES));
      return defaults;
    }));
  }
public static Optional < Variable > freshBuilder ( SourceBuilder code , Datatype datatype ) { if ( ! datatype . getBuilderFactory ( ) . isPresent ( ) ) { return Optional . empty ( ) ; } return Optional . of ( code . scope ( ) . computeIfAbsent ( Declaration . FRESH_BUILDER , ( ) -> { Variable defaults = new Variable ( "defaults" ) ; code . addLine ( "%s %s = %s;" , datatype . getGeneratedBuilder ( ) , defaults , datatype . getBuilderFactory ( ) . get ( ) . newBuilder ( datatype . getBuilder ( ) , TypeInference . INFERRED_TYPES ) ) ; return defaults ; } ) ) ; }
Declares a fresh Builder to copy default property values from.

<p>Reuses an existing fresh Builder instance if one was already declared in this scope.

@returns a variable holding a fresh Builder, if a no-args factory method is available to
create one with