![JAR search and dependency download from the Maven repository](/logo.png)
org.ggp.base.apps.validator.ValidatorThread Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of alloy-ggp-base Show documentation
Show all versions of alloy-ggp-base Show documentation
A modified version of the GGP-Base library for Alloy.
The newest version!
package org.ggp.base.apps.validator;
import java.util.ArrayList;
import java.util.List;
import org.ggp.base.apps.validator.event.ValidatorFailureEvent;
import org.ggp.base.apps.validator.event.ValidatorSuccessEvent;
import org.ggp.base.util.game.Game;
import org.ggp.base.util.observer.Event;
import org.ggp.base.util.observer.Observer;
import org.ggp.base.util.observer.Subject;
import org.ggp.base.validator.GameValidator;
import org.ggp.base.validator.ValidatorException;
import org.ggp.base.validator.ValidatorWarning;
public final class ValidatorThread extends Thread implements Subject
{
private final Game theGame;
private final GameValidator theValidator;
private final List observers;
public ValidatorThread(Game theGame, GameValidator theValidator)
{
this.theGame = theGame;
this.theValidator = theValidator;
this.observers = new ArrayList();
}
@Override
public void addObserver(Observer observer)
{
observers.add(observer);
}
@Override
public void notifyObservers(Event event)
{
for (Observer observer : observers)
{
observer.observe(event);
}
}
@Override
public void run()
{
try {
List warnings = theValidator.checkValidity(theGame);
notifyObservers(new ValidatorSuccessEvent(theValidator.getClass().getSimpleName(), warnings));
} catch (ValidatorException ve) {
notifyObservers(new ValidatorFailureEvent(theValidator.getClass().getSimpleName(), ve));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy