Bug 5730 - Delete subset of list items using PATCH?
[netconf.git] / restconf / sal-rest-connector / src / main / java / org / opendaylight / netconf / sal / restconf / impl / PATCHEntity.java
1 /*
2  * Copyright (c) 2016 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
9 package org.opendaylight.netconf.sal.restconf.impl;
10
11 import com.google.common.base.Preconditions;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
13 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
14
15 public class PATCHEntity {
16
17     private final String operation;
18     private final String editId;
19     private final YangInstanceIdentifier targetNode;
20     private final NormalizedNode<?,?> node;
21
22     /**
23      * Constructor to create PATCHEntity for PATCH operations which require value leaf representing data to be present.
24      * @param editId Id of PATCH edit
25      * @param operation PATCH edit operation
26      * @param targetNode Target node for PATCH edit operation
27      * @param node Data defined by value leaf used by edit operation
28      */
29     public PATCHEntity(final String editId, final String operation, final YangInstanceIdentifier targetNode, final
30     NormalizedNode<?, ?> node) {
31         this.editId = Preconditions.checkNotNull(editId);
32         this.operation = Preconditions.checkNotNull(operation);
33         this.targetNode = Preconditions.checkNotNull(targetNode);
34         this.node = Preconditions.checkNotNull(node);
35     }
36
37     /**
38      * Constructor to create PATCHEntity for PATCH operations which do not allow value leaf representing data to be
39      * present. <code>node</code> is set to <code>null</code> meaning that data are not allowed for edit operation.
40      * @param editId Id of PATCH edit
41      * @param operation PATCH edit operation
42      * @param targetNode Target node for PATCH edit operation
43      */
44     public PATCHEntity(final String editId, final String operation, final YangInstanceIdentifier targetNode) {
45         this.editId = Preconditions.checkNotNull(editId);
46         this.operation = Preconditions.checkNotNull(operation);
47         this.targetNode = Preconditions.checkNotNull(targetNode);
48         this.node = null;
49     }
50
51     public String getOperation() {
52         return operation;
53     }
54
55     public String getEditId() {
56         return editId;
57     }
58
59     public YangInstanceIdentifier getTargetNode() {
60         return targetNode;
61     }
62
63     public NormalizedNode<?, ?> getNode() {
64         return node;
65     }
66
67 }