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

public class ExceptionMessages<T> extends Object
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 Details

    • ExceptionMessages

      public ExceptionMessages()
  • Method Details

    • add

      public void add(Map<? extends String,? extends Set<ExceptionMessage<T>>> keyListMap)
      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

      public void add(String key, ExceptionMessage<T> value)
      Adds an exception message to the collection under the specified key
      Parameters:
      key - the key under which the exception message should be stored
      value - the exception message to be added
    • containsKey

      public boolean containsKey(String key)
      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

      public Set<ExceptionMessage<T>> get(String key)
      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

      public Set<String> 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

      public Set<ExceptionMessage<T>> remove(String key)
      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

      public void removeAll(Collection<String> keys)
      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