re base code
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / utils / AnnotationBuilder.java
1 package org.openecomp.sdc.be.components.utils;
2
3 import org.openecomp.sdc.be.datatypes.elements.Annotation;
4 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
5 import org.openecomp.sdc.be.model.PropertyDefinition;
6
7 import java.util.ArrayList;
8 import java.util.List;
9
10 public class AnnotationBuilder {
11
12     private Annotation annotation;
13
14     private AnnotationBuilder() {
15         annotation = new Annotation();
16     }
17
18     public static AnnotationBuilder create() {
19         return new AnnotationBuilder();
20     }
21
22     public AnnotationBuilder setType(String type) {
23         annotation.setType(type);
24         return this;
25     }
26
27     public AnnotationBuilder setName(String name) {
28         annotation.setName(name);
29         return this;
30     }
31
32     public AnnotationBuilder addProperty(String name) {
33         PropertyDefinition prop = new PropertyDataDefinitionBuilder()
34                 .setName(name)
35                 .build();
36         List<PropertyDataDefinition> annotationProps = getAnnotationProps();
37         annotationProps.add(prop);
38         return this;
39     }
40
41     public Annotation build() {
42         return annotation;
43     }
44
45     private List<PropertyDataDefinition> getAnnotationProps() {
46         if (annotation.getProperties() == null) {
47             annotation.setProperties(new ArrayList<>());
48         }
49         return annotation.getProperties();
50     }
51
52 }