improved diff for journal
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
package de.srsoftware.umbrella.messagebus.events;
|
||||
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static java.text.MessageFormat.format;
|
||||
import static java.util.Optional.*;
|
||||
|
||||
import de.srsoftware.tools.Diff;
|
||||
import de.srsoftware.tools.Mappable;
|
||||
import de.srsoftware.umbrella.core.model.UmbrellaUser;
|
||||
import java.util.HashMap;
|
||||
@@ -45,11 +45,6 @@ public abstract class Event<Payload extends Mappable> {
|
||||
|
||||
public abstract String describe();
|
||||
|
||||
private String diff(Map<String, Object> a, Map<String, Object> b){
|
||||
// TODO: replace by better implementation
|
||||
return format("{0}\n→\n{1}",dropMarkdown(a),dropMarkdown(b));
|
||||
}
|
||||
|
||||
private Map<String, Object> dropMarkdown(Map<String, Object> map) {
|
||||
var result = new HashMap<String, Object>();
|
||||
for (var entry : map.entrySet()){
|
||||
@@ -61,7 +56,7 @@ public abstract class Event<Payload extends Mappable> {
|
||||
}
|
||||
|
||||
public Optional<String> diff(){
|
||||
return oldData == null ? empty() : of(diff(oldData,payload.toMap()));
|
||||
return oldData == null ? empty() : of(Diff.MapDiff.diff(dropMarkdown(oldData),dropMarkdown(payload.toMap())));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user