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 StringBaseType implements BaseType {
30 private final int minLength;
31 private final int maxLength;
32 private final Set<String> enums;
35 * Constructs a StringBaseType object.
37 public StringBaseType() {
38 this.minLength = Integer.MIN_VALUE;
39 this.maxLength = Integer.MAX_VALUE;
40 this.enums = Sets.newHashSet();
44 * Constructs a StringBaseType object.
45 * @param minLength minLength constraint
46 * @param maxLength maxLength constraint
47 * @param enums enums constraint
49 public StringBaseType(int minLength, int maxLength, Set<String> enums) {
50 this.minLength = minLength;
51 this.maxLength = maxLength;
59 public int getMinLength() {
67 public int getMaxLength() {
75 public Set<String> getEnums() {
80 public int hashCode() {
81 return Objects.hash(minLength, maxLength, enums);
85 public boolean equals(Object obj) {
89 if (obj instanceof StringBaseType) {
90 final StringBaseType other = (StringBaseType) obj;
91 return Objects.equals(this.enums, other.enums)
92 && Objects.equals(this.minLength, other.minLength)
93 && Objects.equals(this.maxLength, other.maxLength);
99 public String toString() {
100 return toStringHelper(this).add("minLength", minLength)
101 .add("maxLength", maxLength).add("enums", enums).toString();