public class UnionType extends AssociativeType implements java.lang.Cloneable
The depth subtyping is similar to that of RecordTypes. However,
the width subtyping for UnionType is opposite compared to
RecordType i.e., a UnionType with more fields
is a supertype of a UnionType with a subset of the fields.
For example, {|x = double, y = int} is a supertype of {|x = double}.
MAXDEPTHBOUNDHASH_INVALID| Constructor and Description |
|---|
UnionType(java.lang.String[] labels,
Type[] types)
Construct a new UnionType with the specified labels and types.
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
_compare(StructuredType type)
Compare this type with the specified type.
|
protected StructuredType |
_getRepresentative()
Return a static instance of RecordType.
|
protected StructuredType |
_greatestLowerBound(StructuredType type)
Return the greatest lower bound of this type with the specified
type.
|
protected StructuredType |
_leastUpperBound(StructuredType type)
Return the least Upper bound of this type with the specified
type.
|
java.lang.Object |
clone()
Return a deep copy of this UnionType if it is a variable, or
itself if it is a constant.
|
Token |
convert(Token token)
Convert the argument token into a UnionToken having this
type, if lossless conversion can be done.
|
int |
depth()
Return the depth of a union type.
|
boolean |
equals(java.lang.Object object)
Determine if the argument represents the same UnionType as this
object.
|
Type |
get(java.lang.String label)
Return the type of the specified label.
|
java.lang.Class |
getTokenClass()
Return the class for tokens that this type represents.
|
InequalityTerm |
getTypeTerm(java.lang.String label)
Return the InequalityTerm representing the type of the specified
label.
|
int |
hashCode()
Return a hash code value for this object.
|
void |
initialize(Type type)
Set the elements that have declared type BaseType.UNKNOWN (the leaf
type variable) to the specified type.
|
boolean |
isAbstract()
Test if this type corresponds to an abstract token
class.
|
boolean |
isCompatible(Type type)
Test if the argument type is compatible with this type.
|
boolean |
isConstant()
Test if this UnionType is a constant.
|
boolean |
isInstantiable()
Test if this type corresponds to an instantiable token
class.
|
boolean |
isSubstitutionInstance(Type type)
Test if the specified type is a substitution instance of this
type.
|
java.util.Set |
labelSet()
Return the labels of this record type as a Set.
|
java.lang.String |
toString()
Return the string representation of this type.
|
void |
updateType(StructuredType newType)
Update this Type to the specified UnionType.
|
add, divide, getTypeHash, modulo, multiply, one, subtract, zeropublic UnionType(java.lang.String[] labels, Type[] types)
labels - An array of String.types - An array of Type.java.lang.IllegalArgumentException - If the two arrays do not have
the same size.java.lang.NullPointerException - If one of the arguments is null.public java.lang.Object clone()
clone in interface Typeclone in class StructuredTypepublic Token convert(Token token) throws IllegalActionException
convert in interface Typetoken - A token.IllegalActionException - If lossless conversion
cannot be done.public int depth()
depth in class StructuredTypepublic boolean equals(java.lang.Object object)
public Type get(java.lang.String label)
get in class AssociativeTypelabel - The specified label.public java.lang.Class getTokenClass()
getTokenClass in interface Typepublic InequalityTerm getTypeTerm(java.lang.String label)
label - The specified label.InequalityTermpublic int hashCode()
hashCode in class java.lang.Objectpublic void initialize(Type type)
initialize in class StructuredTypetype - the type to set the leaf type variable to.public boolean isAbstract()
isAbstract in interface TypeisAbstract in class StructuredTypepublic boolean isCompatible(Type type)
isCompatible in interface Typetype - An instance of Type.public boolean isConstant()
isConstant in interface Typepublic boolean isInstantiable()
isInstantiable in interface Typepublic boolean isSubstitutionInstance(Type type)
isSubstitutionInstance in interface Typetype - A Type.Type.isSubstitutionInstance(ptolemy.data.type.Type)public java.util.Set labelSet()
public java.lang.String toString()
public void updateType(StructuredType newType) throws IllegalActionException
updateType in class StructuredTypenewType - A StructuredType.IllegalActionException - If the specified type is not a
UnionType or it does not have the same structure as this one.protected int _compare(StructuredType type)
_compare in class StructuredTypetype - a UnionType.java.lang.IllegalArgumentException - If the specified type is
not a UnionType.protected StructuredType _getRepresentative()
_getRepresentative in class StructuredTypeprotected StructuredType _greatestLowerBound(StructuredType type)
_greatestLowerBound in class StructuredTypetype - a UnionType.java.lang.IllegalArgumentException - If the specified type is
not a UnionType.protected StructuredType _leastUpperBound(StructuredType type)
_leastUpperBound in class StructuredTypetype - a UnionType.java.lang.IllegalArgumentException - If the specified type is
not a UnionType.