2 * Copyright (c) 2019 PANTHEON.tech, s.r.o. 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.util.schema.opaque;
10 import static com.google.common.base.Preconditions.checkState;
11 import static java.util.Objects.requireNonNull;
13 import com.google.common.annotations.Beta;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.opendaylight.yangtools.concepts.Builder;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
17 import org.opendaylight.yangtools.yang.data.api.schema.opaque.OpaqueDataNode;
20 public abstract class AbstractOpaqueDataNodeBuilder<T extends OpaqueDataNode> implements Builder<T> {
21 private NodeIdentifier identifier;
23 AbstractOpaqueDataNodeBuilder() {
27 final NodeIdentifier identifier() {
31 public AbstractOpaqueDataNodeBuilder<T> withIdentifier(final NodeIdentifier newIdentifier) {
32 checkState(identifier == null, "Identifier already set to %s", identifier);
33 identifier = requireNonNull(newIdentifier);
37 public abstract OpaqueDataValueBuilder withValue(Object value);
40 public final T build() {
41 checkState(identifier != null, "Identifier not set");
42 return build(identifier);
45 abstract @NonNull T build(@NonNull NodeIdentifier identifier);