move Tags.asValueString to StringCompressor
This commit is contained in:
@@ -8,6 +8,8 @@ import java.util.function.Function;
|
||||
*/
|
||||
public class StringCompressor {
|
||||
|
||||
private static final String DEFAULT_GROUP = "<none>";
|
||||
|
||||
private final UniqueStringIntegerPairs usip;
|
||||
|
||||
public StringCompressor(final UniqueStringIntegerPairs usip) throws RuntimeIOException {
|
||||
@@ -119,4 +121,18 @@ public class StringCompressor {
|
||||
return result;
|
||||
}
|
||||
|
||||
public String asValueString(final Tags tags) {
|
||||
final StringBuilder result = new StringBuilder();
|
||||
if (tags.isEmpty()) {
|
||||
result.append(DEFAULT_GROUP);
|
||||
} else {
|
||||
tags.forEach((k, v) -> {
|
||||
if (result.length() > 0) {
|
||||
result.append(" / ");
|
||||
}
|
||||
result.append(v);
|
||||
});
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,15 +175,6 @@ public class Tags implements Comparable<Tags> {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void forEach(final BiConsumer<String, String> keyValueConsumer) {
|
||||
|
||||
for (final Tag tag : tags) {
|
||||
final String key = STRING_COMPRESSOR.get(tag.getKey());
|
||||
final String value = STRING_COMPRESSOR.get(tag.getValue());
|
||||
keyValueConsumer.accept(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public Tags mapTags(final Function<Tag, Tag> tagMapFuntion) {
|
||||
final List<Tag> mappedTags = new ArrayList<>(tags.size());
|
||||
for (final Tag tag : tags) {
|
||||
@@ -244,9 +235,24 @@ public class Tags implements Comparable<Tags> {
|
||||
return tags.isEmpty();
|
||||
}
|
||||
|
||||
// TODO move
|
||||
// to StringCompressor
|
||||
|
||||
public void forEach(final BiConsumer<String, String> keyValueConsumer) {
|
||||
|
||||
for (final Tag tag : tags) {
|
||||
final String key = STRING_COMPRESSOR.get(tag.getKey());
|
||||
final String value = STRING_COMPRESSOR.get(tag.getValue());
|
||||
keyValueConsumer.accept(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User facing readable representation
|
||||
*/
|
||||
// TODO move
|
||||
// to StringCompressor
|
||||
|
||||
public String asString() {
|
||||
|
||||
final StringBuilder result = new StringBuilder();
|
||||
@@ -264,18 +270,21 @@ public class Tags implements Comparable<Tags> {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
// 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();
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ public class Plotter {
|
||||
static String title(final Tags tags, final CsvSummary csvSummary) {
|
||||
// TODO title must be computed by the AggregateHandler, because it is the only
|
||||
// one knowing how many values are plotted
|
||||
final StringBuilder result = new StringBuilder(tags.asValueString());
|
||||
final StringBuilder result = new StringBuilder(Tags.STRING_COMPRESSOR.asValueString(tags));
|
||||
|
||||
final int values = csvSummary.getValues();
|
||||
result.append(" (");
|
||||
|
||||
Reference in New Issue
Block a user