add copy() for raw string injection to Builder
This commit is contained in:
parent
31aa9c4de5
commit
07673324ca
4 changed files with 23 additions and 0 deletions
|
@ -58,5 +58,7 @@ public interface Builder {
|
|||
|
||||
Builder copy(Builder builder) throws IOException;
|
||||
|
||||
Builder copy(String string) throws IOException;
|
||||
|
||||
String build();
|
||||
}
|
||||
|
|
|
@ -182,6 +182,15 @@ public class JsonBuilder implements Builder {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder copy(String string) throws IOException {
|
||||
if (state.structure == Structure.COLLECTION) {
|
||||
beginArrayValue();
|
||||
}
|
||||
appendable.append(string);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String build() {
|
||||
return appendable.toString();
|
||||
|
|
|
@ -305,6 +305,12 @@ public class XMLBuilder implements Builder {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder copy(String string) throws IOException {
|
||||
appendable.append(string);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String build() {
|
||||
return appendable.toString();
|
||||
|
|
|
@ -175,6 +175,12 @@ public class YamlBuilder implements Builder {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder copy(String string) throws IOException {
|
||||
buildValue(string);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String build() {
|
||||
return appendable.toString();
|
||||
|
|
Loading…
Reference in a new issue