Package model
Class MemoryObject
java.lang.Object
model.MemoryObject
- All Implemented Interfaces:
Comparable<MemoryObject>,IMemoryObject
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMemoryObject(Integer id, Integer typeId) Constructs a MemoryObject with a given id and type id. -
Method Summary
Modifier and TypeMethodDescriptionintCompares the memory object to another object by their type ids.Returns the id of the memory object.Returns the type id of the memory object.isActive()Returns whether the memory object is currently active or not.voidToggles the active state of the memory object.voidsetId(int id) Sets the id of the memory object.
-
Field Details
-
id
-
typeId
-
active
-
-
Constructor Details
-
MemoryObject
Constructs a MemoryObject with a given id and type id. The object is initialized as inactive.- Parameters:
id- the unique identifier of the objecttypeId- the type identifier of the object
-
-
Method Details
-
getIdNumber
Returns the id of the memory object.- Specified by:
getIdNumberin interfaceIMemoryObject- Returns:
- the id of the memory object
-
getTypeId
Returns the type id of the memory object.- Specified by:
getTypeIdin interfaceIMemoryObject- Returns:
- the type id of the memory object
-
setActive
public void setActive()Toggles the active state of the memory object.- Specified by:
setActivein interfaceIMemoryObject
-
isActive
Returns whether the memory object is currently active or not.- Specified by:
isActivein interfaceIMemoryObject- Returns:
- true if the object is active, false otherwise
-
setId
public void setId(int id) Sets the id of the memory object.- Specified by:
setIdin interfaceIMemoryObject- Parameters:
id- the new id of the memory object
-
compareTo
Compares the memory object to another object by their type ids.- Specified by:
compareToin interfaceComparable<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
-