Class Entity

    • Constructor Detail

      • Entity

        protected Entity​(EntityType entityType,
                         java.lang.String name)
        Creates an Entity with the given name and the creation time set to the current simulation time
        Parameters:
        entityType -
        name - The name of the entity
    • Method Detail

      • nullify

        public void nullify()
        Description copied from class: QObject
        Causes all references to objects from this QObject to be set to null and all internal objects to be set to null including State information

        Meant primarily to facilitate garbage collection. After this call, the object should not be used.

        Overrides:
        nullify in class QObject
      • getTimeEnteredReceiver

        public final double getTimeEnteredReceiver()
        Returns the time that the entity was last received by a receiver. Useful in determining the total time an entity was at a receiver
        Returns:
      • setTimeEnteredReceiver

        protected final void setTimeEnteredReceiver​(double time)
        Used to set the time that the entity last entered a receiver
        Parameters:
        time -
      • getType

        public final EntityType getType()
        Returns:
        Returns the type.
      • getProcessExecutor

        public final ProcessExecutor getProcessExecutor()
        Gets a reference to the process executor that is currently executing with the entity.
        Returns:
        A reference to the process executor.
      • setType

        protected final void setType​(EntityType entityType)
        Sets the type of the entity. Side effects: 1. ALL previously supplied attributes will be cleared, even user defined attributes. The attributes of the entity will be assigned based on the newly supplied entity type.
        Parameters:
        entityType - The type to set, must not be null
      • addAttribute

        public final void addAttribute​(java.lang.String attributeName,
                                       AttributeIfc attribute)
        Adds the named attribute to the entity as a valid attribute Arguments must be non-null, or exceptions will be thrown. The named attribute must not already have been added to the entity or an exception will be thrown.
        Parameters:
        attributeName -
        attribute -
      • containsAttribute

        public final boolean containsAttribute​(java.lang.String attributeName)
        Returns whether or not the attribute has been named for this entity
        Parameters:
        attributeName -
        Returns:
        true if already added, false otherwise
      • setAttributeValue

        public final void setAttributeValue​(java.lang.String attributeName,
                                            double value)
        Allows the user to set the value of the named attribute to the given value
        Parameters:
        attributeName - the attribute name must be present for the entity or an exception is thrown
        value -
      • getAttributeValue

        public final double getAttributeValue​(java.lang.String attributeName)
        Gets the value of the attribute using the GetValueIfc
        Parameters:
        attributeName -
        Returns:
      • setProcessExecutor

        public final void setProcessExecutor​(ProcessExecutor processExecutor)
        This is used by the ProcessExecutor to tell the entity what process executor it is currently executing within.
        Parameters:
        processExecutor - The ProcessExecutor
      • hasAllocations

        public final boolean hasAllocations()
        Checks if the entity has any allocations from resources
        Returns:
      • containsAllocation

        public final boolean containsAllocation​(Allocation a)
        Checks if the entity has the supplied allocation
        Parameters:
        a -
        Returns:
      • containsAllocation

        public final boolean containsAllocation​(Resource r)
        Checks of the entity has an allocation for the supplied resource
        Parameters:
        r -
        Returns:
      • getAllocation

        public final Allocation getAllocation​(Resource r)
        Gets the allocation for the supplied resource or null if no allocation exists
        Parameters:
        r -
        Returns:
      • setCurrentReceiver

        protected void setCurrentReceiver​(EntityReceiverAbstract receiver)
        Sets the current receiver
        Parameters:
        receiver - must not be null
      • setPlannedReceiver

        protected void setPlannedReceiver​(EntityReceiverAbstract receiver)
        Sets the current receiver
        Parameters:
        receiver - must not be null
      • release

        public final void release​(Resource resource)
        A convenience method that allows an entity to release a resource that it has previously had allocated. Releases all units of the resource that were allocated. Throws an IllegalArgumentException if the supplied resource has not be allocated to the entity
        Parameters:
        resource -
      • getMessage

        public final java.lang.Object getMessage()
        Returns:
        Returns the Message.
      • setMessage

        public final void setMessage​(java.lang.Object message)
        Parameters:
        message - The Message to set.
      • getDurationTime

        public final double getDurationTime()
        Returns the duration time. This can be used by clients to set a duration time and be used within activities, processes, time events, etc.
        Returns:
      • setDurationTime

        public final void setDurationTime​(double durationTime)
        Sets the duration time. This can be used by clients to set a duration time and be used within activities, processes, time events, etc.
        Parameters:
        durationTime -
      • getUseDurationFlag

        public final boolean getUseDurationFlag()
        This can be used by clients to indicate whether they should use getDurationTime(). By default it is false (do not use the duration time).
        Returns:
      • setUseDurationFlag

        public final void setUseDurationFlag​(boolean flag)
        This can be used by clients to indicate whether they should used getDurationTime(). By default it is false (do not use the duration time).
        Parameters:
        flag -
      • getAmount

        public final int getAmount()
        This can be used by clients to set an amount, generally used when seizing resources.
        Returns:
      • setAmount

        public final void setAmount​(int amount)
        This can be used by clients to set an amount, generally used when seizing resources.
        Parameters:
        amount - must be > 0
      • getUseAmountFlag

        public final boolean getUseAmountFlag()
        This can be used by clients to indicate whether they should used getAmount(). By default it is false (do not use the getAmount()).
        Returns:
      • setUseAmountFlag

        public final void setUseAmountFlag​(boolean flag)
        This can be used by clients to indicate whether they should used getAmount(). By default it is false (do not use the getAmount()).
        Parameters:
        flag -
      • hasReceiverSequence

        public final boolean hasReceiverSequence()
        Returns true if the entity was supplied a receiver sequence from its entity type
        Returns:
      • resetReceiverSequence

        public final boolean resetReceiverSequence()
        Resets the entity's receiver sequence to the beginning Returns true if a receiver sequence exists
        Returns:
      • peekNextEntityReceiver

        public final EntityReceiverAbstract peekNextEntityReceiver()
        Peeks at the next receiver, without advancing to the next receiver Returns null if no receiver is next
        Returns:
      • peekPreviousEntityReceiver

        public final EntityReceiverAbstract peekPreviousEntityReceiver()
        Peeks at the previous receiver, without moving to the previous Returns null if no previous receiver is available
        Returns:
      • getEntityReceiverAt

        public final EntityReceiverAbstract getEntityReceiverAt​(int index)
        Returns the EntityReceiver at the supplied index for the EntityType. Returns null if no sequence or the index is out of bounds for the sequence.
        Parameters:
        index -
        Returns:
      • nextEntityReceiverIndex

        public int nextEntityReceiverIndex()
        Returns the index of the next entity receiver in the iterator sequence.
        Specified by:
        nextEntityReceiverIndex in interface EntityReceiverIteratorIfc
        Returns:
        (-1 if no sequence iterator, size() if at end of list
      • previousEntityReceiverIndex

        public int previousEntityReceiverIndex()
        Returns the index of the next entity receiver in the iterator sequence.
        Specified by:
        previousEntityReceiverIndex in interface EntityReceiverIteratorIfc
        Returns:
        (-1 if no sequence iterator or at the beginning of the list
      • hasNextEntityReceiver

        public final boolean hasNextEntityReceiver()
        Checks if there is a next entity receiver for this entity Returns false if no next receiver
        Specified by:
        hasNextEntityReceiver in interface EntityReceiverIteratorIfc
        Returns:
        true if there is one, false otherwise
      • hasPreviousEntityReceiver

        public final boolean hasPreviousEntityReceiver()
        Checks if there is a previous entity receiver for this entity Returns false if no previous receiver
        Specified by:
        hasPreviousEntityReceiver in interface EntityReceiverIteratorIfc
        Returns:
        true if there is one, false otherwise
      • getCurrentReceiver

        public final EntityReceiverAbstract getCurrentReceiver()
        Gets the receiver that most recently received the entity This may be null if the entity has never been received
        Returns:
      • sendViaReceiver

        public final void sendViaReceiver​(EntityReceiverAbstract receiver)
        Causes the entity to be sent to the receiver. It arrives instantaneously.
        Parameters:
        receiver -
      • sendViaReceiver

        public final void sendViaReceiver​(EntityReceiverAbstract receiver,
                                          GetValueIfc time)
        Causes the entity to be sent to the receiver. It arrives after the specified amount of time
        Parameters:
        receiver -
        time -
      • sendViaReceiver

        public final void sendViaReceiver​(EntityReceiverAbstract receiver,
                                          double time)
        Causes the entity to be sent to the receiver. It arrives after the specified amount of time
        Parameters:
        receiver -
        time -
      • sendViaSequence

        public final void sendViaSequence()
        Causes the entity to be sent to the next receiver in its sequence (i.e. to nextEntityReceiver()). It arrives instantaneously.
      • sendViaSequence

        public final void sendViaSequence​(double time)
        Causes the entity to be sent to the next receiver in its sequence (i.e. to nextEntityReceiver()). It arrives after the specified amount of time
        Parameters:
        time -
      • sendViaEntityType

        public final void sendViaEntityType()
        Causes the entity to be sent to a destination (receiver) as specified by its EntityType based on its current location (receiver)
      • dispose

        public final void dispose()
        Causes the entity to be disposed. It can no longer be used. The entity must not have any outstanding requests. This can be checked by using hasAllocations(). If the entity is carrying any entities in its list, those entities will also be disposed
      • getSeizeRequirements

        public java.util.List<SeizeRequirement> getSeizeRequirements()
      • getReleaseRequirements

        public java.util.SortedSet<ReleaseRequirement> getReleaseRequirements()
      • requestFullyAllocated

        protected void requestFullyAllocated​(Request request)
        This method can be overridden to react to the request receiving its full allocation of the desired resource
        Parameters:
        request -
      • requestReleased

        protected void requestReleased​(Request request)
        This method can be overridden to react to the request releasing its associated resource
        Parameters:
        request -
      • toArray

        public <T> T[] toArray​(T[] ts)
        Specified by:
        toArray in interface java.util.Collection<Entity>
        Specified by:
        toArray in interface java.util.List<Entity>
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<Entity>
        Specified by:
        toArray in interface java.util.List<Entity>
      • subList

        public java.util.List<Entity> subList​(int i,
                                              int i1)
        Specified by:
        subList in interface java.util.List<Entity>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<Entity>
        Specified by:
        size in interface java.util.List<Entity>
      • set

        public Entity set​(int i,
                          Entity e)
        Preconditions: e must not be null, and must not already be in the group
        Specified by:
        set in interface java.util.List<Entity>
        Parameters:
        i -
        e -
        Returns:
      • retainAll

        public boolean retainAll​(java.util.Collection<?> clctn)
        Specified by:
        retainAll in interface java.util.Collection<Entity>
        Specified by:
        retainAll in interface java.util.List<Entity>
      • removeAll

        public boolean removeAll​(java.util.Collection<?> clctn)
        Specified by:
        removeAll in interface java.util.Collection<Entity>
        Specified by:
        removeAll in interface java.util.List<Entity>
      • remove

        public Entity remove​(int i)
        Specified by:
        remove in interface java.util.List<Entity>
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<Entity>
        Specified by:
        remove in interface java.util.List<Entity>
      • listIterator

        public java.util.ListIterator<Entity> listIterator​(int i)
        Specified by:
        listIterator in interface java.util.List<Entity>
      • listIterator

        public java.util.ListIterator<Entity> listIterator()
        Specified by:
        listIterator in interface java.util.List<Entity>
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object o)
        Specified by:
        lastIndexOf in interface java.util.List<Entity>
      • iterator

        public java.util.Iterator<Entity> iterator()
        Specified by:
        iterator in interface java.util.Collection<Entity>
        Specified by:
        iterator in interface java.lang.Iterable<Entity>
        Specified by:
        iterator in interface java.util.List<Entity>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<Entity>
        Specified by:
        isEmpty in interface java.util.List<Entity>
      • indexOf

        public int indexOf​(java.lang.Object o)
        Specified by:
        indexOf in interface java.util.List<Entity>
      • get

        public Entity get​(int i)
        Specified by:
        get in interface java.util.List<Entity>
      • containsAll

        public boolean containsAll​(java.util.Collection<?> clctn)
        Specified by:
        containsAll in interface java.util.Collection<Entity>
        Specified by:
        containsAll in interface java.util.List<Entity>
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<Entity>
        Specified by:
        contains in interface java.util.List<Entity>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<Entity>
        Specified by:
        clear in interface java.util.List<Entity>
      • addAll

        public boolean addAll​(int i,
                              java.util.Collection<? extends Entity> clctn)
        The collection must not have any null elements or any elements that are already part of the entity's group
        Specified by:
        addAll in interface java.util.List<Entity>
        Parameters:
        i -
        clctn -
        Returns:
      • addAll

        public boolean addAll​(java.util.Collection<? extends Entity> clctn)
        The collection must not have any null elements or any elements that are already part of the entity's group
        Specified by:
        addAll in interface java.util.Collection<Entity>
        Specified by:
        addAll in interface java.util.List<Entity>
        Parameters:
        clctn -
        Returns:
      • add

        public void add​(int i,
                        Entity e)
        Adds an entity to the entity's group Preconditions: e must not be null, e must not already be in group
        Specified by:
        add in interface java.util.List<Entity>
        Parameters:
        i -
        e -
      • add

        public boolean add​(Entity e)
        Adds an entity to the entity's group Preconditions: e must not be null, e must not already be in group
        Specified by:
        add in interface java.util.Collection<Entity>
        Specified by:
        add in interface java.util.List<Entity>
        Parameters:
        e -
        Returns: