cbd2a17081a8e9d877a9f484775ee6c6a40cd25b
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / md / sal / dom / store / impl / tree / spi / ValueNode.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.md.sal.dom.store.impl.tree.spi;
9
10 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
11 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
14
15 import com.google.common.base.Optional;
16 import com.google.common.primitives.UnsignedLong;
17
18 final class ValueNode extends AbstractTreeNode {
19     private static final Logger LOG = LoggerFactory.getLogger(ValueNode.class);
20
21     protected ValueNode(final NormalizedNode<?, ?> data, final UnsignedLong version) {
22         super(data, version);
23     }
24
25     @Override
26     public Optional<TreeNode> getChild(final PathArgument childId) {
27         LOG.warn("Attempted to access child {} of value-node {}", childId, this);
28         return Optional.absent();
29     }
30
31     @Override
32     public UnsignedLong getSubtreeVersion() {
33         return getVersion();
34     }
35
36     @Override
37     public MutableTreeNode mutable() {
38         /**
39          * Value nodes can only we read/written/delete, which does a straight
40          * replace. That means they don't haver need to be made mutable.
41          */
42         throw new UnsupportedOperationException(String.format("Attempted to mutate value-node %s", this));
43     }
44 }