Fix checkstyle issues reported by odlparent-3.0.0's checkstyle
[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 static com.google.common.base.Preconditions.checkState;
11 import static java.util.Objects.requireNonNull;
12
13 import java.util.Collections;
14 import java.util.Map;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
17 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
18 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder;
19
20 abstract class AbstractImmutableNormalizedNodeBuilder<I extends PathArgument, V, R extends NormalizedNode<I, ?>>
21         implements NormalizedNodeAttrBuilder<I,V,R> {
22
23     private Map<QName, String> attributes = Collections.emptyMap();
24     private I nodeIdentifier;
25     private V value;
26
27     protected final I getNodeIdentifier() {
28         checkState(nodeIdentifier != null, "Identifier has not been set");
29         return nodeIdentifier;
30     }
31
32     protected final V getValue() {
33         checkState(value != null, "Value has not been set");
34         return value;
35     }
36
37     protected final Map<QName, String> getAttributes() {
38         return attributes;
39     }
40
41     @Override
42     public NormalizedNodeAttrBuilder<I, V, R> withValue(final V withValue) {
43         this.value = requireNonNull(withValue);
44         return this;
45     }
46
47     @Override
48     public NormalizedNodeAttrBuilder<I, V, R> withNodeIdentifier(final I withNodeIdentifier) {
49         this.nodeIdentifier = requireNonNull(withNodeIdentifier);
50         return this;
51     }
52
53     @Override
54     public NormalizedNodeAttrBuilder<I, V, R> withAttributes(final Map<QName, String> withAttributes) {
55         this.attributes = requireNonNull(withAttributes);
56         return this;
57     }
58 }