BUG-4295: instantiate MERGE operations lazily
[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,
38             final Optional<TreeNode> storeMetadata) {
39         throw new IllegalStateException("Schema Context is not available.");
40     }
41
42     @Override
43     public Optional<ModificationApplyOperation> getChild(final PathArgument child) {
44         throw new IllegalStateException("Schema Context is not available.");
45     }
46
47     @Override
48     void verifyStructure(final NormalizedNode<?, ?> modification, final boolean verifyChildren) {
49         throw new IllegalStateException("Schema Context is not available.");
50     }
51
52     @Override
53     ChildTrackingPolicy getChildPolicy() {
54         throw new IllegalStateException("Schema Context is not available.");
55     }
56
57     @Override
58     void mergeIntoModifiedNode(final ModifiedNode node, final NormalizedNode<?, ?> value, final Version version) {
59         throw new IllegalStateException("Schema Context is not available.");
60     }
61
62     @Override
63     void recursivelyVerifyStructure(NormalizedNode<?, ?> value) {
64         throw new IllegalStateException("Schema Context is not available.");
65     }
66 }