Bug 5509 - HTTP Patch in Restconf doesn't support general absolute or relative target...
[netconf.git] / restconf / sal-rest-connector / src / main / java / org / opendaylight / netconf / sal / restconf / impl / PATCHEditOperation.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 javax.annotation.Nonnull;
12
13 /**
14  *
15  * Each YANG patch edit specifies one edit operation on the target data
16  * node.  The set of operations is aligned with the NETCONF edit
17  * operations, but also includes some new operations.
18  *
19  */
20 public enum PATCHEditOperation {
21     CREATE,  //post
22     DELETE,  //delete
23     INSERT,  //post
24     MERGE,
25     MOVE,    //delete+post
26     REPLACE, //put
27     REMOVE;  //delete
28
29     /**
30      * Not all patch operations support value node. Check if operation requires value or not.
31      * @param operation Name of the operation to be checked
32      * @return true if operation requires value, false otherwise
33      */
34     public static final boolean isPatchOperationWithValue(@Nonnull final String operation) {
35         switch (PATCHEditOperation.valueOf(operation.toUpperCase())) {
36             case CREATE:
37                 // fall through
38             case MERGE:
39                 // fall through
40             case REPLACE:
41                 // fall through
42             case INSERT:
43                 return true;
44             default:
45                 return false;
46         }
47     }
48 }