The simplest initializing it with the Lombok's builder is like this:
@Builder
public @Data class RMF_Objective {
private ArrayList<String> parameters;
public void refresh() {
parameters.clear(); // Clear for now
System.out.println("cleared !");
}
public static void main(String[] args) {
ArrayList<String> list = new ArrayList<>(Arrays.asList("one", "two"));
RMF_Objective builtObject = new RMF_ObjectiveBuilder()
.parameters(list)
.build();
builtObject.refresh();
}
}
Otherwise you could also use Lombok's @Singular annotation to make it generate a 'singular' version of the parameters() method taking only one String as input parameter. Like this:
@Builder
public @Data class RMF_ObjectiveSingular {
@Singular
private List<String> parameters;
public void refresh() {
parameters.clear(); // Clear for now
System.out.println("cleared !");
}
public static void main(String[] args) {
ArrayList<String> list = new ArrayList<>(Arrays.asList("one", "two"));
RMF_ObjectiveSingular builtObject = new RMF_ObjectiveSingularBuilder()
.parameter("one")
.parameter("two")
.build();
builtObject.refresh();
}
}
But if I were you, I would really use only the @Value's Lombok annotation. If you don't need a builder, it's simpler to have only a constructor initializing the object and Getter but no Setters. Immutables objects are often safer.