All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.rx.core.ObjectChangedEvent Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy