Class Context<TEntity extends Entity>

  • All Implemented Interfaces:
    IContext<TEntity>

    public class Context<TEntity extends Entity>
    extends java.lang.Object
    implements IContext<TEntity>
    A context manages the life-cycle of entities and groups. You can create and destroy entities and get groups of entities.
    Author:
    kong
    See Also:
    IContext
    • Constructor Detail

    • Method Detail

      • createEntity

        public TEntity createEntity()
        Description copied from interface: IContext
        Create new entity
        Specified by:
        createEntity in interface IContext<TEntity extends Entity>
        Returns:
        the entity by the corresponding entity template
      • getEntity

        public TEntity getEntity​(java.lang.String entityId)
        Description copied from interface: IContext
        Retrieves an entity by entity id
        Specified by:
        getEntity in interface IContext<TEntity extends Entity>
        Parameters:
        entityId - the entity id
        Returns:
        the corresponding entity
      • destroyEntity

        public void destroyEntity​(TEntity entity)
        Description copied from interface: IContext
        Remove this entity from the current context
        Specified by:
        destroyEntity in interface IContext<TEntity extends Entity>
        Parameters:
        entity - the corresponding entity
      • hasEntity

        public boolean hasEntity​(TEntity entity)
        Description copied from interface: IContext
        Check if the entity is existed by entity id
        Specified by:
        hasEntity in interface IContext<TEntity extends Entity>
        Parameters:
        entity - the entity
        Returns:
        true if this entity is existed in the current context, false otherwise
      • getEntities

        public java.util.Map<java.lang.String,​TEntity> getEntities()
        Description copied from interface: IContext
        Retrieves all entities of the current context
        Specified by:
        getEntities in interface IContext<TEntity extends Entity>
        Returns:
        the map of entities
      • getEntitesCount

        public int getEntitesCount()
        Description copied from interface: IContext
        Retrieves the number of entities
        Specified by:
        getEntitesCount in interface IContext<TEntity extends Entity>
        Returns:
        the entities count