import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeContainerBuilder;
-import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedLong;
/**
private StoreNodeCompositeBuilder(final NormalizedNodeContainerBuilder nodeBuilder) {
this.metadata = StoreMetadataNode.builder();
- this.data = nodeBuilder;
+ this.data = Preconditions.checkNotNull(nodeBuilder);
+ }
+
+ public StoreNodeCompositeBuilder(NormalizedNodeContainerBuilder nodeBuilder, StoreMetadataNode currentMeta) {
+ this.metadata = StoreMetadataNode.builder(currentMeta);
+ this.data = Preconditions.checkNotNull(nodeBuilder);
}
@SuppressWarnings("unchecked")
}
@SuppressWarnings("unchecked")
- public StoreNodeCompositeBuilder addIfPresent(final Optional<StoreMetadataNode> potential) {
- if (potential.isPresent()) {
- StoreMetadataNode node = potential.get();
- metadata.add(node);
- data.addChild(node.getData());
- }
+ public StoreNodeCompositeBuilder remove(PathArgument id) {
+ metadata.remove(id);
+ data.removeChild(id);
return this;
}
return new StoreNodeCompositeBuilder(nodeBuilder);
}
+ public static StoreNodeCompositeBuilder from(final NormalizedNodeContainerBuilder nodeBuilder, StoreMetadataNode currentMeta) {
+ return new StoreNodeCompositeBuilder(nodeBuilder, currentMeta);
+ }
+
@SuppressWarnings("unchecked")
public StoreNodeCompositeBuilder setIdentifier(final PathArgument identifier) {
data.withNodeIdentifier(identifier);
metadata.setSubtreeVersion(updatedSubtreeVersion);
return this;
}
-
}