/* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.yangtools.yang.data.impl.schema.builder.impl; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableNormalizedNode; import com.google.common.base.Preconditions; public class ImmutableLeafSetEntryNodeBuilder extends AbstractImmutableNormalizedNodeBuilder> { public static NormalizedNodeBuilder> create() { return new ImmutableLeafSetEntryNodeBuilder<>(); } @Override public LeafSetEntryNode build() { return new ImmutableLeafSetEntryNode<>(nodeIdentifier, value); } static final class ImmutableLeafSetEntryNode extends AbstractImmutableNormalizedNode implements LeafSetEntryNode { ImmutableLeafSetEntryNode(InstanceIdentifier.NodeWithValue nodeIdentifier, T value) { super(nodeIdentifier, value); Preconditions.checkArgument(nodeIdentifier.getValue().equals(value), "Node identifier contains different value: %s than value itself: %s", nodeIdentifier, value); } @Override public String toString() { final StringBuffer sb = new StringBuffer("ImmutableLeafSetEntryNode{"); sb.append("nodeIdentifier=").append(nodeIdentifier); sb.append(", value=").append(value); sb.append('}'); return sb.toString(); } } }