下面列出了com.google.common.io.CharStreams#asWriter ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void appendTo(Appendable buf) throws IOException {
// nested content is sorted so toString() is deterministic. this is valuable in tests and for
// comparing hashes of deltas for equality.
buf.append('{');
String sep = "";
if (!_removeRest) {
buf.append("..");
sep = ",";
}
Writer writer = CharStreams.asWriter(buf);
for (Map.Entry<String, Delta> entry : OrderedJson.ENTRY_COMPARATOR.immutableSortedCopy(_entries.entrySet())) {
buf.append(sep);
sep = ",";
DeltaJson.write(writer, entry.getKey());
buf.append(':');
entry.getValue().appendTo(buf);
}
buf.append('}');
if (_deleteIfEmpty) {
buf.append('?');
}
}
@Override
public void appendTo(Appendable buf) throws IOException {
// Use a writer so the re can be correctly converted to json using DeltaJson.
Writer out = CharStreams.asWriter(buf);
out.write("like(");
DeltaJson.write(out, _condition);
out.write(")");
}
@Override
public void appendTo(Appendable buf) throws IOException {
buf.append("intrinsic(");
Writer out = CharStreams.asWriter(buf);
DeltaJson.write(out, _name);
buf.append(':');
appendSubCondition(buf, _condition);
buf.append(')');
}
@Override
public void appendTo(Appendable buf) throws IOException {
buf.append("{..");
Writer writer = CharStreams.asWriter(buf);
for (Map.Entry<String, Condition> entry : OrderedJson.ENTRY_COMPARATOR.immutableSortedCopy(_entries.entrySet())) {
buf.append(',');
DeltaJson.write(writer, entry.getKey());
buf.append(':');
entry.getValue().appendTo(buf);
}
buf.append('}');
}
@Override
public void appendTo(Appendable buf)
throws IOException {
// Use a writer so the value can be correctly converted to json using DeltaJson.
Writer out = CharStreams.asWriter(buf);
out.write(_comparison.getDeltaFunction());
out.write("(");
DeltaJson.write(out, _value);
out.write(")");
}
public DebugExpressionVisitor(A target) {
super(e -> { throw new UnsupportedOperationException(); });
this.target = Objects.requireNonNull(target, "target");
this.writer = new PrintWriter(CharStreams.asWriter(target));
}