paragon-0.1.10: lib/se/chalmers/paragon/ActorVariable.java
package se.chalmers.paragon;
/**
* <p>
* An actor variable, to be used in lock clauses or policies. A opposed to
* {@link se.chalmers.paragon.ConcreteActor}, the method equals returns true if
* the variable identifier of the supplied instances is the same.
* </p>
*
* @author Paragon Developers (http://www.cse.chalmers.se/paragon)
*
*/
public class ActorVariable extends Actor {
private int varID;
protected ActorVariable(int var) {
this.varID = var;
}
/**
*
* @return The variable identifier
*/
public int getVar() {
return this.varID;
}
/**
* Returns true if the supplied variable has the same variable identifier as
* this instance
*
* @param av
* The ActorVariable to compare with
* @return True if the supplied variable has the same variable identifier as
* this instance, false otherwise
*/
public boolean equals(Object _av) {
if (_av == null || ! (_av instanceof ActorVariable))
return false;
ActorVariable av = (ActorVariable) _av;
return av.getVar() == this.getVar();
}
public int hashCode() {
return this.varID;
}
public String toString() {
return "_var_" + getVar();
}
}