Package notification
Class CommunicationAccess
java.lang.Object
notification.CommunicationAccess
* This class provides centralized access to communication strategies
based on different transmission modes.
It ensures that only one instance of each communication mode exists at a time.
The class follows the Singleton-like pattern by preventing instantiation
and offering static methods to manage communication strategies.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static Map<String,CommunicationStrategy> It store all the mode Object created organised by their name so it exists only one at a time -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateA private no-argument constructor is used to prevent any instance creation of this class. -
Method Summary
Modifier and TypeMethodDescriptionstatic CommunicationStrategyThis method returns the instance that enables access according to the given mode parameter.static voidsetCom(String mode, CommunicationStrategy comObj) Allows the server to store in the Map the object responsible for communication for the desired mode.
-
Field Details
-
strategies
It store all the mode Object created organised by their name so it exists only one at a time
-
-
Constructor Details
-
CommunicationAccess
private CommunicationAccess()A private no-argument constructor is used to prevent any instance creation of this class.
-
-
Method Details
-
setCom
Allows the server to store in the Map the object responsible for communication for the desired mode. If the object does not yet exist, the pair is added; otherwise, the new pair replaces the existing one.- Parameters:
mode- : The mode of communicationcomObj- : The object responsible for communication
-
getCom
This method returns the instance that enables access according to the given mode parameter. This instance is the one stored in the Map.- Parameters:
mode- : The mode of communication- Returns:
- The object in charge of communication. If no instance is present for this mode, null is returned.
-