Package model

Class MemoryObject

java.lang.Object
model.MemoryObject
All Implemented Interfaces:
Comparable<MemoryObject>, IMemoryObject

public class MemoryObject extends Object implements IMemoryObject, Comparable<MemoryObject>
The MemoryObject class represents a memory object that has a unique id, a type id and can be active or inactive. It implements the IMemoryObject interface and the Comparable interface to compare objects by their type id.
  • Field Details

  • Constructor Details

    • MemoryObject

      public MemoryObject(Integer id, Integer typeId)
      Constructs a MemoryObject with a given id and type id. The object is initialized as inactive.
      Parameters:
      id - the unique identifier of the object
      typeId - the type identifier of the object
  • Method Details

    • getIdNumber

      public Integer getIdNumber()
      Returns the id of the memory object.
      Specified by:
      getIdNumber in interface IMemoryObject
      Returns:
      the id of the memory object
    • getTypeId

      public Integer getTypeId()
      Returns the type id of the memory object.
      Specified by:
      getTypeId in interface IMemoryObject
      Returns:
      the type id of the memory object
    • setActive

      public void setActive()
      Toggles the active state of the memory object.
      Specified by:
      setActive in interface IMemoryObject
    • isActive

      public Boolean isActive()
      Returns whether the memory object is currently active or not.
      Specified by:
      isActive in interface IMemoryObject
      Returns:
      true if the object is active, false otherwise
    • setId

      public void setId(int id)
      Sets the id of the memory object.
      Specified by:
      setId in interface IMemoryObject
      Parameters:
      id - the new id of the memory object
    • compareTo

      public int compareTo(MemoryObject o)
      Compares the memory object to another object by their type ids.
      Specified by:
      compareTo in interface Comparable<MemoryObject>
      Parameters:
      o - the memory object to compare to
      Returns:
      -1 if this object has a lower type id, 0 if they have the same type id, and 1 if this object has a higher type id