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

com.dimajix.shaded.everit.schema.event.ValidationEvent Maven / Gradle / Ivy

There is a newer version: 1.2.0-synapse3.3-spark3.3-hadoop3.3
Show newest version
package com.dimajix.shaded.everit.schema.event;

import java.util.Objects;

import com.dimajix.shaded.everit.schema.Schema;
import com.dimajix.shaded.json.JSONObject;

public abstract class ValidationEvent {

    protected final S schema;

    protected final Object instance;

    protected ValidationEvent(S schema, Object instance) {
        this.schema = schema;
        this.instance = instance;
    }

    public S getSchema() {
        return schema;
    }

    @Override public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null)
            return false;
        if (!canEqual(o))
            return false;
        ValidationEvent that = (ValidationEvent) o;
        if (!that.canEqual(this)) {
            return false;
        }
        return schema.equals(that.schema) &&
                instance.equals(that.instance);
    }

    boolean canEqual(Object o) {
        return o instanceof ValidationEvent;
    }

    @Override public int hashCode() {
        return Objects.hash(schema, instance);
    }

    @Override
    public String toString() {
        return toJSON(false, false).toString();
    }

    public JSONObject toJSON(boolean includeSchema, boolean includeInstance) {
        JSONObject json = new JSONObject();
        if (includeSchema) {
            json.put("schema", new JSONObject(schema.toString()));
        }
        if (includeInstance) {
            json.put("instance", instance);
        }
        describeTo(json);
        return json;
    }

    abstract void describeTo(JSONObject obj);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy