BUG-704 Remove pax from netconf identity-ref test.
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / md / sal / dom / store / impl / tree / StoreNodeCompositeBuilder.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.md.sal.dom.store.impl.tree;
9
10 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
11 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeContainerBuilder;
12
13 import com.google.common.base.Optional;
14 import com.google.common.primitives.UnsignedLong;
15
16 /**
17  *
18  * Helper builder
19  *
20  *
21  */
22 @SuppressWarnings("rawtypes")
23 public class StoreNodeCompositeBuilder {
24
25     private final StoreMetadataNode.Builder metadata;
26
27     private final NormalizedNodeContainerBuilder data;
28
29     private StoreNodeCompositeBuilder(final NormalizedNodeContainerBuilder nodeBuilder) {
30         this.metadata = StoreMetadataNode.builder();
31         this.data = nodeBuilder;
32     }
33
34     @SuppressWarnings("unchecked")
35     public StoreNodeCompositeBuilder add(final StoreMetadataNode node) {
36         metadata.add(node);
37         data.addChild(node.getData());
38         return this;
39     }
40
41     @SuppressWarnings("unchecked")
42     public StoreNodeCompositeBuilder addIfPresent(final Optional<StoreMetadataNode> potential) {
43         if (potential.isPresent()) {
44             StoreMetadataNode node = potential.get();
45             metadata.add(node);
46             data.addChild(node.getData());
47         }
48         return this;
49     }
50
51     public StoreMetadataNode build() {
52         return metadata.setData(data.build()).build();
53     }
54
55     public static StoreNodeCompositeBuilder from(final NormalizedNodeContainerBuilder nodeBuilder) {
56         return new StoreNodeCompositeBuilder(nodeBuilder);
57     }
58
59     @SuppressWarnings("unchecked")
60     public StoreNodeCompositeBuilder setIdentifier(final PathArgument identifier) {
61         data.withNodeIdentifier(identifier);
62         return this;
63     }
64
65     public StoreNodeCompositeBuilder setNodeVersion(final UnsignedLong nodeVersion) {
66         metadata.setNodeVersion(nodeVersion);
67         return this;
68     }
69
70     public StoreNodeCompositeBuilder setSubtreeVersion(final UnsignedLong updatedSubtreeVersion) {
71         metadata.setSubtreeVersion(updatedSubtreeVersion);
72         return this;
73     }
74
75 }