Package model.estrutura
Class Router
java.lang.Object
model.estrutura.Router
Represents a router that manages multiple protocols and their associated data
queues.
The router provides functionality to add data to specific protocols and read
data
from protocol queues following FIFO principles.
This class acts as a facade that coordinates between the protocol management system and the data storage mechanism.
- Since:
- 2024
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
newProtocolList
ProtocolList newProtocolList
-
-
Constructor Details
-
Router
public Router()Constructs a new Router with an empty protocol list. Initializes the internal protocol management system.
-
-
Method Details
-
addData
Adds data to the specified protocol type. If the protocol doesn't exist, it will be created automatically. The data is written to the protocol's FIFO data queue.- Parameters:
type
- the protocol type to which the data should be addeddata
- the data to be added to the protocol's queue
-
readData
Reads and removes data from the specified protocol's queue. If the protocol's queue becomes empty after reading, the protocol is automatically removed from the system.- Parameters:
type
- the protocol type from which to read data- Returns:
- the data read from the protocol's queue, or a message indicating the protocol was removed if the queue is empty
- Throws:
IllegalArgumentException
- if no protocols exist in the system or if the specified protocol doesn't exist
-