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 org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
11 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
12 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeBuilder;
13 import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableNormalizedNode;
15 import com.google.common.base.Preconditions;
17 public class ImmutableLeafSetEntryNodeBuilder<T> extends AbstractImmutableNormalizedNodeBuilder<InstanceIdentifier.NodeWithValue, T, LeafSetEntryNode<T>> {
19 public static <T> NormalizedNodeBuilder<InstanceIdentifier.NodeWithValue, T, LeafSetEntryNode<T>> create() {
20 return new ImmutableLeafSetEntryNodeBuilder<>();
24 public LeafSetEntryNode<T> build() {
25 return new ImmutableLeafSetEntryNode<>(nodeIdentifier, value);
28 static final class ImmutableLeafSetEntryNode<T> extends AbstractImmutableNormalizedNode<InstanceIdentifier.NodeWithValue, T> implements LeafSetEntryNode<T> {
30 ImmutableLeafSetEntryNode(InstanceIdentifier.NodeWithValue nodeIdentifier, T value) {
31 super(nodeIdentifier, value);
32 Preconditions.checkArgument(nodeIdentifier.getValue().equals(value),
33 "Node identifier contains different value: %s than value itself: %s", nodeIdentifier, value);
37 public String toString() {
38 final StringBuffer sb = new StringBuffer("ImmutableLeafSetEntryNode{");
39 sb.append("nodeIdentifier=").append(nodeIdentifier);
40 sb.append(", value=").append(value);