move Tags.asString() to StringCompressor

This commit is contained in:
2021-09-18 10:18:42 +02:00
parent 54acb38e5e
commit 6cd6f578e7
4 changed files with 20 additions and 44 deletions

View File

@@ -135,4 +135,21 @@ public class StringCompressor {
}
return result.toString();
}
public String asString(final Tags tags) {
final StringBuilder result = new StringBuilder();
for (final Tag tag : tags.toTags()) {
if (result.length() > 0) {
result.append(", ");
}
result.append(get(tag.getKey()));
result.append("=");
result.append(get(tag.getValue()));
}
return result.toString();
}
}

View File

@@ -16,7 +16,6 @@ import org.lucares.utils.byteencoder.VariableByteEncoder;
public class Tags implements Comparable<Tags> {
private static final String DEFAULT_GROUP = "<none>";
public static StringCompressor STRING_COMPRESSOR = null;
private static final byte[] EMPTY_BYTES = new byte[0];
public static final Tags EMPTY = new Tags();
@@ -246,45 +245,4 @@ public class Tags implements Comparable<Tags> {
keyValueConsumer.accept(key, value);
}
}
/**
* @return User facing readable representation
*/
// TODO move
// to StringCompressor
public String asString() {
final StringBuilder result = new StringBuilder();
for (final Tag tag : tags) {
if (result.length() > 0) {
result.append(", ");
}
result.append(STRING_COMPRESSOR.get(tag.getKey()));
result.append("=");
result.append(STRING_COMPRESSOR.get(tag.getValue()));
}
return result.toString();
}
// TODO move
// to StringCompressor
//
// public String asValueString() {
// final StringBuilder result = new StringBuilder();
// if (isEmpty()) {
// result.append(DEFAULT_GROUP);
// } else {
// forEach((k, v) -> {
// if (result.length() > 0) {
// result.append(" / ");
// }
// result.append(v);
// });
// }
// return result.toString();
// }
}