76286240ce12ffed7f61608af272ce97d77dd2ac
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / UnorderedLeafSetModificationStrategy.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
12 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
13 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
14 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
15 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeContainerBuilder;
16 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
17 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
18
19 final class UnorderedLeafSetModificationStrategy extends AbstractLeafSetModificationStrategy {
20     UnorderedLeafSetModificationStrategy(final LeafListSchemaNode schema, final DataTreeConfiguration treeConfig) {
21         super(schema, treeConfig);
22     }
23
24     @SuppressWarnings("rawtypes")
25     @Override
26     protected NormalizedNodeContainerBuilder createBuilder(final NormalizedNode<?, ?> original) {
27         checkArgument(original instanceof LeafSetNode<?>);
28         return ImmutableLeafSetNodeBuilder.create((LeafSetNode<?>) original);
29     }
30
31     @Override
32     protected NormalizedNode<?, ?> createEmptyValue(final NormalizedNode<?, ?> original) {
33         checkArgument(original instanceof LeafSetNode<?>);
34         return ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(((LeafSetNode<?>) original).getIdentifier())
35                 .build();
36     }
37 }