@Test public void testBuilds() { PrependingTypeNameValuesStringBuilder builder = new PrependingTypeNameValuesStringBuilder( TypeNameValuesStringBuilder.DEFAULT_SEPARATOR, asList("p-key1-p", "q-key1-q")); assertThat(builder.build(null, "p-key1-p=p-value1-p,q-key1-q=q-value1-q")).isEqualTo("p-value1-p_q-value1-q"); assertThat(builder.build(Collections.<String>emptyList(), "p-key1-p=p-value1-p")).isEqualTo("p-value1-p"); assertThat(builder.build(asList("x-key1-x"), "")).isEmpty(); assertThat(builder.build(asList("x-key1-x"), "p-key1-p=p-value1-p")).isEqualTo("p-value1-p"); assertThat(builder.build(asList("x-key1-x", "y-key2-y"), "")).isEmpty(); assertThat(builder.build(asList("x-key1-x"), "x-key1-x=x-value1-x")).isEqualTo("x-value1-x"); assertThat(builder.build(asList("x-key1-x"), "x-key1-x=x-value1-x,q-key1-q=q-value1-q")) .isEqualTo("q-value1-q_x-value1-x"); assertThat(builder.build(asList("x-key1-x"), "y-key2-y=y-value2-y")).isEmpty(); assertThat(builder.build(asList("x-key1-x", "y-key2-y"), "x-key1-x=x-value1-x,y-key2-y=y-value2-y")) .isEqualTo("x-value1-x_y-value2-y"); assertThat(builder.build( asList("x-key1-x", "y-key2-y"), "x-key1-x=x-value1-x,q-key1-q=q-value1-q,y-key2-y=y-value2-y,p-key1-p=p-value1-p")) .isEqualTo("p-value1-p_q-value1-q_x-value1-x_y-value2-y"); }
@Override public String build(List<String> typeNames, String typeNameStr) { List<String> resultingTypeNames = new ArrayList<>(prependedTypeNames); if (typeNames != null) { for (String name : typeNames) { if (!resultingTypeNames.contains(name)) { resultingTypeNames.add(name); } } } return doBuild(resultingTypeNames, typeNameStr); }
PrependingTypeNameValuesStringBuilder extends TypeNameValuesStringBuilder { @Override public String build(List<String> typeNames, String typeNameStr) { List<String> resultingTypeNames = new ArrayList<>(prependedTypeNames); if (typeNames != null) { for (String name : typeNames) { if (!resultingTypeNames.contains(name)) { resultingTypeNames.add(name); } } } return doBuild(resultingTypeNames, typeNameStr); } }
PrependingTypeNameValuesStringBuilder extends TypeNameValuesStringBuilder { @Override public String build(List<String> typeNames, String typeNameStr) { List<String> resultingTypeNames = new ArrayList<>(prependedTypeNames); if (typeNames != null) { for (String name : typeNames) { if (!resultingTypeNames.contains(name)) { resultingTypeNames.add(name); } } } return doBuild(resultingTypeNames, typeNameStr); } PrependingTypeNameValuesStringBuilder(String separator, List<String> prependedTypeNames); }
PrependingTypeNameValuesStringBuilder extends TypeNameValuesStringBuilder { @Override public String build(List<String> typeNames, String typeNameStr) { List<String> resultingTypeNames = new ArrayList<>(prependedTypeNames); if (typeNames != null) { for (String name : typeNames) { if (!resultingTypeNames.contains(name)) { resultingTypeNames.add(name); } } } return doBuild(resultingTypeNames, typeNameStr); } PrependingTypeNameValuesStringBuilder(String separator, List<String> prependedTypeNames); @Override String build(List<String> typeNames, String typeNameStr); }
PrependingTypeNameValuesStringBuilder extends TypeNameValuesStringBuilder { @Override public String build(List<String> typeNames, String typeNameStr) { List<String> resultingTypeNames = new ArrayList<>(prependedTypeNames); if (typeNames != null) { for (String name : typeNames) { if (!resultingTypeNames.contains(name)) { resultingTypeNames.add(name); } } } return doBuild(resultingTypeNames, typeNameStr); } PrependingTypeNameValuesStringBuilder(String separator, List<String> prependedTypeNames); @Override String build(List<String> typeNames, String typeNameStr);  }