delegate().startLeafSet(name, childSizeHint);
}
+ @Override
+ public void startOrderedLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException {
+ delegate().startOrderedLeafSet(name, childSizeHint);
+ }
+
@Override
public void leafSetEntryNode(final Object value) throws IOException {
delegate().leafSetEntryNode(value);
incIndent();
}
+ @Override
+ public void startOrderedLeafSet(final NodeIdentifier name, final int childSizeHint) {
+ LOG.debug("{}{}(leaf-list)", ind(), name);
+ incIndent();
+ }
+
@Override
public void startContainerNode(final NodeIdentifier name, final int childSizeHint) {
LOG.debug("{}{}(container)", ind(), name);
*/
void startLeafSet(NodeIdentifier name, int childSizeHint) throws IOException;
+ /**
+ *
+ * Emits a start of leaf set (leaf-list).
+ * <p>
+ * Emits start of leaf set, during writing leaf set event, only
+ * {@link #leafSetEntryNode(Object)} calls are valid. Leaf set event is
+ * finished by calling {@link #endNode()}.
+ *
+ * @param name
+ * name of node as defined in schema, namespace and revision are
+ * derived from parent node.
+ * @param childSizeHint
+ * Non-negative count of expected direct child nodes or
+ * {@link #UNKNOWN_SIZE} if count is unknown. This is only hint
+ * and should not fail writing of child events, if there are more
+ * events than count.
+ * @throws IllegalArgumentException
+ * If emitted leaf node is invalid in current context or was
+ * emitted multiple times.
+ * @throws IllegalStateException
+ * If node was emitted inside <code>map</code>,
+ * <code>choice</code> <code>unkeyed list</code> node.
+ * @throws IOException if an underlying IO error occurs
+ */
+ void startOrderedLeafSet(NodeIdentifier name, int childSizeHint) throws IOException, IllegalArgumentException;
+
/**
* Emits a leaf set entry node
*
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.OrderedLeafSetNode;
import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode;
import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode;
writer.startMapNode(n.getIdentifier(), childSizeHint(n.getValue()));
return writeChildren(n.getValue());
}
+ if (node instanceof OrderedLeafSetNode) {
+ final LeafSetNode<?> n = (LeafSetNode<?>) node;
+ writer.startOrderedLeafSet(n.getIdentifier(), childSizeHint(n.getValue()));
+ return writeChildren(n.getValue());
+ }
if (node instanceof LeafSetNode) {
- //covers also OrderedLeafSetNode for which doesn't exist start* method
final LeafSetNode<?> n = (LeafSetNode<?>) node;
writer.startLeafSet(n.getIdentifier(), childSizeHint(n.getValue()));
return writeChildren(n.getValue());
writeValue(value, codec);
}
+ @Override
+ public void startOrderedLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException {
+ tracker.startLeafSet(name);
+ context = new JSONStreamWriterListContext(context, name);
+ }
+
/*
* Warning suppressed due to static final constant which triggers a warning
* for the call to schema.isPresenceContainer().
import java.io.IOException;
import org.opendaylight.yangtools.yang.data.api.schema.stream.SchemaAwareNormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
class LeafListNodeDataWithSchema extends CompositeNodeDataWithSchema {
public LeafListNodeDataWithSchema(final DataSchemaNode schema) {
@Override
public void write(final SchemaAwareNormalizedNodeStreamWriter writer) throws IOException {
- writer.nextDataSchemaNode(getSchema());
- writer.startLeafSet(provideNodeIdentifier(), childSizeHint());
+ final LeafListSchemaNode schema = (LeafListSchemaNode) getSchema();
+ writer.nextDataSchemaNode(schema);
+ if (schema.isUserOrdered()) {
+ writer.startOrderedLeafSet(provideNodeIdentifier(), childSizeHint());
+ } else {
+ writer.startLeafSet(provideNodeIdentifier(), childSizeHint());
+ }
super.write(writer);
writer.endNode();
}
writeElement(schema.getQName(), schema, value);
}
+ @Override
+ public void startOrderedLeafSet(final NodeIdentifier name, final int childSizeHint) {
+ tracker.startLeafSet(name);
+ }
+
@Override
public void startContainerNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
final SchemaNode schema = tracker.startContainerNode(name);
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedLeafSetNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedMapNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListEntryNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListNodeBuilder;
@Override
public void leafSetEntryNode(final Object value) {
- Preconditions.checkArgument(getCurrent() instanceof ImmutableLeafSetNodeBuilder<?>);
- @SuppressWarnings("unchecked")
- final ListNodeBuilder<Object, LeafSetEntryNode<Object>> builder = ((ImmutableLeafSetNodeBuilder<Object>) getCurrent());
- builder.withChildValue(value);
+ if (getCurrent() instanceof ImmutableOrderedLeafSetNodeBuilder) {
+ @SuppressWarnings("unchecked")
+ ListNodeBuilder<Object, LeafSetEntryNode<Object>> builder = ((ImmutableOrderedLeafSetNodeBuilder<Object>) getCurrent());
+ builder.withChildValue(value);
+ } else if (getCurrent() instanceof ImmutableLeafSetNodeBuilder) {
+ @SuppressWarnings("unchecked")
+ ListNodeBuilder<Object, LeafSetEntryNode<Object>> builder = ((ImmutableLeafSetNodeBuilder<Object>) getCurrent());
+ builder.withChildValue(value);
+ } else {
+ throw new IllegalArgumentException("LeafSetEntryNode is not valid for parent " + getCurrent());
+ }
+
nextSchema = null;
}
+ @Override
+ public void startOrderedLeafSet(final NodeIdentifier name,final int childSizeHint) {
+ checkDataNodeContainer();
+ final ListNodeBuilder<Object, LeafSetEntryNode<Object>> builder = Builders.orderedLeafSetBuilder();
+ builder.withNodeIdentifier(name);
+ enter(builder);
+ }
+
@Override
public void anyxmlNode(final NodeIdentifier name, final Object value) {
checkDataNodeContainer();
delegate().startLeafSet(transform(name), childSizeHint);
}
+ @Override
+ public void startOrderedLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException, IllegalArgumentException {
+ delegate().startOrderedLeafSet(transform(name), childSizeHint);
+ }
+
@Override
public void leafSetEntryNode(final Object value) throws IOException, IllegalArgumentException {
delegate().leafSetEntryNode(value);