2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2019 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2019 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.aai.schemaif.definitions;
26 import org.onap.aai.schemaif.SchemaProviderException;
27 import org.onap.aai.schemaif.definitions.types.DataType;
29 public class PropertySchema {
30 protected String name;
31 protected DataType dataType;
32 protected Boolean required;
33 protected String defaultValue;
34 protected Boolean unique;
35 protected Boolean isReserved;
36 protected Map<String, String> annotations;
38 public String getName() {
42 public DataType getDataType() {
46 public Boolean isRequired() {
50 public Boolean isKey() {
51 return (unique && required);
54 public Boolean isUnique() {
58 public String getDefaultValue() {
62 public Boolean isReserved() {
66 public String getAnnotationValue(String annotation) {
67 return annotations.get(annotation.toLowerCase());
70 public Map<String, String> getAnnotations() {
74 public Object validateValue(String value) throws SchemaProviderException {
75 Object obj = dataType.validateValue(value);
77 throw new SchemaProviderException("Invalid value for porperty '" + name + "': " + value);
83 public String toString() {
84 StringBuilder sb = new StringBuilder();
85 sb.append(" property: " + getName() + "\n");
86 sb.append(" datatype: " + dataType.toString() + "\n");
87 sb.append(" required: " + isRequired() + "\n");
88 sb.append(" key: " + isKey() + "\n");
89 sb.append(" reserved: " + isReserved() + "\n");
90 sb.append(" default: " + getDefaultValue() + "\n");
91 sb.append(" annotations: " + "\n");
93 for (String annotation : annotations.keySet()) {
94 sb.append(" " + annotation + ": " + annotations.get(annotation) + "\n");