CodeCoverage improvement for dcaegen2-platform-mod-genprocessor
[dcaegen2/platform.git] / mod / genprocessor / src / main / java / org / onap / dcae / genprocessor / CompList.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  * 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * ============LICENSE_END=========================================================
17  */
18 package org.onap.dcae.genprocessor;
19
20 import java.net.URI;
21 import java.net.URISyntaxException;
22 import java.util.List;
23
24 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
25 import com.fasterxml.jackson.annotation.JsonProperty;
26
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29
30 @JsonIgnoreProperties(ignoreUnknown = true)
31 public class CompList {
32
33     static final Logger LOG = LoggerFactory.getLogger(CompList.class);
34
35     @JsonIgnoreProperties(ignoreUnknown = true)
36     public static class CompShort {
37         @JsonProperty("id")
38         public String id;
39         @JsonProperty("name")
40         public String name;
41         @JsonProperty("version")
42         public String version;
43         @JsonProperty("description")
44         public String description;
45         @JsonProperty("componentType")
46         public String componentType;
47         @JsonProperty("owner")
48         public String owner;
49         @JsonProperty("componentUrl")
50         public String componentUrl;
51         @JsonProperty("whenAdded")
52         public String whenAdded;
53
54         public String getNameForJavaClass() {
55             return Utils.formatNameForJavaClass(this.name);
56         }
57
58         public URI getComponentUrlAsURI() {
59             try {
60                 return new URI(this.componentUrl);
61             } catch (URISyntaxException e) {
62                 throw new RuntimeException("Component URL is bad");
63             }
64         }
65     }
66
67     @JsonProperty("components")
68     public List<CompShort> components;
69
70 }
71