+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.yangtools.yang.data.impl.schema.tree;
-
-import com.google.common.base.Optional;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+import java.util.Optional;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
/**
- * An implementation of apply operation which fails to do anything,
- * consistently. An instance of this class is used by the data tree
- * if it does not have a SchemaContext attached and hence cannot
- * perform anything meaningful.
+ * An implementation of apply operation which fails to do anything, consistently. An instance of this class is used by
+ * the data tree if it does not have a SchemaContext attached and hence cannot perform anything meaningful.
*/
-final class AlwaysFailOperation implements ModificationApplyOperation {
- @Override
- public Optional<TreeNode> apply(final ModifiedNode modification,
- final Optional<TreeNode> storeMeta, final Version version) {
- throw new IllegalStateException("Schema Context is not available.");
+final class AlwaysFailOperation extends NonApplyDelegatedModificationApplyOperation {
+ static final ModificationApplyOperation INSTANCE = new AlwaysFailOperation();
+
+ private AlwaysFailOperation() {
+
}
@Override
- public void checkApplicable(final YangInstanceIdentifier path,final NodeModification modification, final Optional<TreeNode> storeMetadata) {
- throw new IllegalStateException("Schema Context is not available.");
+ ModificationApplyOperation delegate() {
+ throw ise();
}
@Override
- public Optional<ModificationApplyOperation> getChild(final PathArgument child) {
- throw new IllegalStateException("Schema Context is not available.");
+ Optional<TreeNode> apply(final ModifiedNode modification, final Optional<TreeNode> currentMeta,
+ final Version version) {
+ throw ise();
}
@Override
- public void verifyStructure(final ModifiedNode modification) {
- throw new IllegalStateException("Schema Context is not available.");
+ void checkApplicable(final ModificationPath path, final NodeModification modification,
+ final Optional<TreeNode> current, final Version version) throws DataValidationFailedException {
+ throw ise();
+ }
+
+ private static IllegalStateException ise() {
+ return new IllegalStateException("Schema Context is not available.");
}
-}
\ No newline at end of file
+}