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 * The "atomic-type" specifies the type of data stored in this column. Refer
25 * to RFC 7047 Section 3.2.
27 public final class AtomicColumnType implements ColumnType {
28 private final BaseType baseType;
29 private final int min;
30 private final int max;
33 * Constructs a AtomicColumnType object.
34 * @param baseType BaseType entity
36 public AtomicColumnType(BaseType baseType) {
37 checkNotNull(baseType, "BaseType cannot be null");
38 this.baseType = baseType;
44 * Constructs a AtomicColumnType object.
45 * @param baseType BaseType entity
46 * @param min min constraint
47 * @param max max constraint
49 public AtomicColumnType(BaseType baseType, int min, int max) {
50 checkNotNull(baseType, "BaseType cannot be null");
51 this.baseType = baseType;
60 public BaseType baseType() {
81 public int hashCode() {
82 return Objects.hash(baseType, min, max);
86 public boolean equals(Object obj) {
90 if (obj instanceof AtomicColumnType) {
91 final AtomicColumnType other = (AtomicColumnType) obj;
92 return Objects.equals(this.baseType, other.baseType)
93 && Objects.equals(this.min, other.min)
94 && Objects.equals(this.max, other.max);
100 public String toString() {
101 return toStringHelper(this).add("baseType", baseType).add("min", min)
102 .add("max", max).toString();