blob: 7ed42f102eab86e0dffed84b2ae163fa07a6ce03 [file] [log] [blame]
Sho SHIMIZUe4efe452015-08-26 15:06:55 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Sho SHIMIZUe4efe452015-08-26 15:06:55 -07003 *
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.schema.TableSchema;
24
25import com.fasterxml.jackson.annotation.JsonIgnore;
26import com.fasterxml.jackson.annotation.JsonProperty;
27
28/**
29 * select operation.Refer to RFC 7047 Section 5.2.
30 */
31public final class Select implements Operation {
32
33 @JsonIgnore
34 private final TableSchema tableSchema;
35 private final String op;
36 private final List<Condition> where;
37 private final List<String> columns;
38
39 /**
40 * Constructs a Select object.
41 * @param schema TableSchema entity
42 * @param where the List of Condition entity
43 * @param columns the List of column name
44 */
45 public Select(TableSchema schema, List<Condition> where, List<String> columns) {
46 checkNotNull(schema, "TableSchema cannot be null");
47 checkNotNull(where, "where cannot be null");
48 checkNotNull(columns, "columns cannot be null");
49 this.tableSchema = schema;
50 this.op = Operations.SELECT.op();
51 this.where = where;
52 this.columns = columns;
53 }
54
55 /**
56 * Returns the columns member of select operation.
57 * @return the columns member of select operation
58 */
59 public List<String> getColumns() {
60 return columns;
61 }
62
63 /**
64 * Returns the where member of select operation.
65 * @return the where member of select operation
66 */
67 public List<Condition> getWhere() {
68 return where;
69 }
70
71 @Override
72 public String getOp() {
73 return op;
74 }
75
76 @Override
77 public TableSchema getTableSchema() {
78 return tableSchema;
79 }
80
81 /**
82 * For the use of serialization.
83 * @return the table member of update operation
84 */
85 @JsonProperty
86 public String getTable() {
87 return tableSchema.name();
88 }
89}