Rename NormalizedNodeContainerModificationStrategy
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / OrderedLeafSetModificationStrategy.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.yangtools.yang.data.impl.schema.tree;
9
10 import static com.google.common.base.Preconditions.checkArgument;
11 import com.google.common.base.Optional;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
13 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
14 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
15 import org.opendaylight.yangtools.yang.data.api.schema.OrderedLeafSetNode;
16 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeContainerBuilder;
17 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedLeafSetNodeBuilder;
18 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
19
20 final class OrderedLeafSetModificationStrategy extends AbstractNodeContainerModificationStrategy {
21     private final Optional<ModificationApplyOperation> entryStrategy;
22
23     @SuppressWarnings({ "unchecked", "rawtypes" })
24     OrderedLeafSetModificationStrategy(final LeafListSchemaNode schema) {
25         super((Class) LeafSetNode.class);
26         entryStrategy = Optional.<ModificationApplyOperation> of(new LeafSetEntryModificationStrategy(schema));
27     }
28
29     @Override
30     boolean isOrdered() {
31         return true;
32     }
33
34     @SuppressWarnings("rawtypes")
35     @Override
36     protected NormalizedNodeContainerBuilder createBuilder(final NormalizedNode<?, ?> original) {
37         checkArgument(original instanceof OrderedLeafSetNode<?>);
38         return ImmutableOrderedLeafSetNodeBuilder.create((OrderedLeafSetNode<?>) original);
39     }
40
41     @Override
42     public Optional<ModificationApplyOperation> getChild(final YangInstanceIdentifier.PathArgument identifier) {
43         if (identifier instanceof YangInstanceIdentifier.NodeWithValue) {
44             return entryStrategy;
45         }
46         return Optional.absent();
47     }
48 }