2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.md.sal.dom.store.impl.tree;
10 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
11 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeContainerBuilder;
13 import com.google.common.base.Optional;
14 import com.google.common.primitives.UnsignedLong;
22 @SuppressWarnings("rawtypes")
23 public class StoreNodeCompositeBuilder {
25 private final StoreMetadataNode.Builder metadata;
27 private final NormalizedNodeContainerBuilder data;
29 private StoreNodeCompositeBuilder(final NormalizedNodeContainerBuilder nodeBuilder) {
30 this.metadata = StoreMetadataNode.builder();
31 this.data = nodeBuilder;
34 @SuppressWarnings("unchecked")
35 public StoreNodeCompositeBuilder add(final StoreMetadataNode node) {
37 data.addChild(node.getData());
41 @SuppressWarnings("unchecked")
42 public StoreNodeCompositeBuilder addIfPresent(final Optional<StoreMetadataNode> potential) {
43 if (potential.isPresent()) {
44 StoreMetadataNode node = potential.get();
46 data.addChild(node.getData());
51 public StoreMetadataNode build() {
52 return metadata.setData(data.build()).build();
55 public static StoreNodeCompositeBuilder from(final NormalizedNodeContainerBuilder nodeBuilder) {
56 return new StoreNodeCompositeBuilder(nodeBuilder);
59 @SuppressWarnings("unchecked")
60 public StoreNodeCompositeBuilder setIdentifier(final PathArgument identifier) {
61 data.withNodeIdentifier(identifier);
65 public StoreNodeCompositeBuilder setNodeVersion(final UnsignedLong nodeVersion) {
66 metadata.setNodeVersion(nodeVersion);
70 public StoreNodeCompositeBuilder setSubtreeVersion(final UnsignedLong updatedSubtreeVersion) {
71 metadata.setSubtreeVersion(updatedSubtreeVersion);