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 java.util.Objects.requireNonNull;
12 import org.eclipse.jdt.annotation.NonNull;
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.api.schema.builder.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 return checkSet(nodeIdentifier, "Identifier has not been set");
27 protected final V getValue() {
28 return checkSet(value, "Value has not been set");
32 public NormalizedNodeBuilder<I, V, R> withValue(final V withValue) {
33 this.value = requireNonNull(withValue);
38 public NormalizedNodeBuilder<I, V, R> withNodeIdentifier(final I withNodeIdentifier) {
39 this.nodeIdentifier = requireNonNull(withNodeIdentifier);
43 private static <T> @NonNull T checkSet(final @Nullable T obj, final String message) {
45 throw new IllegalStateException(message);