Class ExceptionMessages<T>
java.lang.Object
io.github.astrapi69.design.pattern.observer.exception.ExceptionMessages<T>
- Type Parameters:
T
- the generic type of the additional data contained in the exception messages
The class
ExceptionMessages
manages a collection of exception messages organized by keys
It allows adding, retrieving, and removing exception messages based on specific keys-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(String key, ExceptionMessage<T> value) Adds an exception message to the collection under the specified keyvoid
Adds a map of exception messages to the existing collectionboolean
containsKey
(String key) Checks if the collection contains exception messages associated with the specified keyRetrieves the set of exception messages associated with the specified keygetKeys()
Retrieves the set of all keys used in the collectionint
getSize()
Gets the number of unique keys in the collectionboolean
isEmpty()
Checks if the collection is emptyRemoves all exception messages associated with the specified keyvoid
removeAll
(Collection<String> keys) Removes all exception messages associated with the specified collection of keys
-
Constructor Details
-
ExceptionMessages
public ExceptionMessages()
-
-
Method Details
-
add
Adds a map of exception messages to the existing collection- Parameters:
keyListMap
- the map of keys and corresponding sets of exception messages to be added
-
add
Adds an exception message to the collection under the specified key- Parameters:
key
- the key under which the exception message should be storedvalue
- the exception message to be added
-
containsKey
Checks if the collection contains exception messages associated with the specified key- Parameters:
key
- the key to be checked- Returns:
- true if the key exists in the collection, otherwise false
-
get
Retrieves the set of exception messages associated with the specified key- Parameters:
key
- the key whose associated exception messages are to be returned- Returns:
- the set of exception messages associated with the specified key, or null if no messages are found
-
getKeys
Retrieves the set of all keys used in the collection- Returns:
- the set of all keys
-
getSize
public int getSize()Gets the number of unique keys in the collection- Returns:
- the number of unique keys
-
isEmpty
public boolean isEmpty()Checks if the collection is empty- Returns:
- true if the collection contains no entries, otherwise false
-
remove
Removes all exception messages associated with the specified key- Parameters:
key
- the key whose associated exception messages are to be removed- Returns:
- the set of exception messages that were removed, or null if the key was not found
-
removeAll
Removes all exception messages associated with the specified collection of keys- Parameters:
keys
- the collection of keys whose associated exception messages are to be removed
-