2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
11 import com.google.common.base.Optional;
12 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
13 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
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 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
19 * Presence container modification strategy. In addition to {@link ContainerModificationStrategy} it also enforces
20 * presence of mandatory leaves.
22 final class PresenceContainerModificationStrategy extends ContainerModificationStrategy {
23 private final MandatoryLeafEnforcer enforcer;
25 PresenceContainerModificationStrategy(final ContainerSchemaNode schemaNode,
26 final DataTreeConfiguration treeConfig) {
27 super(schemaNode, treeConfig);
28 enforcer = MandatoryLeafEnforcer.forContainer(schemaNode, treeConfig);
32 void verifyStructure(final NormalizedNode<?, ?> writtenValue, final boolean verifyChildren) {
33 super.verifyStructure(writtenValue, verifyChildren);
35 enforcer.enforceOnData(writtenValue);
40 protected TreeNode applyMerge(final ModifiedNode modification, final TreeNode currentMeta, final Version version) {
41 final TreeNode ret = super.applyMerge(modification, currentMeta, version);
42 enforcer.enforceOnTreeNode(ret);
47 protected TreeNode applyWrite(final ModifiedNode modification, final Optional<TreeNode> currentMeta,
48 final Version version) {
49 final TreeNode ret = super.applyWrite(modification, currentMeta, version);
50 enforcer.enforceOnTreeNode(ret);
55 protected TreeNode applyTouch(final ModifiedNode modification, final TreeNode currentMeta, final Version version) {
56 final TreeNode ret = super.applyTouch(modification, currentMeta, version);
57 enforcer.enforceOnTreeNode(ret);