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

edu.stanford.protege.webprotege.hierarchy.EdgeChange Maven / Gradle / Ivy

There is a newer version: 2.0.2-WHO
Show newest version
package edu.stanford.protege.webprotege.hierarchy;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonSubTypes;

import java.util.function.Consumer;

/**
 * Matthew Horridge
 * Stanford Center for Biomedical Informatics Research
 * 2021-04-20
 */
@JsonSubTypes({
        @JsonSubTypes.Type(AddEdge.class),
        @JsonSubTypes.Type(RemoveEdge.class)
})
public abstract class EdgeChange extends GraphModelChange {


    private GraphEdge edge;

    protected EdgeChange() {

    }

    protected EdgeChange(GraphEdge edge) {
        this.edge = edge;
    }

    @JsonIgnore
    public GraphNode getPredecessor() {
        return edge.getPredecessor();
    }

    @JsonIgnore
    public GraphNode getSuccessor() {
        return edge.getSuccessor();
    }

    public GraphEdge getEdge() {
        return edge;
    }

    @Override
    void forEachGraphNode(Consumer> nodeConsumer) {
        nodeConsumer.accept(edge.getPredecessor());
        nodeConsumer.accept(edge.getSuccessor());
    }
}