lishuai | 91d986c | 2015-07-28 09:45:20 +0800 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.ovsdb.rfc.message; |
| 17 | |
| 18 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 19 | import static com.google.common.base.Preconditions.checkNotNull; |
| 20 | |
| 21 | import java.util.Objects; |
| 22 | import java.util.Set; |
| 23 | |
| 24 | import com.fasterxml.jackson.annotation.JsonIgnore; |
| 25 | import com.fasterxml.jackson.annotation.JsonInclude; |
| 26 | |
| 27 | /** |
| 28 | * Monitor Requst information that need to monitor table. |
| 29 | */ |
| 30 | @JsonInclude(JsonInclude.Include.NON_NULL) |
| 31 | public final class MonitorRequest { |
| 32 | @JsonIgnore |
| 33 | private final String tableName; |
| 34 | private final Set<String> columns; |
| 35 | private final MonitorSelect select; |
| 36 | |
| 37 | /** |
| 38 | * Constructs a MonitorRequest object. |
| 39 | * @param tableName table name |
| 40 | * @param columns a set of column name |
| 41 | * @param select monitor action |
| 42 | */ |
| 43 | public MonitorRequest(String tableName, Set<String> columns, |
| 44 | MonitorSelect select) { |
| 45 | checkNotNull(tableName, "tableName is not null"); |
| 46 | checkNotNull(columns, "columns is not null"); |
| 47 | checkNotNull(select, "select is not null"); |
| 48 | this.tableName = tableName; |
| 49 | this.columns = columns; |
| 50 | this.select = select; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Returns tableName. |
| 55 | * @return tableName |
| 56 | */ |
| 57 | public String getTableName() { |
| 58 | return tableName; |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Returns select. |
| 63 | * @return select |
| 64 | */ |
| 65 | public MonitorSelect getSelect() { |
| 66 | return select; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Returns columns. |
| 71 | * @return columns |
| 72 | */ |
| 73 | public Set<String> getColumns() { |
| 74 | return columns; |
| 75 | } |
| 76 | |
| 77 | @Override |
| 78 | public int hashCode() { |
| 79 | return Objects.hash(tableName, select, columns); |
| 80 | } |
| 81 | |
| 82 | @Override |
| 83 | public boolean equals(Object obj) { |
| 84 | if (this == obj) { |
| 85 | return true; |
| 86 | } |
| 87 | if (obj instanceof MonitorRequest) { |
| 88 | final MonitorRequest other = (MonitorRequest) obj; |
| 89 | return Objects.equals(this.tableName, other.tableName) |
| 90 | && Objects.equals(this.select, other.select) |
| 91 | && Objects.equals(this.columns, other.columns); |
| 92 | } |
| 93 | return false; |
| 94 | } |
| 95 | |
| 96 | @Override |
| 97 | public String toString() { |
| 98 | return toStringHelper(this).add("tableName", tableName) |
| 99 | .add("select", select).add("columns", columns).toString(); |
| 100 | } |
| 101 | } |