-
Notifications
You must be signed in to change notification settings - Fork 164
/
Copy pathChangedExtensions.java
42 lines (36 loc) · 1.35 KB
/
ChangedExtensions.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.qdesrame.openapi.diff.model.schema;
import com.qdesrame.openapi.diff.model.Changed;
import com.qdesrame.openapi.diff.model.DiffContext;
import com.qdesrame.openapi.diff.model.DiffResult;
import lombok.Getter;
import lombok.Setter;
import java.util.LinkedHashMap;
import java.util.Map;
@Getter
@Setter
public class ChangedExtensions implements Changed {
private final Map<String, Object> oldExtensions;
private final Map<String, Object> newExtensions;
private final DiffContext context;
private Map<String, Object> increased;
private Map<String, Object> missing;
private Map<String, Changed> changed;
public ChangedExtensions(Map<String, Object> oldExtensions, Map<String, Object> newExtensions, DiffContext context) {
this.oldExtensions = oldExtensions;
this.newExtensions = newExtensions;
this.context = context;
this.increased = new LinkedHashMap<>();
this.missing = new LinkedHashMap<>();
this.changed = new LinkedHashMap<>();
}
@Override
public DiffResult isChanged() {
if (increased.isEmpty() && missing.isEmpty() && changed.isEmpty()) {
return DiffResult.NO_CHANGES;
}
if (changed.values().stream().allMatch(Changed::isCompatible)) {
return DiffResult.COMPATIBLE;
}
return DiffResult.INCOMPATIBLE;
}
}