Fix child ordering assumptions
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / AlwaysFailOperation.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 com.google.common.base.Optional;
11 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
13 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNode;
14 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
15
16 /**
17  * An implementation of apply operation which fails to do anything,
18  * consistently. An instance of this class is used by the data tree
19  * if it does not have a SchemaContext attached and hence cannot
20  * perform anything meaningful.
21  */
22 final class AlwaysFailOperation extends ModificationApplyOperation {
23     static final ModificationApplyOperation INSTANCE = new AlwaysFailOperation();
24
25     private AlwaysFailOperation() {
26
27     }
28
29     @Override
30     Optional<TreeNode> apply(final ModifiedNode modification,
31             final Optional<TreeNode> storeMeta, final Version version) {
32         throw new IllegalStateException("Schema Context is not available.");
33     }
34
35     @Override
36     void checkApplicable(final YangInstanceIdentifier path,final NodeModification modification, final Optional<TreeNode> storeMetadata) {
37         throw new IllegalStateException("Schema Context is not available.");
38     }
39
40     @Override
41     public Optional<ModificationApplyOperation> getChild(final PathArgument child) {
42         throw new IllegalStateException("Schema Context is not available.");
43     }
44
45     @Override
46     void verifyStructure(final ModifiedNode modification) {
47         throw new IllegalStateException("Schema Context is not available.");
48     }
49
50     @Override
51     ChildTrackingPolicy getChildPolicy() {
52         throw new IllegalStateException("Schema Context is not available.");
53     }
54 }