public class ValidateReverseContext {

    private FlowchartContext flowchartContext;
    private HashMap reverseChildListMap;
    private NodeHList reachableList;

    public ValidateReverseContext(FlowchartContext flowchartContext) {
        this.flowchartContext = flowchartContext;
        validateReverseContextInit();
    }

    public final void validateReverseContextInit()  {
        this.reverseChildListMap = new HashMap();
        this.reachableList = new NodeHList();
    }

    public final NodechildIList getReverseChildList(Node mapkey) {
        NodechildIList reverseChildList = reverseChildListMap.get(mapkey);
        if (reverseChildList == null) {
            reverseChildList = new NodechildIList();
            reverseChildListMap.put(mapkey, reverseChildList);
        }
        return reverseChildList;
    }

    public final void addReverseChild(Node mapkey, Nodechild reverseChild) {
        NodechildIList reverseChildList = getReverseChildList(mapkey);
        reverseChildList.add(reverseChild);
    }

    public final boolean hasReverseChilds(Node mapkey) {
        return reverseChildListMap.containsKey(mapkey);
    }

    public final boolean hasReverseChild(Node mapkey, Nodechild reverseChild) {
        NodechildIList reverseChildList = reverseChildListMap.get(mapkey);
        return reverseChildList != null && reverseChildList.contains(reverseChild);
    }

    public final NodeHList getReachableList() {
        return reachableList;
    }

    public final boolean isReachable(Node item) {
        return reachableList.contains(item);
    }

    public final boolean addReachable(Node item) {
        return reachableList.add(item);
    }

    public final FlowchartContext getFlowchartContext() {
        return flowchartContext;
    }
}