blob: b28277978d86e1b260c9066b19013e0a3b3e90d7 [file] [log] [blame]
Sho SHIMIZUe4efe452015-08-26 15:06:55 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.ovsdb.rfc.operations;
17
18import static com.google.common.base.Preconditions.checkNotNull;
19
20import java.util.List;
21
22import org.onosproject.ovsdb.rfc.notation.Condition;
23import org.onosproject.ovsdb.rfc.notation.Mutation;
24import org.onosproject.ovsdb.rfc.schema.TableSchema;
25
26import com.fasterxml.jackson.annotation.JsonIgnore;
27import com.fasterxml.jackson.annotation.JsonProperty;
28
29/**
30 * mutate operation.Refer to RFC 7047 Section 5.2.
31 */
32public final class Mutate implements Operation {
33
34 @JsonIgnore
35 private final TableSchema tableSchema;
36 private final String op;
37 private final List<Condition> where;
38 private final List<Mutation> mutations;
39
40 /**
41 * Constructs a Mutate object.
42 * @param schema TableSchema entity
43 * @param where the List of Condition entity
44 * @param mutations the List of Mutation entity
45 */
46 public Mutate(TableSchema schema, List<Condition> where,
47 List<Mutation> mutations) {
48 checkNotNull(schema, "TableSchema cannot be null");
49 checkNotNull(mutations, "mutations cannot be null");
50 checkNotNull(where, "where cannot be null");
51 this.tableSchema = schema;
52 this.op = Operations.MUTATE.op();
53 this.where = where;
54 this.mutations = mutations;
55 }
56
57 /**
58 * Returns the mutations member of mutate operation.
59 * @return the mutations member of mutate operation
60 */
61 public List<Mutation> getMutations() {
62 return mutations;
63 }
64
65 /**
66 * Returns the where member of mutate operation.
67 * @return the where member of mutate operation
68 */
69 public List<Condition> getWhere() {
70 return where;
71 }
72
73 @Override
74 public String getOp() {
75 return op;
76 }
77
78 @Override
79 public TableSchema getTableSchema() {
80 return tableSchema;
81 }
82
83 /**
84 * For the use of serialization.
85 * @return the table member of update operation
86 */
87 @JsonProperty
88 public String getTable() {
89 return tableSchema.name();
90 }
91}