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.checkArgument;
13 import java.util.Objects;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
16 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
17 import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableNormalizedValueAttrNode;
19 public class ImmutableLeafSetEntryNodeBuilder<T>
20 extends AbstractImmutableNormalizedNodeBuilder<NodeWithValue, T, LeafSetEntryNode<T>> {
22 public static <T> ImmutableLeafSetEntryNodeBuilder<T> create() {
23 return new ImmutableLeafSetEntryNodeBuilder<>();
27 public LeafSetEntryNode<T> build() {
28 return new ImmutableLeafSetEntryNode<>(getNodeIdentifier(), getValue(), getAttributes());
31 private static final class ImmutableLeafSetEntryNode<T>
32 extends AbstractImmutableNormalizedValueAttrNode<NodeWithValue, T> implements LeafSetEntryNode<T> {
34 ImmutableLeafSetEntryNode(final NodeWithValue nodeIdentifier, final T value,
35 final Map<QName, String> attributes) {
36 super(nodeIdentifier, value, attributes);
37 checkArgument(Objects.deepEquals(nodeIdentifier.getValue(), value),
38 "Node identifier contains different value: %s than value itself: %s", nodeIdentifier, value);