[SDC-29] Amdocs OnBoard 1707 initial commit.
[sdc.git] / openecomp-be / lib / openecomp-heat-lib / src / main / java / org / openecomp / sdc / heat / datatypes / manifest / FileData.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.heat.datatypes.manifest;
22
23 import org.apache.commons.collections4.CollectionUtils;
24
25 import java.util.ArrayList;
26 import java.util.Arrays;
27 import java.util.HashSet;
28 import java.util.List;
29 import java.util.Set;
30 import java.util.function.Predicate;
31
32 public class FileData {
33
34   public static Set<Type> heatFileTypes =
35       new HashSet<>(Arrays.asList(Type.HEAT, Type.HEAT_NET, Type.HEAT_VOL));
36   private Boolean isBase;
37   private String file;
38   private Type type;
39   private List<FileData> data;
40
41   public static Predicate<FileData> buildFileDataPredicateByType(Type... types) {
42     return fileData -> Arrays.asList(types).contains(fileData.getType());
43   }
44
45   public static boolean isHeatFile(Type type) {
46     return heatFileTypes.contains(type);
47   }
48
49   public Boolean getBase() {
50     return isBase;
51   }
52
53   public void setBase(Boolean base) {
54     isBase = base;
55   }
56
57   public String getFile() {
58     return file;
59   }
60
61   public void setFile(String file) {
62     this.file = file;
63   }
64
65   public Type getType() {
66     return type;
67   }
68
69   public void setType(Type type) {
70     this.type = type;
71   }
72
73   public List<FileData> getData() {
74     return data;
75   }
76
77   public void setData(List<FileData> data) {
78     this.data = data;
79   }
80
81   /**
82    * Add file data.
83    *
84    * @param data the data
85    */
86   public void addFileData(FileData data) {
87     if (CollectionUtils.isEmpty(this.data)) {
88       this.data = new ArrayList<>();
89     }
90     this.data.add(data);
91   }
92
93   public enum Type {
94
95     HEAT("HEAT"),
96     HEAT_ENV("HEAT_ENV"),
97     HEAT_NET("HEAT_NET"),
98     HEAT_VOL("HEAT_VOL"),
99     CHEF("CHEF"),
100     PUPPET("PUPPET"),
101     SHELL("SHELL"),
102     YANG("YANG"),
103     YANG_XML("YANG_XML"),
104     BPEL("BPEL"),
105     DG_XML("DG_XML"),
106     MURANO_PKG("MURANO_PKG"),
107     VENDOR_LICENSE("VENDOR_LICENSE"),
108     VF_LICENSE("VF_LICENSE"),
109     OTHER("OTHER");
110
111     private String displayName;
112
113     Type(String displayName) {
114       this.displayName = displayName;
115     }
116
117     public String getDisplayName() {
118       return displayName;
119     }
120
121     public static boolean isArtifact(Type fileType)
122     {
123       return !Arrays.asList(HEAT,HEAT_ENV, HEAT_VOL).contains(fileType);
124     }
125
126   }
127 }