edu.mit.csail.sdg.alloy4viz
Class AlloyRelation

java.lang.Object
  extended by edu.mit.csail.sdg.alloy4viz.AlloyElement
      extended by edu.mit.csail.sdg.alloy4viz.AlloyRelation
All Implemented Interfaces:
java.lang.Comparable<AlloyElement>

public final class AlloyRelation
extends AlloyElement

Immutable; represents an Alloy relation of 2 or higher arity.

Thread Safety: Can be called only by the AWT event thread.


Field Summary
static AlloyRelation EXTENDS
          This caches an instance of the "extends" AlloyRelation, so we don't have to keep re-constructing it.
static AlloyRelation IN
          This caches an instance of the "in" AlloyRelation, so we don't have to keep re-constructing it.
 boolean isMeta
          Records whether this relation is known to be "meta"; NOTE: this value is NOT USED during equals() comparison.
 boolean isPrivate
          Records whether this relation is known to be "private"; NOTE: this value is NOT USED during equals() comparison.
 
Constructor Summary
AlloyRelation(java.lang.String name, boolean isPrivate, boolean isMeta, java.util.List<AlloyType> types)
          Constructs a new AlloyRelation with that name and that list of types; types.size() must be 2 or above.
 
Method Summary
 int compareTo(AlloyElement other)
          When comparing two AlloyRelation objects, we first compare the name, then the arity, then the types.
 int compareTo(AlloyRelation other)
          When comparing two AlloyRelation objects, we first compare the name, then the arity, then the types.
 boolean equals(java.lang.Object other)
          Two relations are equal if they have the same name, and the same list of types.
 int getArity()
          Returns the arity of the relation.
 java.util.List<AlloyType> getTypes()
          Returns an unmodifiable list of AlloyTypes representing the relation's type.
 int hashCode()
          Computes a hash code based on the name and the list of types.
 java.util.List<AlloyType> project(java.util.Collection<java.lang.Integer> columns)
          Project this relation and return an unmodifiable list of remaining types (after removing zero or more columns)
 java.lang.String toString()
          This value is used to display this type in the Visualizer's customization screen.
 
Methods inherited from class edu.mit.csail.sdg.alloy4viz.AlloyElement
getName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EXTENDS

public static final AlloyRelation EXTENDS
This caches an instance of the "extends" AlloyRelation, so we don't have to keep re-constructing it.


IN

public static final AlloyRelation IN
This caches an instance of the "in" AlloyRelation, so we don't have to keep re-constructing it.


isPrivate

public final boolean isPrivate
Records whether this relation is known to be "private"; NOTE: this value is NOT USED during equals() comparison.


isMeta

public final boolean isMeta
Records whether this relation is known to be "meta"; NOTE: this value is NOT USED during equals() comparison.

Constructor Detail

AlloyRelation

public AlloyRelation(java.lang.String name,
                     boolean isPrivate,
                     boolean isMeta,
                     java.util.List<AlloyType> types)
Constructs a new AlloyRelation with that name and that list of types; types.size() must be 2 or above.

Method Detail

project

public java.util.List<AlloyType> project(java.util.Collection<java.lang.Integer> columns)
Project this relation and return an unmodifiable list of remaining types (after removing zero or more columns)

Parameters:
columns - - the collection of columns to remove (0 is the first column, 1 is the second column...)

getTypes

public java.util.List<AlloyType> getTypes()
Returns an unmodifiable list of AlloyTypes representing the relation's type.


getArity

public int getArity()
Returns the arity of the relation.


compareTo

public int compareTo(AlloyRelation other)
When comparing two AlloyRelation objects, we first compare the name, then the arity, then the types.
We guarantee x.equals(y) iff x.compareTo(y)==0


compareTo

public int compareTo(AlloyElement other)
When comparing two AlloyRelation objects, we first compare the name, then the arity, then the types.
We guarantee x.equals(y) iff x.compareTo(y)==0


toString

public java.lang.String toString()
This value is used to display this type in the Visualizer's customization screen.

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
Two relations are equal if they have the same name, and the same list of types.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Computes a hash code based on the name and the list of types.

Overrides:
hashCode in class java.lang.Object