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;
30 public class PropertySchema {
31 protected String name;
32 protected DataType dataType;
33 protected Boolean required;
34 protected String defaultValue;
35 protected Boolean unique;
36 protected Boolean isReserved;
37 protected Map<String,String> annotations;
39 public String getName() {
43 public DataType getDataType() {
47 public Boolean isRequired() {
51 public Boolean isKey() {
52 return (unique && required);
55 public Boolean isUnique() {
59 public String getDefaultValue() {
63 public Boolean isReserved() {
67 public String getAnnotationValue(String annotation) {
68 return annotations.get(annotation.toLowerCase());
71 public Map<String, String> getAnnotations() {
75 public Object validateValue(String value) throws SchemaProviderException {
76 Object obj = dataType.validateValue(value);
78 throw new SchemaProviderException("Invalid value for porperty '" + name + "': " + value);
84 public String toString() {
85 StringBuilder sb = new StringBuilder();
86 sb.append(" property: " + getName() + "\n");
87 sb.append(" datatype: " + dataType.toString() + "\n");
88 sb.append(" required: " + isRequired() + "\n");
89 sb.append(" key: " + isKey() + "\n");
90 sb.append(" reserved: " + isReserved() + "\n");
91 sb.append(" default: " + getDefaultValue() + "\n");
92 sb.append(" annotations: " + "\n");
94 for (String annotation : annotations.keySet()) {
95 sb.append(" " + annotation + ": " + annotations.get(annotation) + "\n");