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

com.ly.invoker.builder.fa.FANode Maven / Gradle / Ivy

The newest version!
package com.ly.invoker.builder.fa;

import java.util.*;
import java.util.function.BiConsumer;

public abstract class FANode {
    protected final String name = UUID.randomUUID().toString();
    protected final FANodeType type;
    protected final Map table = new HashMap<>();

    protected FANode(FANodeType type) {
        this.type = type;
    }

    public FANodeType getType() {
        return type;
    }

    public boolean isStart() {
        return type == FANodeType.START;
    }

    public boolean isEnd() {
        return type == FANodeType.END;
    }

    public boolean isNormal() {
        return type == FANodeType.NORMAL;
    }

    public String getName() {
        return name;
    }

    public Set events() {
        return table.keySet();
    }

    public abstract N next(T t, FANode node);

    public abstract N move(T t);

    public abstract boolean has(T t);

    public abstract void walk(BiConsumer[]> consumer);

    @Override
    public int hashCode() {
        return Objects.hash(getName(), getType());
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof FANode)) {
            return false;
        }
        FANode node = (FANode) o;
        return getName().equals(node.getName()) && getType() == node.getType();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy