|
@ -2,6 +2,8 @@ package com.databasir.core.diff.processor; |
|
|
|
|
|
|
|
|
import com.databasir.core.diff.data.DiffType; |
|
|
import com.databasir.core.diff.data.DiffType; |
|
|
import com.databasir.core.diff.data.FieldDiff; |
|
|
import com.databasir.core.diff.data.FieldDiff; |
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
@ -12,6 +14,8 @@ import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
public interface DiffProcessor<T> { |
|
|
public interface DiffProcessor<T> { |
|
|
|
|
|
|
|
|
|
|
|
Logger log = LoggerFactory.getLogger(DiffProcessor.class); |
|
|
|
|
|
|
|
|
FieldDiff process(String fieldName, List<T> original, List<T> current); |
|
|
FieldDiff process(String fieldName, List<T> original, List<T> current); |
|
|
|
|
|
|
|
|
default FieldDiff diffTableField(List<T> original, |
|
|
default FieldDiff diffTableField(List<T> original, |
|
@ -41,7 +45,10 @@ public interface DiffProcessor<T> { |
|
|
default Map<String, T> toMap(List<T> content, Function<T, String> idMapping) { |
|
|
default Map<String, T> toMap(List<T> content, Function<T, String> idMapping) { |
|
|
return content |
|
|
return content |
|
|
.stream() |
|
|
.stream() |
|
|
.collect(Collectors.toMap(idMapping, Function.identity())); |
|
|
.collect(Collectors.toMap(idMapping, Function.identity(), (a, b) -> { |
|
|
|
|
|
log.warn("Duplicate key, origin = {}, current = {}", a, b); |
|
|
|
|
|
return a; |
|
|
|
|
|
})); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
default List<FieldDiff> originalRemovedField(Map<String, T> originalMapById, |
|
|
default List<FieldDiff> originalRemovedField(Map<String, T> originalMapById, |
|
|