Adding endpoints to SDC simulator
[integration/csit.git] / plans / so / integration-etsi-testing / so-simulators / sdc-simulator / src / main / java / org / onap / so / sdcsimulator / models / Metadata.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2021 Nordix Foundation.
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  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.so.sdcsimulator.models;
21
22 import java.util.HashSet;
23 import java.util.Set;
24 import org.springframework.util.ObjectUtils;
25 import com.fasterxml.jackson.annotation.JsonProperty;
26
27 /**
28  *
29  * @author Waqas Ikram (waqas.ikram@est.tech)
30  *
31  */
32 public class Metadata extends AssetInfo {
33
34     private static final long serialVersionUID = 2754071491333890698L;
35
36     @JsonProperty("resources")
37     private Set<Resource> resources = new HashSet<>();
38
39     @JsonProperty("artifacts")
40     private Set<Artifact> artifacts = new HashSet<>();
41
42
43     public Set<Resource> getResources() {
44         return resources;
45     }
46
47     public void setResources(final Set<Resource> resources) {
48         this.resources = resources;
49     }
50
51     public Metadata resources(final Set<Resource> resources) {
52         this.resources = resources;
53         return this;
54     }
55
56     public Set<Artifact> getArtifacts() {
57         return artifacts;
58     }
59
60     public void setArtifacts(final Set<Artifact> artifacts) {
61         this.artifacts = artifacts;
62     }
63
64     public Metadata artifacts(Set<Artifact> artifacts) {
65         this.artifacts = artifacts;
66         return this;
67     }
68
69     @Override
70     public int hashCode() {
71         final int prime = 31;
72         int result = 1;
73         result = prime * result + super.hashCode();
74         result = prime * result + ((resources == null) ? 0 : resources.hashCode());
75         result = prime * result + ((artifacts == null) ? 0 : artifacts.hashCode());
76
77         return result;
78     }
79
80     @Override
81     public boolean equals(final Object obj) {
82         if (obj instanceof Metadata) {
83             final Metadata other = (Metadata) obj;
84             return super.equals(obj) && ObjectUtils.nullSafeEquals(resources, other.resources)
85                     && ObjectUtils.nullSafeEquals(artifacts, other.artifacts);
86
87         }
88         return false;
89     }
90
91     @Override
92     public String toString() {
93         final StringBuilder sb = new StringBuilder();
94         sb.append(super.toString());
95         sb.deleteCharAt(sb.length() - 1);
96         sb.append("    resources: ").append(resources).append("\n");
97         sb.append("    artifacts: ").append(artifacts).append("\n");
98
99         sb.append("}");
100         return sb.toString();
101     }
102
103
104 }