2 * Copyright 2015 Open Networking Laboratory
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.onosproject.ovsdb.rfc.schema.type;
18 import static com.google.common.base.MoreObjects.toStringHelper;
19 import static com.google.common.base.Preconditions.checkNotNull;
21 import java.util.Objects;
24 * a JSON object that describes the type of a database column, with key and
25 * value. Refer to RFC 7047 Section 3.2.
27 public final class KeyValuedColumnType implements ColumnType {
28 private final BaseType keyType;
29 private final BaseType valueType;
30 private final int min;
31 private final int max;
34 * Constructs a KeyValuedColumnType object.
35 * @param keyType BaseType entity
36 * @param valueType BaseType entity
37 * @param min min constraint
38 * @param max max constraint
40 public KeyValuedColumnType(BaseType keyType, BaseType valueType, int min,
42 checkNotNull(keyType, "keyType cannot be null");
43 checkNotNull(valueType, "valueType cannot be null");
44 this.keyType = keyType;
45 this.valueType = valueType;
54 public BaseType keyType() {
62 public BaseType valueType() {
83 public int hashCode() {
84 return Objects.hash(keyType, valueType, min, max);
88 public boolean equals(Object obj) {
92 if (obj instanceof KeyValuedColumnType) {
93 final KeyValuedColumnType other = (KeyValuedColumnType) obj;
94 return Objects.equals(this.keyType, other.keyType)
95 && Objects.equals(this.valueType, other.valueType)
96 && Objects.equals(this.min, other.min)
97 && Objects.equals(this.max, other.max);
103 public String toString() {
104 return toStringHelper(this).add("keyType", keyType)
105 .add("valueType", valueType).add("min", min).add("max", max)