2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.be.components.utils;
23 import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
24 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
25 import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
27 import java.util.ArrayList;
29 public abstract class PropertyDataDefinitionAbstractBuilder<B extends PropertyDataDefinition, T extends PropertyDataDefinitionAbstractBuilder<B, T>> {
33 protected abstract PropertyDataDefinitionAbstractBuilder<B, T> self();
35 abstract B propertyDefinition();
37 PropertyDataDefinitionAbstractBuilder() {
38 propertyDefinition = propertyDefinition();
41 public PropertyDataDefinitionAbstractBuilder<B, T> setUniqueId(String id) {
42 this.propertyDefinition.setUniqueId(id);
46 public PropertyDataDefinitionAbstractBuilder<B, T> setName(String name) {
47 this.propertyDefinition.setName(name);
51 public PropertyDataDefinitionAbstractBuilder<B, T> setValue(String value) {
52 this.propertyDefinition.setValue(value);
56 public PropertyDataDefinitionAbstractBuilder<B, T> setDefaultValue(String value) {
57 this.propertyDefinition.setDefaultValue(value);
61 public PropertyDataDefinitionAbstractBuilder<B, T> setType(String type) {
62 this.propertyDefinition.setType(type);
66 public PropertyDataDefinitionAbstractBuilder<B, T> setOwnerId(String ownerId) {
67 this.propertyDefinition.setOwnerId(ownerId);
71 public PropertyDataDefinitionAbstractBuilder<B, T> setSchemaType(String type) {
72 if (propertyDefinition.getSchema() == null) {
73 propertyDefinition.setSchema(new SchemaDefinition());
75 if (propertyDefinition.getSchema().getProperty() == null) {
76 propertyDefinition.getSchema().setProperty(new PropertyDataDefinition());
78 propertyDefinition.getSchema().getProperty().setType(type);
82 public PropertyDataDefinitionAbstractBuilder<B, T> addGetInputValue(String inputName) {
83 GetInputValueDataDefinition getInputValueDataDefinition = new GetInputValueDataDefinition();
84 getInputValueDataDefinition.setInputName(inputName);
85 getInputValueDataDefinition.setInputId(inputName);
86 if (propertyDefinition.getGetInputValues() == null) {
87 propertyDefinition.setGetInputValues(new ArrayList<>());
89 propertyDefinition.getGetInputValues().add(getInputValueDataDefinition);
93 public PropertyDataDefinitionAbstractBuilder<B, T> setIsRequired(boolean required) {
94 this.propertyDefinition.setRequired(required);
98 public PropertyDataDefinitionAbstractBuilder<B, T> setDescription(String description) {
99 this.propertyDefinition.setDescription(description);
103 public PropertyDataDefinitionAbstractBuilder<B, T> setIsPassword(boolean isPassword) {
104 this.propertyDefinition.setRequired(isPassword);
108 public PropertyDataDefinitionAbstractBuilder<B, T> setStatus(String status) {
109 this.propertyDefinition.setStatus(status);
113 public abstract B build();