use of com.yahoo.slime.Inspector in project vespa by vespa-engine.
the class StringSetSerializer method fromJson.
public Set<String> fromJson(byte[] data) {
Inspector inspector = SlimeUtils.jsonToSlime(data).get();
Set<String> stringSet = new HashSet<>();
inspector.traverse((ArrayTraverser) (index, name) -> stringSet.add(name.asString()));
return stringSet;
}
use of com.yahoo.slime.Inspector in project vespa by vespa-engine.
the class NodePatcher method asStringSet.
private Set<String> asStringSet(Inspector field) {
if (!field.type().equals(Type.ARRAY))
throw new IllegalArgumentException("Expected an ARRAY value, got a " + field.type());
TreeSet<String> strings = new TreeSet<>();
for (int i = 0; i < field.entries(); i++) {
Inspector entry = field.entry(i);
if (!entry.type().equals(Type.STRING))
throw new IllegalArgumentException("Expected a STRING value, got a " + entry.type());
strings.add(entry.asString());
}
return strings;
}
Aggregations