package hibergui.verify;

import java.util.LinkedHashMap;

public class SelfVerifier {
    
    LinkedHashMap<SelfConstraint, VerificationException> constraints = 
    	new LinkedHashMap<SelfConstraint, VerificationException>();
    
    public void addConstraint(SelfConstraint c, VerificationException r) {
        constraints.put(c, r);
    }
    
    public void removeConstraint(SelfConstraint c) {
        constraints.remove(c);
    }
    
    /* This method is needed to remove the wrapper constraint of a constraint. */
    public void removeConstraint(Constraint c) {
        constraints.remove(c);
    }
    
    public void verify() throws VerificationException {
        for (SelfConstraint c: constraints.keySet())
        	if (!c.check())
        		throw constraints.get(c);
    }

    public boolean isEmpty() {
    	return constraints.isEmpty();
    }
}
