55import java .util .Map ;
66import java .util .Optional ;
77
8- import lombok .EqualsAndHashCode ;
9- import lombok .Getter ;
10- import lombok .Setter ;
11-
12- @ Getter
13- @ Setter
14- @ EqualsAndHashCode
158public class AddOn {
169
1710 private String name ;
@@ -26,23 +19,208 @@ public class AddOn {
2619 private Map <String , UsageLimit > usageLimits ;
2720 private Map <String , UsageLimit > usageLimitsExtensions ;
2821
22+ public String getName () {
23+ return name ;
24+ }
25+
26+ public void setName (String name ) {
27+ this .name = name ;
28+ }
29+
30+ public String getDescription () {
31+ return description ;
32+ }
33+
34+ public void setDescription (String description ) {
35+ this .description = description ;
36+ }
37+
38+ public List <String > getAvailableFor () {
39+ return availableFor ;
40+ }
41+
42+ public void setAvailableFor (List <String > availableFor ) {
43+ this .availableFor = availableFor ;
44+ }
45+
46+ public List <String > getDependsOn () {
47+ return dependsOn ;
48+ }
49+
50+ public void setDependsOn (List <String > dependsOn ) {
51+ this .dependsOn = dependsOn ;
52+ }
53+
54+ public List <String > getExcludes () {
55+ return excludes ;
56+ }
57+
58+ public void setExcludes (List <String > excludes ) {
59+ this .excludes = excludes ;
60+ }
61+
62+ public Object getPrice () {
63+ return price ;
64+ }
65+
66+ public void setPrice (Object price ) {
67+ this .price = price ;
68+ }
69+
70+ public String getUnit () {
71+ return unit ;
72+ }
73+
74+ public void setUnit (String unit ) {
75+ this .unit = unit ;
76+ }
77+
78+ public Boolean getIsPrivate () {
79+ return isPrivate ;
80+ }
81+
82+ public void setIsPrivate (Boolean isPrivate ) {
83+ this .isPrivate = isPrivate ;
84+ }
85+
86+ public Map <String , Feature > getFeatures () {
87+ return features ;
88+ }
89+
90+ public void setFeatures (Map <String , Feature > features ) {
91+ this .features = features ;
92+ }
93+
94+ public Map <String , UsageLimit > getUsageLimits () {
95+ return usageLimits ;
96+ }
97+
98+ public void setUsageLimits (Map <String , UsageLimit > usageLimits ) {
99+ this .usageLimits = usageLimits ;
100+ }
101+
102+ public Map <String , UsageLimit > getUsageLimitsExtensions () {
103+ return usageLimitsExtensions ;
104+ }
105+
106+ public void setUsageLimitsExtensions (Map <String , UsageLimit > usageLimitsExtensions ) {
107+ this .usageLimitsExtensions = usageLimitsExtensions ;
108+ }
109+
110+ @ Override
111+ public int hashCode () {
112+ final int prime = 31 ;
113+ int result = 1 ;
114+ result = prime * result + ((name == null ) ? 0 : name .hashCode ());
115+ result = prime * result + ((description == null ) ? 0 : description .hashCode ());
116+ result = prime * result + ((availableFor == null ) ? 0 : availableFor .hashCode ());
117+ result = prime * result + ((dependsOn == null ) ? 0 : dependsOn .hashCode ());
118+ result = prime * result + ((excludes == null ) ? 0 : excludes .hashCode ());
119+ result = prime * result + ((price == null ) ? 0 : price .hashCode ());
120+ result = prime * result + ((unit == null ) ? 0 : unit .hashCode ());
121+ result = prime * result + ((isPrivate == null ) ? 0 : isPrivate .hashCode ());
122+ result = prime * result + ((features == null ) ? 0 : features .hashCode ());
123+ result = prime * result + ((usageLimits == null ) ? 0 : usageLimits .hashCode ());
124+ result = prime * result + ((usageLimitsExtensions == null ) ? 0 : usageLimitsExtensions .hashCode ());
125+ return result ;
126+ }
127+
128+ @ Override
129+ public boolean equals (Object obj ) {
130+ if (this == obj )
131+ return true ;
132+ if (obj == null )
133+ return false ;
134+ if (getClass () != obj .getClass ())
135+ return false ;
136+ AddOn other = (AddOn ) obj ;
137+ if (name == null ) {
138+ if (other .name != null )
139+ return false ;
140+ } else if (!name .equals (other .name ))
141+ return false ;
142+ if (description == null ) {
143+ if (other .description != null )
144+ return false ;
145+ } else if (!description .equals (other .description ))
146+ return false ;
147+ if (availableFor == null ) {
148+ if (other .availableFor != null )
149+ return false ;
150+ } else if (!availableFor .equals (other .availableFor ))
151+ return false ;
152+ if (dependsOn == null ) {
153+ if (other .dependsOn != null )
154+ return false ;
155+ } else if (!dependsOn .equals (other .dependsOn ))
156+ return false ;
157+ if (excludes == null ) {
158+ if (other .excludes != null )
159+ return false ;
160+ } else if (!excludes .equals (other .excludes ))
161+ return false ;
162+ if (price == null ) {
163+ if (other .price != null )
164+ return false ;
165+ } else if (!price .equals (other .price ))
166+ return false ;
167+ if (unit == null ) {
168+ if (other .unit != null )
169+ return false ;
170+ } else if (!unit .equals (other .unit ))
171+ return false ;
172+ if (isPrivate == null ) {
173+ if (other .isPrivate != null )
174+ return false ;
175+ } else if (!isPrivate .equals (other .isPrivate ))
176+ return false ;
177+ if (features == null ) {
178+ if (other .features != null )
179+ return false ;
180+ } else if (!features .equals (other .features ))
181+ return false ;
182+ if (usageLimits == null ) {
183+ if (other .usageLimits != null )
184+ return false ;
185+ } else if (!usageLimits .equals (other .usageLimits ))
186+ return false ;
187+ if (usageLimitsExtensions == null ) {
188+ if (other .usageLimitsExtensions != null )
189+ return false ;
190+ } else if (!usageLimitsExtensions .equals (other .usageLimitsExtensions ))
191+ return false ;
192+ return true ;
193+ }
194+
195+ @ Override
196+ public String toString () {
197+ return "AddOn [name=" + name + ", description=" + description + ", availableFor=" + availableFor
198+ + ", dependsOn=" + dependsOn + ", excludes=" + excludes + ", price=" + price + ", unit=" + unit
199+ + ", isPrivate=" + isPrivate + ", features=" + features + ", usageLimits=" + usageLimits
200+ + ", usageLimitsExtensions=" + usageLimitsExtensions + "]" ;
201+ }
202+
29203 public Map <String , Object > serializeAddOn () {
30204 Map <String , Object > serializedAddOn = new LinkedHashMap <>();
31205
32- serializedAddOn .put ("description" , description );
206+ if (description != null ) {
207+ serializedAddOn .put ("description" , description );
208+ }
33209
34210 if (availableFor != null && !availableFor .isEmpty ()) {
35211 serializedAddOn .put ("availableFor" , availableFor );
36212 }
37213
38- if (dependsOn != null && !availableFor .isEmpty ()) {
39- serializedAddOn .put ("dependsOn" , availableFor );
214+ if (dependsOn != null && !dependsOn .isEmpty ()) {
215+ serializedAddOn .put ("dependsOn" , dependsOn );
40216 }
41- if (excludes != null && !availableFor .isEmpty ()) {
42- serializedAddOn .put ("excludes" , availableFor );
217+ if (excludes != null && !excludes .isEmpty ()) {
218+ serializedAddOn .put ("excludes" , excludes );
43219 }
44220
45- serializedAddOn .put ("private" , isPrivate );
221+ if (isPrivate != null && isPrivate ) {
222+ serializedAddOn .put ("private" , isPrivate );
223+ }
46224
47225 if (price != null ) {
48226 serializedAddOn .put ("price" , price );
@@ -58,7 +236,7 @@ public Map<String, Object> serializeAddOn() {
58236
59237 serializedAddOn .put ("features" , features );
60238 serializedAddOn .put ("usageLimits" , usageLimits );
61- serializedAddOn .put ("usageLimitExtensions " , usageLimitExtensions );
239+ serializedAddOn .put ("usageLimitsExtensions " , usageLimitExtensions );
62240
63241 return serializedAddOn ;
64242 }
@@ -123,13 +301,13 @@ private Optional<Map<String, Object>> serializeUsageLimits() {
123301
124302 private Optional <Map <String , Object >> serializeUsageLimitExtensions () {
125303
126- if (usageLimits == null ) {
304+ if (usageLimitsExtensions == null ) {
127305 return Optional .empty ();
128306 }
129307
130308 Map <String , Object > serializedUsageLimitExtensions = new LinkedHashMap <>();
131309
132- for (UsageLimit usageLimitExtension : usageLimits .values ()) {
310+ for (UsageLimit usageLimitExtension : usageLimitsExtensions .values ()) {
133311 Optional <Map <String , Object >> serializedUsageLimit = serializeValue (usageLimitExtension .getValue ());
134312 if (serializedUsageLimit .isPresent ()) {
135313
0 commit comments