org.rx.core.ObjectChangedEvent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rxlib Show documentation
Show all versions of rxlib Show documentation
A set of utilities for Java
package org.rx.core;
import lombok.Getter;
import java.util.EventObject;
import java.util.Map;
@Getter
public class ObjectChangedEvent extends EventObject {
private static final long serialVersionUID = -2993269004798534124L;
final Map changedMap;
public ObjectChangedEvent(Object source, Map changedMap) {
super(source);
this.changedMap = changedMap;
}
public T source() {
return (T) getSource();
}
public T readValue(String path) {
return readValue(path, false);
}
public T readValue(String path, boolean throwOnEmptyChild) {
return Sys.readJsonValue(changedMap, path, p -> {
if (p instanceof ObjectChangeTracker.ChangedValue) {
return ((ObjectChangeTracker.ChangedValue) p).newValue();
}
return p;
}, throwOnEmptyChild);
}
}