@Test public void format() { final List<String> instanceNames = Lists.newArrayList("a", "b", "c", "d"); final String formatted = new InstanceNamesFormatter().format(instanceNames); final String expected = "Rya instance names:\n" + " a\n" + " b\n" + " c\n" + " d\n"; assertEquals(expected, formatted); }
public String format(final List<String> names, final String connectedName) { requireNonNull(names); requireNonNull(connectedName); final int connectedIndex = names.indexOf( connectedName ); final StringBuilder formatted = new StringBuilder("Rya instance names:\n"); for(int i = 0; i < names.size(); i++) { if(i == connectedIndex) { formatted.append(" * "); } else { formatted.append(" "); } formatted.append( names.get(i) ).append("\n"); } return formatted.toString(); }
InstanceNamesFormatter { public String format(final List<String> names, final String connectedName) { requireNonNull(names); requireNonNull(connectedName); final int connectedIndex = names.indexOf( connectedName ); final StringBuilder formatted = new StringBuilder("Rya instance names:\n"); for(int i = 0; i < names.size(); i++) { if(i == connectedIndex) { formatted.append(" * "); } else { formatted.append(" "); } formatted.append( names.get(i) ).append("\n"); } return formatted.toString(); } }
InstanceNamesFormatter { public String format(final List<String> names, final String connectedName) { requireNonNull(names); requireNonNull(connectedName); final int connectedIndex = names.indexOf( connectedName ); final StringBuilder formatted = new StringBuilder("Rya instance names:\n"); for(int i = 0; i < names.size(); i++) { if(i == connectedIndex) { formatted.append(" * "); } else { formatted.append(" "); } formatted.append( names.get(i) ).append("\n"); } return formatted.toString(); }  }
InstanceNamesFormatter { public String format(final List<String> names, final String connectedName) { requireNonNull(names); requireNonNull(connectedName); final int connectedIndex = names.indexOf( connectedName ); final StringBuilder formatted = new StringBuilder("Rya instance names:\n"); for(int i = 0; i < names.size(); i++) { if(i == connectedIndex) { formatted.append(" * "); } else { formatted.append(" "); } formatted.append( names.get(i) ).append("\n"); } return formatted.toString(); }  String format(final List<String> names, final String connectedName); String format(final List<String> names); }
InstanceNamesFormatter { public String format(final List<String> names, final String connectedName) { requireNonNull(names); requireNonNull(connectedName); final int connectedIndex = names.indexOf( connectedName ); final StringBuilder formatted = new StringBuilder("Rya instance names:\n"); for(int i = 0; i < names.size(); i++) { if(i == connectedIndex) { formatted.append(" * "); } else { formatted.append(" "); } formatted.append( names.get(i) ).append("\n"); } return formatted.toString(); }  String format(final List<String> names, final String connectedName); String format(final List<String> names);  }