Skip to content

Commit 239f571

Browse files
quen2404joschi
authored andcommitted
refactor: replace lombok by plain getter / setter / hashCode / equals methods
1 parent 0280663 commit 239f571

34 files changed

+2808
-223
lines changed

core/pom.xml

-5
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@
4242
<groupId>commons-httpclient</groupId>
4343
<artifactId>commons-httpclient</artifactId>
4444
</dependency>
45-
<dependency>
46-
<groupId>org.projectlombok</groupId>
47-
<artifactId>lombok</artifactId>
48-
<scope>provided</scope>
49-
</dependency>
5045
<dependency>
5146
<groupId>org.junit.jupiter</groupId>
5247
<artifactId>junit-jupiter</artifactId>
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,54 @@
11
package com.qdesrame.openapi.diff.core.compare;
22

33
import com.qdesrame.openapi.diff.core.model.DiffContext;
4-
import lombok.Value;
4+
import java.util.Objects;
55

6-
@Value
7-
public class CacheKey {
6+
public final class CacheKey {
7+
private final String left;
8+
private final String right;
9+
private final DiffContext context;
810

9-
String left;
10-
String right;
11-
DiffContext context;
11+
public CacheKey(final String left, final String right, final DiffContext context) {
12+
this.left = left;
13+
this.right = right;
14+
this.context = context;
15+
}
16+
17+
public String getLeft() {
18+
return this.left;
19+
}
20+
21+
public String getRight() {
22+
return this.right;
23+
}
24+
25+
public DiffContext getContext() {
26+
return this.context;
27+
}
28+
29+
@Override
30+
public boolean equals(Object o) {
31+
if (this == o) return true;
32+
if (o == null || getClass() != o.getClass()) return false;
33+
CacheKey cacheKey = (CacheKey) o;
34+
return Objects.equals(left, cacheKey.left)
35+
&& Objects.equals(right, cacheKey.right)
36+
&& Objects.equals(context, cacheKey.context);
37+
}
38+
39+
@Override
40+
public int hashCode() {
41+
return Objects.hash(left, right, context);
42+
}
43+
44+
@java.lang.Override
45+
public java.lang.String toString() {
46+
return "CacheKey(left="
47+
+ this.getLeft()
48+
+ ", right="
49+
+ this.getRight()
50+
+ ", context="
51+
+ this.getContext()
52+
+ ")";
53+
}
1254
}

core/src/main/java/com/qdesrame/openapi/diff/core/compare/OpenApiDiff.java

+100-7
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,12 @@
1717
import java.util.Map;
1818
import java.util.Optional;
1919
import java.util.stream.Collectors;
20-
import lombok.Getter;
2120
import org.slf4j.Logger;
2221
import org.slf4j.LoggerFactory;
2322

24-
@Getter
2523
public class OpenApiDiff {
26-
2724
public static final String SWAGGER_VERSION_V2 = "2.0";
28-
2925
private static final Logger logger = LoggerFactory.getLogger(OpenApiDiff.class);
30-
3126
private PathsDiff pathsDiff;
3227
private PathDiff pathDiff;
3328
private SchemaDiff schemaDiff;
@@ -47,7 +42,6 @@ public class OpenApiDiff {
4742
private OAuthFlowDiff oAuthFlowDiff;
4843
private ExtensionsDiff extensionsDiff;
4944
private MetadataDiff metadataDiff;
50-
5145
private final OpenAPI oldSpecOpenApi;
5246
private final OpenAPI newSpecOpenApi;
5347
private List<Endpoint> newEndpoints;
@@ -132,7 +126,6 @@ private void setChangedExtension(ChangedExtensions changedExtension) {
132126

133127
private void preProcess(OpenAPI openApi) {
134128
List<SecurityRequirement> securityRequirements = openApi.getSecurity();
135-
136129
if (securityRequirements != null) {
137130
List<SecurityRequirement> distinctSecurityRequirements =
138131
securityRequirements.stream().distinct().collect(Collectors.toList());
@@ -171,4 +164,104 @@ private ChangedOpenApi getChangedOpenApi() {
171164
.setChangedOperations(changedOperations)
172165
.setChangedExtensions(changedExtensions);
173166
}
167+
168+
public PathsDiff getPathsDiff() {
169+
return this.pathsDiff;
170+
}
171+
172+
public PathDiff getPathDiff() {
173+
return this.pathDiff;
174+
}
175+
176+
public SchemaDiff getSchemaDiff() {
177+
return this.schemaDiff;
178+
}
179+
180+
public ContentDiff getContentDiff() {
181+
return this.contentDiff;
182+
}
183+
184+
public ParametersDiff getParametersDiff() {
185+
return this.parametersDiff;
186+
}
187+
188+
public ParameterDiff getParameterDiff() {
189+
return this.parameterDiff;
190+
}
191+
192+
public RequestBodyDiff getRequestBodyDiff() {
193+
return this.requestBodyDiff;
194+
}
195+
196+
public ResponseDiff getResponseDiff() {
197+
return this.responseDiff;
198+
}
199+
200+
public HeadersDiff getHeadersDiff() {
201+
return this.headersDiff;
202+
}
203+
204+
public HeaderDiff getHeaderDiff() {
205+
return this.headerDiff;
206+
}
207+
208+
public ApiResponseDiff getApiResponseDiff() {
209+
return this.apiResponseDiff;
210+
}
211+
212+
public OperationDiff getOperationDiff() {
213+
return this.operationDiff;
214+
}
215+
216+
public SecurityRequirementsDiff getSecurityRequirementsDiff() {
217+
return this.securityRequirementsDiff;
218+
}
219+
220+
public SecurityRequirementDiff getSecurityRequirementDiff() {
221+
return this.securityRequirementDiff;
222+
}
223+
224+
public SecuritySchemeDiff getSecuritySchemeDiff() {
225+
return this.securitySchemeDiff;
226+
}
227+
228+
public OAuthFlowsDiff getOAuthFlowsDiff() {
229+
return this.oAuthFlowsDiff;
230+
}
231+
232+
public OAuthFlowDiff getOAuthFlowDiff() {
233+
return this.oAuthFlowDiff;
234+
}
235+
236+
public ExtensionsDiff getExtensionsDiff() {
237+
return this.extensionsDiff;
238+
}
239+
240+
public MetadataDiff getMetadataDiff() {
241+
return this.metadataDiff;
242+
}
243+
244+
public OpenAPI getOldSpecOpenApi() {
245+
return this.oldSpecOpenApi;
246+
}
247+
248+
public OpenAPI getNewSpecOpenApi() {
249+
return this.newSpecOpenApi;
250+
}
251+
252+
public List<Endpoint> getNewEndpoints() {
253+
return this.newEndpoints;
254+
}
255+
256+
public List<Endpoint> getMissingEndpoints() {
257+
return this.missingEndpoints;
258+
}
259+
260+
public List<ChangedOperation> getChangedOperations() {
261+
return this.changedOperations;
262+
}
263+
264+
public ChangedExtensions getChangedExtensions() {
265+
return this.changedExtensions;
266+
}
174267
}

core/src/main/java/com/qdesrame/openapi/diff/core/compare/SecurityDiffInfo.java

+42-8
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,25 @@
55
import io.swagger.v3.oas.models.security.SecurityScheme;
66
import java.util.List;
77
import java.util.Optional;
8-
import lombok.AllArgsConstructor;
9-
import lombok.Data;
108

11-
@Data
12-
@AllArgsConstructor
139
public class SecurityDiffInfo {
14-
1510
private String ref;
1611
private SecurityScheme securityScheme;
1712
private List<String> scopes;
1813

14+
public SecurityDiffInfo(
15+
final String ref, final SecurityScheme securityScheme, final List<String> scopes) {
16+
this.ref = ref;
17+
this.securityScheme = securityScheme;
18+
this.scopes = scopes;
19+
}
20+
1921
public static SecurityRequirement getSecurityRequirement(
2022
List<SecurityDiffInfo> securityDiffInfoList) {
2123
SecurityRequirement securityRequirement = new SecurityRequirement();
2224
for (SecurityDiffInfo securityDiffInfo : securityDiffInfoList) {
2325
securityRequirement.put(securityDiffInfo.getRef(), securityDiffInfo.getScopes());
2426
}
25-
2627
return securityRequirement;
2728
}
2829

@@ -47,9 +48,7 @@ public boolean equals(Object o) {
4748
if (o == null || getClass() != o.getClass()) {
4849
return false;
4950
}
50-
5151
SecurityDiffInfo that = (SecurityDiffInfo) o;
52-
5352
if (securityScheme != null
5453
? !securityScheme.equals(that.securityScheme)
5554
: that.securityScheme != null) {
@@ -64,4 +63,39 @@ public int hashCode() {
6463
result = 31 * result + (scopes != null ? scopes.hashCode() : 0);
6564
return result;
6665
}
66+
67+
public String getRef() {
68+
return this.ref;
69+
}
70+
71+
public SecurityScheme getSecurityScheme() {
72+
return this.securityScheme;
73+
}
74+
75+
public List<String> getScopes() {
76+
return this.scopes;
77+
}
78+
79+
public void setRef(final String ref) {
80+
this.ref = ref;
81+
}
82+
83+
public void setSecurityScheme(final SecurityScheme securityScheme) {
84+
this.securityScheme = securityScheme;
85+
}
86+
87+
public void setScopes(final List<String> scopes) {
88+
this.scopes = scopes;
89+
}
90+
91+
@java.lang.Override
92+
public java.lang.String toString() {
93+
return "SecurityDiffInfo(ref="
94+
+ this.getRef()
95+
+ ", securityScheme="
96+
+ this.getSecurityScheme()
97+
+ ", scopes="
98+
+ this.getScopes()
99+
+ ")";
100+
}
67101
}

core/src/main/java/com/qdesrame/openapi/diff/core/compare/schemadiffresult/SchemaDiffResult.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
import io.swagger.v3.oas.models.Components;
1414
import io.swagger.v3.oas.models.media.Schema;
1515
import java.util.*;
16-
import lombok.Getter;
1716

18-
@Getter
1917
public class SchemaDiffResult {
2018
protected ChangedSchema changedSchema;
2119
protected OpenApiDiff openApiDiff;
@@ -55,7 +53,6 @@ public <V extends Schema<X>, X> Optional<ChangedSchema> diff(
5553
.setReadOnly(new ChangedReadOnly(left.getReadOnly(), right.getReadOnly(), context))
5654
.setWriteOnly(new ChangedWriteOnly(left.getWriteOnly(), right.getWriteOnly(), context))
5755
.setMaxLength(new ChangedMaxLength(left.getMaxLength(), right.getMaxLength(), context));
58-
5956
openApiDiff
6057
.getExtensionsDiff()
6158
.diff(left.getExtensions(), right.getExtensions(), context)
@@ -64,11 +61,9 @@ public <V extends Schema<X>, X> Optional<ChangedSchema> diff(
6461
.getMetadataDiff()
6562
.diff(left.getDescription(), right.getDescription(), context)
6663
.ifPresent(changedSchema::setDescription);
67-
6864
Map<String, Schema> leftProperties = null == left ? null : left.getProperties();
6965
Map<String, Schema> rightProperties = null == right ? null : right.getProperties();
7066
MapKeyDiff<String, Schema> propertyDiff = MapKeyDiff.diff(leftProperties, rightProperties);
71-
7267
for (String key : propertyDiff.getSharedKey()) {
7368
openApiDiff
7469
.getSchemaDiff()
@@ -80,9 +75,7 @@ public <V extends Schema<X>, X> Optional<ChangedSchema> diff(
8075
.ifPresent(
8176
changedSchema1 -> changedSchema.getChangedProperties().put(key, changedSchema1));
8277
}
83-
8478
compareAdditionalProperties(refSet, left, right, context);
85-
8679
changedSchema
8780
.getIncreasedProperties()
8881
.putAll(filterProperties(Change.Type.ADDED, propertyDiff.getIncreased(), context));
@@ -157,4 +150,12 @@ private void compareAdditionalProperties(
157150
isChanged(apChangedSchema).ifPresent(changedSchema::setAddProp);
158151
}
159152
}
153+
154+
public ChangedSchema getChangedSchema() {
155+
return this.changedSchema;
156+
}
157+
158+
public OpenApiDiff getOpenApiDiff() {
159+
return this.openApiDiff;
160+
}
160161
}

0 commit comments

Comments
 (0)