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 org.eclipse.jdt.annotation.Nullable;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
15 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
16 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeBuilder;
18 abstract class AbstractImmutableNormalizedNodeBuilder<I extends PathArgument, V, R extends NormalizedNode>
19 implements NormalizedNodeBuilder<I, V, R> {
20 private @Nullable I nodeIdentifier = null;
21 private @Nullable V value = null;
23 protected final I getNodeIdentifier() {
24 checkState(nodeIdentifier != null, "Identifier has not been set");
25 return nodeIdentifier;
28 protected final V getValue() {
29 checkState(value != null, "Value has not been set");
34 public NormalizedNodeBuilder<I, V, R> withValue(final V withValue) {
35 this.value = requireNonNull(withValue);
40 public NormalizedNodeBuilder<I, V, R> withNodeIdentifier(final I withNodeIdentifier) {
41 this.nodeIdentifier = requireNonNull(withNodeIdentifier);