2

is it possible with javapoet to create a method with an open parameter list? To create a method with a String[] parameter is no problem:

curEnumBuilder.addMethod(MethodSpec.methodBuilder("myMethod")
                .addParameter(String[].class, "params", Modifier.FINAL)
                .addModifiers(Modifier.PUBLIC)
                .returns(String.class)
                .build());

but I want to create:

public String myMethod(final String... params)
opfau
  • 731
  • 9
  • 37
  • Just came upon this in my review queue and wanted to let you know that the tags you've chosen seem to not have very much activity on them. I'd recommend choosing another, more popular tag that's related to your question. That way, you're more likely to get an answer. – Daxtron2 May 11 '18 at 12:34
  • Adding "varargs(true)" to the builder generates what I want – opfau May 15 '18 at 06:22
  • So you've solved it then? That's great! Post it as an answer so that way people who have the same problem in the future can more easily fix it. – Daxtron2 May 15 '18 at 11:55

1 Answers1

5

Adding "varargs(true)" to the method builder generates what I want

opfau
  • 731
  • 9
  • 37