9d1fbe3cb308d503e96daa67152a15ca0a997e0b
[sdc.git] /
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.structure;
22
23 import java.util.ArrayList;
24 import java.util.List;
25
26 import lombok.AccessLevel;
27 import lombok.EqualsAndHashCode;
28 import lombok.Getter;
29 import lombok.Setter;
30 import org.openecomp.sdc.datatypes.error.ErrorMessage;
31 import org.openecomp.sdc.heat.datatypes.manifest.FileData;
32
33 @Getter
34 @Setter
35 @EqualsAndHashCode
36 public class Artifact implements Comparable<Artifact> {
37
38     private String fileName;
39
40     @Setter(AccessLevel.NONE)
41     @EqualsAndHashCode.Exclude
42     private FileData.Type type;
43
44     @EqualsAndHashCode.Exclude
45     private List<ErrorMessage> errors;
46
47     public Artifact(String fileName, FileData.Type type) {
48         this.fileName = fileName;
49         this.type = type;
50     }
51
52     /**
53      * Add error to error list.
54      *
55      * @param error the error
56      */
57     public void addErrorToErrorList(ErrorMessage error) {
58         if (this.errors == null || this.errors.isEmpty()) {
59             this.errors = new ArrayList<>();
60         }
61
62         this.errors.add(error);
63     }
64
65     @Override
66     public int compareTo(Artifact artifact) {
67         return artifact.getFileName().compareTo(this.getFileName());
68     }
69 }