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 com.google.common.base.Preconditions;
12 import java.util.Objects;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
15 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
16 import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableNormalizedValueAttrNode;
18 public class ImmutableLeafSetEntryNodeBuilder<T> extends AbstractImmutableNormalizedNodeBuilder<YangInstanceIdentifier.NodeWithValue, T, LeafSetEntryNode<T>> {
20 public static <T> ImmutableLeafSetEntryNodeBuilder<T> create() {
21 return new ImmutableLeafSetEntryNodeBuilder<>();
25 public LeafSetEntryNode<T> build() {
26 return new ImmutableLeafSetEntryNode<>(getNodeIdentifier(), getValue(), getAttributes());
29 private static final class ImmutableLeafSetEntryNode<T> extends AbstractImmutableNormalizedValueAttrNode<YangInstanceIdentifier.NodeWithValue, T> implements LeafSetEntryNode<T> {
31 ImmutableLeafSetEntryNode(final YangInstanceIdentifier.NodeWithValue nodeIdentifier, final T value, final Map<QName, String> attributes) {
32 super(nodeIdentifier, value, attributes);
33 Preconditions.checkArgument(Objects.deepEquals(nodeIdentifier.getValue(), value),
34 "Node identifier contains different value: %s than value itself: %s", nodeIdentifier, value);