2 * Copyright (c) 2013 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.yangtools.yang.data.impl.schema.builder.impl;
10 import static com.google.common.base.Preconditions.checkState;
11 import static java.util.Objects.requireNonNull;
13 import java.util.Collections;
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;
20 abstract class AbstractImmutableNormalizedNodeBuilder<I extends PathArgument, V, R extends NormalizedNode<I, ?>>
21 implements NormalizedNodeAttrBuilder<I,V,R> {
23 private Map<QName, String> attributes = Collections.emptyMap();
24 private I nodeIdentifier;
27 protected final I getNodeIdentifier() {
28 checkState(nodeIdentifier != null, "Identifier has not been set");
29 return nodeIdentifier;
32 protected final V getValue() {
33 checkState(value != null, "Value has not been set");
37 protected final Map<QName, String> getAttributes() {
42 public NormalizedNodeAttrBuilder<I, V, R> withValue(final V value) {
43 this.value = requireNonNull(value);
48 public NormalizedNodeAttrBuilder<I, V, R> withNodeIdentifier(final I nodeIdentifier) {
49 this.nodeIdentifier = requireNonNull(nodeIdentifier);
54 public NormalizedNodeAttrBuilder<I, V, R> withAttributes(final Map<QName, String> attributes) {
55 this.attributes = requireNonNull(attributes);