import com.google.common.collect.Maps;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.util.MapAdaptor;
import org.opendaylight.yangtools.util.UnmodifiableCollection;
-import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
value = MapAdaptor.getDefaultInstance().takeSnapshot(node.children);
}
- public static <T> ListNodeBuilder<T, LeafSetEntryNode<T>> create() {
+ public static <T> @NonNull ListNodeBuilder<T, LeafSetEntryNode<T>> create() {
return new ImmutableLeafSetNodeBuilder<>();
}
- public static <T> ListNodeBuilder<T, LeafSetEntryNode<T>> create(final int sizeHint) {
+ public static <T> @NonNull ListNodeBuilder<T, LeafSetEntryNode<T>> create(final int sizeHint) {
return new ImmutableLeafSetNodeBuilder<>(sizeHint);
}
- public static <T> ListNodeBuilder<T, LeafSetEntryNode<T>> create(final LeafSetNode<T> node) {
+ public static <T> @NonNull ListNodeBuilder<T, LeafSetEntryNode<T>> create(final LeafSetNode<T> node) {
if (!(node instanceof ImmutableLeafSetNode<?>)) {
throw new UnsupportedOperationException(String.format("Cannot initialize from class %s", node.getClass()));
}
return this;
}
-
- @Override
- public ListNodeBuilder<T, LeafSetEntryNode<T>> withChildValue(final T childValue,
- final Map<QName, String> attributes) {
- final ImmutableLeafSetEntryNodeBuilder<T> b = ImmutableLeafSetEntryNodeBuilder.create();
- b.withNodeIdentifier(new NodeWithValue<>(nodeIdentifier.getNodeType(), childValue));
- b.withValue(childValue);
- b.withAttributes(attributes);
- return withChild(b.build());
- }
-
@Override
public ListNodeBuilder<T, LeafSetEntryNode<T>> withChildValue(final T childValue) {
- return withChildValue(childValue, Collections.emptyMap());
+ return withChild(ImmutableLeafSetEntryNodeBuilder.<T>create()
+ .withNodeIdentifier(new NodeWithValue<>(nodeIdentifier.getNodeType(), childValue))
+ .withValue(childValue).build());
}
protected static final class ImmutableLeafSetNode<T> extends
return Optional.ofNullable(children.get(child));
}
+ @Override
+ public int size() {
+ return children.size();
+ }
+
@Override
protected int valueHashCode() {
return children.hashCode();