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