d33db494217b05a0b5c23d44c8db44292357d546
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / builder / impl / AbstractImmutableNormalizedNodeBuilder.java
1 /*
2  * Copyright (c) 2013 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.yangtools.yang.data.impl.schema.builder.impl;
9
10 import java.util.Collections;
11 import java.util.Map;
12 import org.opendaylight.yangtools.yang.common.QName;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
14 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
15 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder;
16
17 abstract class AbstractImmutableNormalizedNodeBuilder<I extends PathArgument, V, R extends NormalizedNode<I, ?>>
18         implements NormalizedNodeAttrBuilder<I,V,R> {
19
20     private Map<QName, String> attributes = Collections.emptyMap();
21     private I nodeIdentifier;
22     private V value;
23
24     protected final I getNodeIdentifier() {
25         return nodeIdentifier;
26     }
27
28     protected final V getValue() {
29         return value;
30     }
31
32     protected final Map<QName, String> getAttributes() {
33         return attributes;
34     }
35
36     @Override
37     public NormalizedNodeAttrBuilder<I,V,R> withValue(final V value) {
38         this.value = value;
39         return this;
40     }
41
42     @Override
43     public NormalizedNodeAttrBuilder<I,V,R> withNodeIdentifier(final I nodeIdentifier) {
44         this.nodeIdentifier = nodeIdentifier;
45         return this;
46     }
47
48     @Override
49     public NormalizedNodeAttrBuilder<I,V,R> withAttributes(final Map<QName, String> attributes) {
50         this.attributes = attributes;
51         return this;
52     }
53 }