DAStatementWriter extends AbstractDAWriter<T> { public DAStatementWriter<T> appendParamValues(@Nonnull List<DAParameter> params, @Nullable Function<DAParameter, String> parameterNameFunction) throws IOException { if (params.isEmpty()) { commons.append("()"); return this; } Function<DAParameter, String> toParameterName = parameterNameFunction == null ? toName() : parameterNameFunction; Iterator<String> it = from(params).transform(toParameterName).filter(notNull()).toList().iterator(); commons.append("("); while (it.hasNext()) { String parameterName = it.next(); commons.append(parameterName); if (it.hasNext()) { commons.append(", "); } } commons.append(")"); return this; } DAStatementWriter(FileContext fileContext, T parent, int indentOffset);   DAStatementWriter(CommonMethods commonMethods, T parent); DAStatementWriter<T> start(); DAStatementWriter<T> append(CharSequence s); DAStatementWriter<T> append(char c); DAStatementWriter<T> appendType(DAType type); DAStatementWriter<T> appendTypeArgs(List<DAType> typeArgs); DAStatementWriter<T> appendParamValues(@Nonnull List<DAParameter> params,
                                                @Nullable Function<DAParameter, String> parameterNameFunction); DAStatementWriter<T> appendParamValues(@Nonnull List<DAParameter> params); T end();  }
@Test public void appendParamValues_add_empty_brackets_if_empty() throws Exception { FileContextTestImpl fileContext = new FileContextTestImpl(); methodWriter(fileContext).appendParamValues(Collections.<DAParameter>emptyList()); assertThat(fileContext.getRes()).isEqualTo("()"); }
@Test public void appendParamValues_with_only_one_parameter() throws Exception { FileContextTestImpl fileContext = new FileContextTestImpl(); methodWriter(fileContext).appendParamValues( Collections.singletonList( DAParameterImpl.builder(DANameFactory.from("param"), DATypeFactory.from(String.class)) .build() ) ); assertThat(fileContext.getRes()).isEqualTo("(param)"); }
@Test public void appendParamValues_with_multiple_parameters() throws Exception { FileContextTestImpl fileContext = new FileContextTestImpl(); methodWriter(fileContext).appendParamValues( ImmutableList.of( DAParameterImpl.builder(DANameFactory.from("param1"), DATypeFactory.from(String.class)) .build(), DAParameterImpl.builder(DANameFactory.from("param2"), DATypeFactory.from(String.class)) .build() ) ); assertThat(fileContext.getRes()).isEqualTo("(param1, param2)"); }