edu.mit.csail.sdg.alloy4viz
Class AlloyProjection

java.lang.Object
  extended by edu.mit.csail.sdg.alloy4viz.AlloyProjection

public final class AlloyProjection
extends java.lang.Object

Immutable; represents a set of types to be projected, plus the exact atom chosen for each type to be projected.

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


Constructor Summary
AlloyProjection()
          Constructs an empty AlloyProjection object, with an empty projection list.
AlloyProjection(java.util.Map<AlloyType,AlloyAtom> map)
          Constructs a new AlloyProjection object based on the set of types to be projected and the exact atoms chosen.
 
Method Summary
 boolean equals(java.lang.Object other)
          AlloyProjections are equal if they are projecting over the same types, each type with the same chosen value.
 AlloyAtom getProjectedAtom(AlloyType type)
          Return the atom chosen for that type; returns null if that type is not projected.
 java.util.Collection<AlloyType> getProjectedTypes()
          Return the sorted unmodifiable collection of types we are projecting.
 int hashCode()
          Computes a hashcode based on the types and the atoms chosen for each type.
 java.lang.String toString()
          Returns a human readable dump of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AlloyProjection

public AlloyProjection(java.util.Map<AlloyType,AlloyAtom> map)
Constructs a new AlloyProjection object based on the set of types to be projected and the exact atoms chosen.

Parameters:
map - - this map describes the set of types to be projected and the exact atoms chosen to be projected

For each type t in map.keySet(),
map.get(t) is an AlloyAtom (indicating the atom in t that we chose to project over).

Note: there's no way for this class to confirm that a chosen atom is really in that type (since the atom may be in a subtype, and thus the atom.type() won't be exactly the same). Thus, classes that use AlloyProjection objects need to do their own sanity check.


AlloyProjection

public AlloyProjection()
Constructs an empty AlloyProjection object, with an empty projection list.

Method Detail

getProjectedTypes

public java.util.Collection<AlloyType> getProjectedTypes()
Return the sorted unmodifiable collection of types we are projecting.


getProjectedAtom

public AlloyAtom getProjectedAtom(AlloyType type)
Return the atom chosen for that type; returns null if that type is not projected.


toString

public java.lang.String toString()
Returns a human readable dump of this object.

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
AlloyProjections are equal if they are projecting over the same types, each type with the same chosen value.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Computes a hashcode based on the types and the atoms chosen for each type.

Overrides:
hashCode in class java.lang.Object