PieceProjection - PendulumProject2020/PendulumProject GitHub Wiki
Version: 0.1.9+
public class PieceProjection
This class belongs to the main
package.
This class belongs to the Methodological layer.
A PieceProjection instance is a "projection", or "drawing", of a Piece subclass. What a PieceProjection instance is to a Piece subclass is what the word "apple" written on a piece of paper is to the concept of an apple. While the Piece class is the central aspect of the Piece-Slot model, it cannot implement the piece-to-slot assembly process on its own. An attempt to implement this without the PieceProjection class would involve setting slots and occupants as static fields. However, the static fields of Piece subclasses are meant for aspects on the metaphysical/tangible layer, rather than for aspects on the methodological layer. That is, they are the contents of a book, not the shape/dimensions of the book.
A PieceProjection instance serves the purpose of encapsulating a Piece subclass and materializing slots and occupants in the form of instance variables. It is the primary target of operations for the PieceTreeCompiler class. During Piece Tree assembly, the PieceTreeCompiler will first materialize each Piece subclass into a PieceProjection instance, and then perform the assembly using the PieceProjection instances.
The Piece subclass itself only specifies the slots that the body can fit to, as well as the slots that it has. The PieceProjection will, during Piece assembly, decide what slot it actually occupies, as well as which pieces occupy its slots.
private Class<Piece> origin
The Piece subclass that this PieceProjection encapsulates.
private PieceProjection hostPiece
The projection of the Piece subclass whose slot this Piece subclass occupies.
private String hostSlot
The name of the slot that this Piece subclass occupies.
private Map<String, Integer> freeObjectSlots
The collection of object piece slots that has not been occupied, alongside the number of unoccupied object piece slots of each type (name).
private Map<String, Integer> freeMethodSlots
The collection of method piece slots that has not been occupied, alongside the number of unoccupied method piece slots of each type (name).
private Map<String, ArrayList<PieceProjection> > occupiedObjectSlots
The collection of occupied object piece slots, alongside the occupant(s).
private Map<String, ArrayList<PieceProjection> > occupiedMethodSlots
The collection of occupied method piece slots, alongside the occupant(s).
private ArrayList<PieceProjection> objectMegaSlot
The collection of Piece subclasses occupying the object mega-slot.
private ArrayList<PieceProjection> methodMegaSlot
The collection of Piece subclasses occupying the method mega-slot.
private ArrayList<SlotPath> possibleFits
The paths of slots that the encapsulated Piece subclass can fit to, as specified by the corresponding static method in the Piece subclass.
private ArrayList<String> dependentPieceNames
The names of the Piece subclasses that the encapsulated Piece subclass is dependent on (i.e. makes direct references to), as specified by the corresponding static method in the Piece subclass.
public PieceProjection(Class<Piece> origin)
Creates a PieceProjection encapsulating origin. Also initializes the fields freeObjectSlots, freeMethodSlots, possibleFits, and dependentPieceNames according to the static methods of origin.
public boolean areAllObjectSlotsFilled()
Returns true if every entry of the field freeObjectSlots has value zero, and false otherwise.
public boolean areAllMethodSlotsFilled()
Returns true if every entry of the field freeMethodSlots has value zero, and false otherwise.
public boolean attemptToHost(String slotNameSimple, PieceProjection pieceProjection)
Checks that this object has the necessary conditions to host pieceProjection, as well as that pieceProjection has the necessary conditions to fit to the slot of name slotNameSimple of this object. If either is not satisfied, the method returns false. If both are satisfied, the method returns true, and modifies the fields involving free slots and occupied slots.
private void addAnOccupiedObjectSlot(String slotNameSimple, PieceProjection pieceProjection)
If the field occupiedObjectSlots has the key slotNameSimple, adds pieceProjection to the value of the entry. If not, creates an entry in occupiedObjectSlots with slotNameSimple as key and a singleton containing pieceProjection as the value.
private void addAnOccupiedMethodSlot(String slotNameSimple, PieceProjection pieceProjection)
If the field occupiedMethodSlots has the key slotNameSimple, adds pieceProjection to the value of the entry. If not, creates an entry in occupiedMethodSlots with slotNameSimple as key and a singleton containing pieceProjection as the value.
public boolean checkFitOf(String slotNameSimple, PieceProjection pieceProjection)
Checks whether this object has the necessary conditions to host pieceProjection.
public SlotPath traceSlotPath()
If this PieceProjection is on the Piece Tree and connected to the projection of the root Piece, returns the path of its host slot. If not, returns null.
public SlotPath traceSlotPathOnThis(String simpleSlotName)
If this PieceProjection is on the Piece Tree and connected to the projection of the root Piece, returns the path of the slot named simpleSlotName. If not, returns null.
public boolean checkFitTo(SlotPath slotPath)
Checks whether this object has the necessary conditions to fit to the slot as specified by slotPath.
public boolean attemptToHostInMegaSlot(PieceProjection pieceProjection)
Checks that pieceProjection has the necessary conditions to fit to the mega-slot of this object. If the condition is satisfied, return true and add pieceProjection to the field involving the mega-slot. If not, return false.
public boolean checkFitToMegaSlot(PieceProjection megaSlotHost)
Checks whether this object has the necessary conditions to fit to the mega-slot of megaSlotHost.
public Class<Piece> getOrigin()
public void setOrigin(Class<Piece> origin)
public PieceProjection getHostPiece()
public void setHostPiece(PieceProjection hostPiece)
public String getHostSlot()
public void setHostSlot(String hostSlot)
public Map<String, Integer> getFreeObjectSlots()
public void setFreeObjectSlots(Map<String, Integer> freeObjectSlots)
public Map<String, Integer> getFreeMethodSlots()
public void setFreeMethodSlots(Map<String, Integer> freeMethodSlots)
public Map<String, ArrayList<PieceProjection> > getOccupiedObjectSlots()
public void setOccupiedObjectSlots(Map<String, ArrayList<PieceProjection> > occupiedObjectSlots)
public Map<String, ArrayList<PieceProjection> > getOccupiedMethodSlots()
public void setOccupiedMethodSlots(Map<String, ArrayList<PieceProjection> > occupiedMethodSlots)
public ArrayList<PieceProjection> getObjectMegaSlot()
public void setObjectMegaSlot(ArrayList<PieceProjection> objectMegaSlot)
public ArrayList<PieceProjection> getMethodMegaSlot()
public void setMethodMegaSlot(ArrayList<PieceProjection> methodMegaSlot)
public ArrayList<SlotPath> getPossibleFits()
public void setPossibleFits(ArrayList<SlotPath> possibleFits)
public ArrayList<String> getDependentPieceNames()
public void setDependentPieceNames(ArrayList<String> dependentPieceNames)