commit fbfa16c05b3f74acd60ccdf780568e7e1b0b9e1b Author: iwakeh iwakeh@torproject.org Date: Fri Oct 27 17:35:14 2017 +0000
Make DescriptorBuilder also accept DescriptorBuilders.
This might facilitate easier processing of descriptors. --- .../torproject/collector/bridgedescs/DescriptorBuilder.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/torproject/collector/bridgedescs/DescriptorBuilder.java b/src/main/java/org/torproject/collector/bridgedescs/DescriptorBuilder.java index 12a8956..cc57662 100644 --- a/src/main/java/org/torproject/collector/bridgedescs/DescriptorBuilder.java +++ b/src/main/java/org/torproject/collector/bridgedescs/DescriptorBuilder.java @@ -14,7 +14,7 @@ import java.util.List; * only be processed after finishing the parsing step.</p> */ class DescriptorBuilder {
- private List<StringBuilder> parts; + private List<Object> parts;
private StringBuilder lastPart;
@@ -36,6 +36,13 @@ class DescriptorBuilder { return this; }
+ public DescriptorBuilder append(DescriptorBuilder placeholder) { + this.parts.add(placeholder); + this.lastPart = new StringBuilder(); + this.parts.add(this.lastPart); + return this; + } + public DescriptorBuilder space() { this.lastPart.append(' '); return this; @@ -49,8 +56,8 @@ class DescriptorBuilder { @Override public String toString() { StringBuilder full = new StringBuilder(); - for (StringBuilder part : this.parts) { - full.append(part); + for (Object part : this.parts) { + full.append(part.toString()); } return full.toString(); }
tor-commits@lists.torproject.org