edu.mit.csail.sdg.alloy4viz
Class AlloyInstance

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

public final class AlloyInstance
extends java.lang.Object

Immutable; represents an Alloy instance that can be displayed in the visualizer.

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


Field Summary
 java.lang.String commandname
          The original command that generated this instance; can be "" if unknown.
 java.lang.String filename
          The original filename of the model that generated this instance; can be "" if unknown.
 boolean isMetamodel
          If true, it is a metamodel, else it is not a metamodel.
 AlloyModel model
          The AlloyModel that this AlloyInstance is an instance of.
 
Constructor Summary
AlloyInstance(A4Solution originalA4, java.lang.String filename, java.lang.String commandname, AlloyModel model, java.util.Map<AlloyAtom,java.util.Set<AlloySet>> atom2sets, java.util.Map<AlloyRelation,java.util.Set<AlloyTuple>> rel2tuples, boolean isMetamodel)
          Create a new instance.
 
Method Summary
 java.util.List<AlloySet> atom2sets(AlloyAtom atom)
          Returns an unmodifiable sorted list of AlloySet(s) that this atom is in; answer can be an empty list.
 boolean equals(java.lang.Object other)
          Two instances are equal if they have the same filename, same commands, same model, and same atoms and tuples relationships.
 java.util.Set<AlloyAtom> getAllAtoms()
          Returns an unmodifiable sorted set of all AlloyAtoms in this AlloyInstance.
 int hashCode()
          Computes a hash code based on the same information used in equals().
 java.util.Set<AlloyTuple> relation2tuples(AlloyRelation rel)
          Returns an unmodifiable sorted set of AlloyTuple(s) in this relation; answer can be an empty set.
 java.util.List<AlloyAtom> set2atoms(AlloySet set)
          Returns an unmodifiable sorted list of AlloyAtom(s) in this set; answer can be an empty list.
 java.lang.String toString()
          Returns a textual dump of the instance.
 java.util.List<AlloyAtom> type2atoms(AlloyType type)
          Returns an unmodifiable sorted list of AlloyAtom(s) in this type; answer can be an empty list.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

isMetamodel

public final boolean isMetamodel
If true, it is a metamodel, else it is not a metamodel.


filename

public final java.lang.String filename
The original filename of the model that generated this instance; can be "" if unknown.


commandname

public final java.lang.String commandname
The original command that generated this instance; can be "" if unknown.


model

public final AlloyModel model
The AlloyModel that this AlloyInstance is an instance of.

Constructor Detail

AlloyInstance

public AlloyInstance(A4Solution originalA4,
                     java.lang.String filename,
                     java.lang.String commandname,
                     AlloyModel model,
                     java.util.Map<AlloyAtom,java.util.Set<AlloySet>> atom2sets,
                     java.util.Map<AlloyRelation,java.util.Set<AlloyTuple>> rel2tuples,
                     boolean isMetamodel)
Create a new instance.

Parameters:
filename - - the original filename of the model that generated this instance; can be "" if unknown
commandname - - the original command that generated this instance; can be "" if unknown
model - - the AlloyModel that this AlloyInstance is an instance of
atom2sets - - maps each atom to the set(s) it is in; its KeySet is considered the universe of all atoms
rel2tuples - - maps each relation to the tuple(s) it is in

(The constructor will ignore any atoms, sets, types, and relations not in the model. So there's no need to explicitly filter them out prior to passing "atom2sets" and "rel2tuples" to the constructor.)

Method Detail

getAllAtoms

public java.util.Set<AlloyAtom> getAllAtoms()
Returns an unmodifiable sorted set of all AlloyAtoms in this AlloyInstance.


atom2sets

public java.util.List<AlloySet> atom2sets(AlloyAtom atom)
Returns an unmodifiable sorted list of AlloySet(s) that this atom is in; answer can be an empty list.


type2atoms

public java.util.List<AlloyAtom> type2atoms(AlloyType type)
Returns an unmodifiable sorted list of AlloyAtom(s) in this type; answer can be an empty list.


set2atoms

public java.util.List<AlloyAtom> set2atoms(AlloySet set)
Returns an unmodifiable sorted list of AlloyAtom(s) in this set; answer can be an empty list.


relation2tuples

public java.util.Set<AlloyTuple> relation2tuples(AlloyRelation rel)
Returns an unmodifiable sorted set of AlloyTuple(s) in this relation; answer can be an empty set.


equals

public boolean equals(java.lang.Object other)
Two instances are equal if they have the same filename, same commands, same model, and same atoms and tuples relationships.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Computes a hash code based on the same information used in equals().

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Returns a textual dump of the instance.

Overrides:
toString in class java.lang.Object