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.tree.TreeType;
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 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
18 * Presence container modification strategy. In addition to {@link ContainerModificationStrategy} it also enforces
19 * presence of mandatory leaves.
21 final class PresenceContainerModificationStrategy extends ContainerModificationStrategy {
22 private final MandatoryLeafEnforcer enforcer;
24 PresenceContainerModificationStrategy(final ContainerSchemaNode schemaNode, final TreeType treeType) {
25 super(schemaNode, treeType);
26 enforcer = MandatoryLeafEnforcer.forContainer(schemaNode, treeType);
30 protected TreeNode applyMerge(final ModifiedNode modification, final TreeNode currentMeta, final Version version) {
31 final TreeNode ret = super.applyMerge(modification, currentMeta, version);
32 enforcer.enforceOnTreeNode(ret);
37 protected TreeNode applyWrite(final ModifiedNode modification, final Optional<TreeNode> currentMeta,
38 final Version version) {
39 final TreeNode ret = super.applyWrite(modification, currentMeta, version);
40 enforcer.enforceOnTreeNode(ret);
45 protected TreeNode applyTouch(final ModifiedNode modification, final TreeNode currentMeta, final Version version) {
46 final TreeNode ret = super.applyTouch(modification, currentMeta, version);
47 enforcer.enforceOnTreeNode(ret);