/* * Copyright (c) 2019 PANTHEON.tech, s.r.o. 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 static java.util.Objects.requireNonNull; import com.google.common.annotations.Beta; import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.AnydataNode; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableNormalizedSimpleValueNode; @Beta public class ImmutableAnydataNodeBuilder extends AbstractImmutableNormalizedNodeBuilder> { private final @NonNull Class objectModel; ImmutableAnydataNodeBuilder(final Class objectModel) { this.objectModel = requireNonNull(objectModel); } public static NormalizedNodeBuilder> create(final Class objectModel) { return new ImmutableAnydataNodeBuilder<>(objectModel); } @Override public AnydataNode build() { return new ImmutableAnydataNode<>(getNodeIdentifier(), getValue(), objectModel); } private static final class ImmutableAnydataNode extends AbstractImmutableNormalizedSimpleValueNode, V> implements AnydataNode { private final Class objectModel; protected ImmutableAnydataNode(final NodeIdentifier nodeIdentifier, final V value, final Class objectModel) { super(nodeIdentifier, value); this.objectModel = requireNonNull(objectModel); } @Override public Class bodyObjectModel() { return objectModel; } @Override protected Class> implementedType() { return (Class) AnydataNode.class; } } }