Search in sources :

Example 1 with ObjectTraverser

use of com.yahoo.slime.ObjectTraverser in project vespa by vespa-engine.

the class ConfigPayloadApplier method handleInnerMap.

private void handleInnerMap(String name, Inspector inspector) {
    NamedBuilder builder = createBuilder(stack.peek(), stack.peek().peekName());
    setMapLeafValue(name, builder.builder());
    stack.push(builder);
    inspector.traverse(new ObjectTraverser() {

        @Override
        public void field(String name, Inspector inspector) {
            handleObjectEntry(name, inspector);
        }
    });
    stack.pop();
}
Also used : ObjectTraverser(com.yahoo.slime.ObjectTraverser) Inspector(com.yahoo.slime.Inspector)

Example 2 with ObjectTraverser

use of com.yahoo.slime.ObjectTraverser in project vespa by vespa-engine.

the class ConfigPayloadApplier method handleOBJECT.

private void handleOBJECT(Inspector inspector) {
    trace("Object");
    printStack();
    inspector.traverse(new ObjectTraverser() {

        @Override
        public void field(String name, Inspector inspector) {
            handleObjectEntry(name, inspector);
        }
    });
    trace("Should pop a builder from stack");
    NamedBuilder builder = stack.pop();
    printStack();
    // Need to set e.g struct(Struct.Builder) here
    if (!stack.empty()) {
        trace("builder= " + builder);
        try {
            invokeSetter(stack.peek().builder, builder.peekName(), builder.builder);
        } catch (Exception e) {
            throw new RuntimeException("Could not set '" + builder.peekName() + "' for value '" + builder.builder() + "'", e);
        }
    }
}
Also used : ObjectTraverser(com.yahoo.slime.ObjectTraverser) Inspector(com.yahoo.slime.Inspector) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 3 with ObjectTraverser

use of com.yahoo.slime.ObjectTraverser in project vespa by vespa-engine.

the class ConfidenceOverrideSerializer method fromSlime.

public Map<Version, Confidence> fromSlime(Slime slime) {
    Cursor root = slime.get();
    Cursor overridesObject = root.field(overridesField);
    Map<Version, Confidence> overrides = new LinkedHashMap<>();
    overridesObject.traverse((ObjectTraverser) (name, value) -> {
        overrides.put(Version.fromString(name), Confidence.valueOf(value.asString()));
    });
    return Collections.unmodifiableMap(overrides);
}
Also used : ObjectTraverser(com.yahoo.slime.ObjectTraverser) LinkedHashMap(java.util.LinkedHashMap) Cursor(com.yahoo.slime.Cursor) Version(com.yahoo.component.Version) Map(java.util.Map) Slime(com.yahoo.slime.Slime) Confidence(com.yahoo.vespa.hosted.controller.versions.VespaVersion.Confidence) Collections(java.util.Collections) Version(com.yahoo.component.Version) Confidence(com.yahoo.vespa.hosted.controller.versions.VespaVersion.Confidence) Cursor(com.yahoo.slime.Cursor) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ObjectTraverser (com.yahoo.slime.ObjectTraverser)3 Inspector (com.yahoo.slime.Inspector)2 Version (com.yahoo.component.Version)1 Cursor (com.yahoo.slime.Cursor)1 Slime (com.yahoo.slime.Slime)1 Confidence (com.yahoo.vespa.hosted.controller.versions.VespaVersion.Confidence)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Collections (java.util.Collections)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1