c4b169b3d32581cc1dd6c5fd80e8de6803c57820
[sdc.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 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 package org.openecomp.sdc.vendorlicense.dao.types;
21
22 import java.util.Objects;
23 import org.openecomp.sdc.versioning.dao.types.Version;
24 import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
25
26 public class LimitEntity implements VersionableEntity {
27
28     private static final String ENTITY_TYPE = "Limit";
29     private String id;
30     private String vendorLicenseModelId;
31     private String epLkgId;
32     private String name;
33     private LimitType type;
34     private String description;
35     private String metric;
36     private Version version;
37     private String value;
38     private String unit;
39     private AggregationFunction aggregationFunction;
40     private String time;
41     //Defined and used only to find parent(EP/LKG) of Limit. Not to be persisted in DB and License
42
43     // Xmls
44     private String parent;
45
46     public LimitEntity() {
47     }
48
49     public LimitEntity(String vlmId, Version version, String epLkgId, String id) {
50         this.vendorLicenseModelId = vlmId;
51         this.version = version;
52         this.epLkgId = epLkgId;
53         this.id = id;
54     }
55
56     public String getUnit() {
57         return unit;
58     }
59
60     public void setUnit(String unit) {
61         this.unit = unit;
62     }
63
64     public AggregationFunction getAggregationFunction() {
65         return aggregationFunction;
66     }
67
68     public void setAggregationFunction(AggregationFunction aggregationFunction) {
69         this.aggregationFunction = aggregationFunction;
70     }
71
72     public String getTime() {
73         return time;
74     }
75
76     public void setTime(String time) {
77         this.time = time;
78     }
79
80     @Override
81     public String getEntityType() {
82         return ENTITY_TYPE;
83     }
84
85     @Override
86     public String getFirstClassCitizenId() {
87         return getVendorLicenseModelId();
88     }
89
90     @Override
91     public String getId() {
92         return id;
93     }
94
95     @Override
96     public void setId(String id) {
97         this.id = id;
98     }
99
100     @Override
101     public Version getVersion() {
102         return version;
103     }
104
105     @Override
106     public void setVersion(Version version) {
107         this.version = version;
108     }
109
110     public String getEpLkgId() {
111         return epLkgId;
112     }
113
114     public void setEpLkgId(String epLkgId) {
115         this.epLkgId = epLkgId;
116     }
117
118     public String getVendorLicenseModelId() {
119         return vendorLicenseModelId;
120     }
121
122     public void setVendorLicenseModelId(String vendorLicenseModelId) {
123         this.vendorLicenseModelId = vendorLicenseModelId;
124     }
125
126     public LimitType getType() {
127         return type;
128     }
129
130     public void setType(LimitType type) {
131         this.type = type;
132     }
133
134     public String getName() {
135         return name;
136     }
137
138     public void setName(String name) {
139         this.name = name;
140     }
141
142     public String getMetric() {
143         return metric;
144     }
145
146     public void setMetric(String metric) {
147         this.metric = metric;
148     }
149
150     public String getDescription() {
151         return description;
152     }
153
154     public void setDescription(String description) {
155         this.description = description;
156     }
157
158     public String getValue() {
159         return value;
160     }
161
162     public void setValue(String value) {
163         this.value = value;
164     }
165     //Defined and used only to find parent(EP/LKG) of Limit. Not to be persisted in DB and License
166
167     // Xmls
168     public String getParent() {
169         return parent;
170     }
171
172     public void setParent(String parent) {
173         this.parent = parent;
174     }
175
176     @Override
177     public int hashCode() {
178         return Objects.hash(vendorLicenseModelId, version, epLkgId, id, name, description, type, metric, unit, time, aggregationFunction, value);
179     }
180
181     @Override
182     public boolean equals(Object obj) {
183         if (this == obj) {
184             return true;
185         }
186         if (obj == null || getClass() != obj.getClass()) {
187             return false;
188         }
189         LimitEntity that = (LimitEntity) obj;
190         return Objects.equals(that.unit, unit) && Objects.equals(that.value, value) && Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId)
191             && Objects.equals(epLkgId, that.epLkgId) && Objects.equals(id, that.id) && Objects.equals(name, that.name) && Objects
192             .equals(description, that.description) && Objects.equals(type, that.type) && Objects.equals(metric, that.metric) && Objects
193             .equals(aggregationFunction, that.aggregationFunction);
194     }
195
196     @Override
197     public String toString() {
198         return "LimitEntity{" + "vendorLicenseModelId='" + vendorLicenseModelId + '\'' + ", version=" + version + ", epLkgId=" + epLkgId + ", id='"
199             + id + '\'' + ", name='" + name + '\'' + ", description='" + description + '\'' + ", type=" + type + ", metric=" + metric + ", value='"
200             + value + '\'' + ", unit='" + unit + '\'' + ", aggregationFunction=" + aggregationFunction + ", time=" + time + '}';
201     }
202 }