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;
20 import java.util.Objects;
23 import com.google.common.collect.Sets;
26 * One of the strings "integer", "real", "boolean", "string", or "uuid",
27 * representing the specified scalar type. Refer to RFC 7047 Section 3.2.
29 public final class IntegerBaseType implements BaseType {
30 private final int min;
31 private final int max;
32 private final Set<Integer> enums;
35 * Constructs a IntegerBaseType object.
37 public IntegerBaseType() {
38 this.min = Integer.MIN_VALUE;
39 this.max = Integer.MAX_VALUE;
40 this.enums = Sets.newHashSet();
44 * Constructs a IntegerBaseType object.
45 * @param min min constraint
46 * @param max max constraint
47 * @param enums enums constraint
49 public IntegerBaseType(int min, int max, Set<Integer> enums) {
75 public Set<Integer> enums() {
80 public int hashCode() {
81 return Objects.hash(min, max, enums);
85 public boolean equals(Object obj) {
89 if (obj instanceof IntegerBaseType) {
90 final IntegerBaseType other = (IntegerBaseType) obj;
91 return Objects.equals(this.enums, other.enums)
92 && Objects.equals(this.min, other.min)
93 && Objects.equals(this.max, other.max);
99 public String toString() {
100 return toStringHelper(this).add("min", min).add("max", max)
101 .add("enums", enums).toString();