Package ptolemy.actor.util
Class BooleanDependency
- java.lang.Object
-
- ptolemy.actor.util.BooleanDependency
-
- All Implemented Interfaces:
java.lang.Comparable<Dependency>
,Dependency
- Direct Known Subclasses:
SuperdenseDependency
public class BooleanDependency extends java.lang.Object implements Dependency
This dependency represents causal relationships that are either present or not. That is, given any two ports, either one depends causally on the other or not. See the paper "Causality Interfaces for Actor Networks" by Ye Zhou and Edward A. Lee, ACM Transactions on Embedded Computing Systems (TECS), April 2008, as available as Technical Report No. UCB/EECS-2006-148, November 16, 2006.- Since:
- Ptolemy II 8.0
- Version:
- $Id$
- Author:
- Edward A. Lee
- Pt.AcceptedRating:
- Red (eal)
- Pt.ProposedRating:
- Yellow (eal)
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
_value
The value.static BooleanDependency
OPLUS_IDENTITY
The additive identity, which has value false and indicates that there is no dependency.static BooleanDependency
OTIMES_IDENTITY
The multiplicative identity, which has value true and indicates that there is a dependency.-
Fields inherited from interface ptolemy.actor.util.Dependency
EQUALS, GREATER_THAN, INCOMPARABLE, LESS_THAN
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BooleanDependency(boolean value)
Construct a dependency with the specified value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(Dependency dependency)
Return Dependency.LESS_THAN, EQUALS, or GREATER_THAN depending on whether the argument is less than, equal to, or greater than this dependency.boolean
equals(java.lang.Object object)
Return true if the value of this dependency equals that of the specified one, and the specified one is an instance of RealDependency.int
hashCode()
Return the same hashCode that that Java Boolean object would return had it the same value, which is the integer 1231 if this object represents true, and the integer 1237 if this object represents false.Dependency
oPlus(Dependency d)
Return a dependency that results from parallel composition of this one and the specified one.Dependency
oPlusIdentity()
Return the dependency that when added to any other dependency using oPlus() yields the other dependency.Dependency
oTimes(Dependency d)
Return a dependency that results from serial composition of this one and the specified one.Dependency
oTimesIdentity()
Return the dependency that when multiplied by any other dependency using oTimes() yields the other dependency.java.lang.String
toString()
Return a string representation in the form "BooleanDependency(value)", where value is "true" or "false".static BooleanDependency
valueOf(boolean value)
Return an instance of BooleanDependency with the specified value.
-
-
-
Field Detail
-
OPLUS_IDENTITY
public static final BooleanDependency OPLUS_IDENTITY
The additive identity, which has value false and indicates that there is no dependency.
-
OTIMES_IDENTITY
public static final BooleanDependency OTIMES_IDENTITY
The multiplicative identity, which has value true and indicates that there is a dependency.
-
_value
protected boolean _value
The value.
-
-
Method Detail
-
compareTo
public int compareTo(Dependency dependency)
Return Dependency.LESS_THAN, EQUALS, or GREATER_THAN depending on whether the argument is less than, equal to, or greater than this dependency. Boolean dependencies are totally ordered, so this never returns Dependency.INCOMPARABLE. The order is that the OPLUS_IDENTITY (false) is less than OTIMES_IDENTITY (true).- Specified by:
compareTo
in interfacejava.lang.Comparable<Dependency>
- Parameters:
dependency
- The dependency to compare against.- Returns:
- The result of comparison.
-
equals
public boolean equals(java.lang.Object object)
Return true if the value of this dependency equals that of the specified one, and the specified one is an instance of RealDependency.- Overrides:
equals
in classjava.lang.Object
- Parameters:
object
- The object to compare against.- Returns:
- true if the values are equal
-
hashCode
public int hashCode()
Return the same hashCode that that Java Boolean object would return had it the same value, which is the integer 1231 if this object represents true, and the integer 1237 if this object represents false.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- A hash code for this object.
-
oPlus
public Dependency oPlus(Dependency d)
Return a dependency that results from parallel composition of this one and the specified one. This is a dependency whose value is the logical OR of the value of this dependency and specified one.- Specified by:
oPlus
in interfaceDependency
- Parameters:
d
- The dependency to add.- Returns:
- A dependency whose value is the logical OR of the two dependency values.
- Throws:
java.lang.ClassCastException
- if d is not a BooleanDependency.
-
oPlusIdentity
public Dependency oPlusIdentity()
Return the dependency that when added to any other dependency using oPlus() yields the other dependency.- Specified by:
oPlusIdentity
in interfaceDependency
- Returns:
- The additive identity.
-
oTimes
public Dependency oTimes(Dependency d)
Return a dependency that results from serial composition of this one and the specified one. This is a dependency whose value is the logical AND of the value of this dependency and specified one.- Specified by:
oTimes
in interfaceDependency
- Parameters:
d
- The dependency to multiply.- Returns:
- A dependency whose value is the logical AND of the value of this one and the specified one.
- Throws:
java.lang.ClassCastException
- if d is not a BooleanDependency.
-
oTimesIdentity
public Dependency oTimesIdentity()
Return the dependency that when multiplied by any other dependency using oTimes() yields the other dependency.- Specified by:
oTimesIdentity
in interfaceDependency
- Returns:
- The multiplicative identity.
-
toString
public java.lang.String toString()
Return a string representation in the form "BooleanDependency(value)", where value is "true" or "false".- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation.
-
valueOf
public static BooleanDependency valueOf(boolean value)
Return an instance of BooleanDependency with the specified value. This is preferable to use over the constructor because there are only ever two possible values.- Parameters:
value
- The specified value.- Returns:
- an instance of BooleanDependency, if value
is true, then
OTIMES_IDENTITY
is returned, if value is false, thenOPLUS_IDENTITY
.
-
-