Skip to content

Instantly share code, notes, and snippets.

@trepidacious
Created July 18, 2013 10:52
Show Gist options
  • Select an option

  • Save trepidacious/6028412 to your computer and use it in GitHub Desktop.

Select an option

Save trepidacious/6028412 to your computer and use it in GitHub Desktop.
public class ListBuilder {
private final StringBuilder b = new StringBuilder();
public ListBuilder li(String s) {
if (s!=null && !s.trim().isEmpty()) {
b.append("<li>"); b.append(s); b.append(</li>);
}
return this;
}
public String toString() {
return b.toString();
}
public static void main(String[] args) {
String s = new ListBuilder()
.li(rMap.get("a")
.li(rMap.get("b")
.li(rMap.get("c")
.toString();
System.out.println(s);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment