2 * Copyright (c) 2013 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
8 package org.opendaylight.yangtools.yang.data.operations;
10 import org.opendaylight.yangtools.yang.data.api.ModifyAction;
11 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
12 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
13 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
14 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
16 import com.google.common.base.Optional;
19 * Edit config operations utilities.
21 public final class DataOperations {
23 private DataOperations() {}
25 public static Optional<ContainerNode> modify(ContainerSchemaNode schema, ContainerNode stored,
26 ContainerNode modified) throws DataModificationException {
27 return modify(schema, stored, modified, ModifyAction.MERGE);
30 public static Optional<MapNode> modify(ListSchemaNode schema, MapNode stored, MapNode modified)
31 throws DataModificationException {
32 return modify(schema, stored, modified, ModifyAction.MERGE);
35 public static Optional<ContainerNode> modify(ContainerSchemaNode schema, ContainerNode stored,
36 ContainerNode modified, ModifyAction defaultOperation) throws DataModificationException {
38 OperationStack operations = new OperationStack(defaultOperation);
40 return new ContainerNodeModification().modify(schema, Optional.fromNullable(stored),
41 Optional.fromNullable(modified), operations);
44 public static Optional<MapNode> modify(ListSchemaNode schema, MapNode stored, MapNode modified,
45 ModifyAction defaultOperation) throws DataModificationException {
47 OperationStack operations = new OperationStack(defaultOperation);
49 return new MapNodeModification().modify(schema, Optional.fromNullable(stored), Optional.fromNullable(modified),