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