*/
package org.opendaylight.yangtools.yang.data.impl.schema.builder.impl;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Sets;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import static java.util.Objects.requireNonNull;
+
+import java.util.Collections;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
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.OrderedMapNode;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataValidationException;
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
-import com.google.common.base.Preconditions;
-
+@Deprecated(since = "6.0.7", forRemoval = true)
public class ImmutableOrderedMapNodeSchemaAwareBuilder extends ImmutableOrderedMapNodeBuilder {
-
private final ListSchemaNode schema;
protected ImmutableOrderedMapNodeSchemaAwareBuilder(final ListSchemaNode schema) {
- this.schema = Preconditions.checkNotNull(schema);
- super.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(schema.getQName()));
+ this.schema = requireNonNull(schema);
+ super.withNodeIdentifier(NodeIdentifier.create(schema.getQName()));
}
- protected ImmutableOrderedMapNodeSchemaAwareBuilder(final ListSchemaNode schema, final ImmutableOrderedMapNode node) {
+ protected ImmutableOrderedMapNodeSchemaAwareBuilder(final ListSchemaNode schema,
+ final ImmutableOrderedMapNode node) {
super(node);
- this.schema = Preconditions.checkNotNull(schema);
- super.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(schema.getQName()));
+ this.schema = requireNonNull(schema);
+ super.withNodeIdentifier(NodeIdentifier.create(schema.getQName()));
}
- public static CollectionNodeBuilder<MapEntryNode, OrderedMapNode> create(final ListSchemaNode schema) {
+ public static @NonNull CollectionNodeBuilder<MapEntryNode, OrderedMapNode> create(final ListSchemaNode schema) {
return new ImmutableOrderedMapNodeSchemaAwareBuilder(schema);
}
- public static CollectionNodeBuilder<MapEntryNode, OrderedMapNode> create(final ListSchemaNode schema,
+ public static @NonNull CollectionNodeBuilder<MapEntryNode, OrderedMapNode> create(final ListSchemaNode schema,
final MapNode node) {
if (!(node instanceof ImmutableOrderedMapNode)) {
throw new UnsupportedOperationException(String.format("Cannot initialize from class %s", node.getClass()));
@Override
public CollectionNodeBuilder<MapEntryNode, OrderedMapNode> withChild(final MapEntryNode child) {
- DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(), schema, Sets.newHashSet(schema.getQName()));
+ DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(),
+ schema, Collections.singleton(schema.getQName()));
return super.withChild(child);
}
@Override
- public CollectionNodeBuilder<MapEntryNode, OrderedMapNode> withNodeIdentifier(final YangInstanceIdentifier.NodeIdentifier nodeIdentifier) {
+ public CollectionNodeBuilder<MapEntryNode, OrderedMapNode> withNodeIdentifier(
+ final NodeIdentifier withNodeIdentifier) {
throw new UnsupportedOperationException("Node identifier created from schema");
}
}