Class AbstractMessageList<M extends IMessage,​L extends AbstractMessageList<M,​L>>

  • All Implemented Interfaces:
    java.lang.Iterable<M>
    Direct Known Subclasses:
    MessageList

    public abstract class AbstractMessageList<M extends IMessage,​L extends AbstractMessageList<M,​L>>
    extends java.lang.Object
    implements java.lang.Iterable<M>
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void add​(L messageList)
      Adds the messages in the given list to this list.
      void add​(M message)
      Adds the message to the list.
      void clear()
      Removes all of the messages from this list.
      abstract boolean containsErrorMsg()
      Returns true if one the messages in the list is an error message, otherwise false.
      protected abstract L createEmptyMessageList()
      Creates a new empty message list.
      boolean equals​(java.lang.Object obj)  
      M getMessage​(int index)
      Returns the message at the indicated index (indexing starts with 0).
      M getMessageByCode​(java.lang.String code)
      Returns the first message in the list that has the specified message code.
      java.util.List<M> getMessages()
      Returns the message list.
      L getMessagesByCode​(java.lang.String code)
      Returns a new message list containing all the message in this list that have the specified message code.
      L getMessagesFor​(java.lang.Object object)
      Returns a new list with the messages in this list that belong to the given object (any property).
      L getMessagesFor​(java.lang.Object object, java.lang.String property)
      Returns a new list with the messages in this list that belong to the given object and property.
      abstract L getMessagesFor​(java.lang.Object object, java.lang.String property, int index)
      Returns a new list with the messages in this list that belong to the given object and property and the property is of the given index.
      abstract M getMessageWithHighestSeverity()
      Returns the message with the highest severity.
      int getNoOfMessages()
      Deprecated.
      Use #size() instead
      java.lang.String getText()
      Returns the text of all messages in the list, separated by the system's default line separator.
      int hashCode()  
      boolean isEmpty()
      Returns true if the list is empty.
      java.util.Iterator<M> iterator()
      Returns an iterator over the messages in this list.
      java.util.stream.Stream<M> parallelStream()
      Returns a parallel Stream of the included messages.
      void setMessages​(java.util.List<M> messages)
      Sets the message list.
      int size()
      Returns the total number of messages in the list.
      java.util.Spliterator<M> spliterator()
      Creates a Spliterator over the included messages.
      java.util.stream.Stream<M> stream()
      Returns a sequential Stream of the included messages.
      java.lang.String toString()
      Returns all messages in the list separated by a line separator.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach
    • Constructor Detail

      • AbstractMessageList

        public AbstractMessageList()
      • AbstractMessageList

        public AbstractMessageList​(M message)
        Creates a message list that contains the given message.
        Parameters:
        message - the message to add. Ignored if null.
    • Method Detail

      • add

        public void add​(M message)
        Adds the message to the list.
        Parameters:
        message - the message to add. Ignored if null.
      • add

        public void add​(L messageList)
        Adds the messages in the given list to this list.
      • isEmpty

        public boolean isEmpty()
        Returns true if the list is empty.
      • size

        public int size()
        Returns the total number of messages in the list.
      • getNoOfMessages

        @Deprecated
        public int getNoOfMessages()
        Deprecated.
        Use #size() instead
        Returns the number of messages in the list.
      • getMessage

        public M getMessage​(int index)
        Returns the message at the indicated index (indexing starts with 0).
        Throws:
        java.lang.IndexOutOfBoundsException - if the index is out of range.
      • getMessages

        public java.util.List<M> getMessages()
        Returns the message list.
      • setMessages

        public void setMessages​(java.util.List<M> messages)
        Sets the message list.
      • toString

        public java.lang.String toString()
        Returns all messages in the list separated by a line separator.
        Overrides:
        toString in class java.lang.Object
      • clear

        public void clear()
        Removes all of the messages from this list. This list will be empty after this call returns.
      • iterator

        public java.util.Iterator<M> iterator()
        Returns an iterator over the messages in this list.
        Specified by:
        iterator in interface java.lang.Iterable<M extends IMessage>
      • getMessagesFor

        public L getMessagesFor​(java.lang.Object object,
                                java.lang.String property)
        Returns a new list with the messages in this list that belong to the given object and property. Returns an empty list if no such message is found.
      • getMessagesFor

        public L getMessagesFor​(java.lang.Object object)
        Returns a new list with the messages in this list that belong to the given object (any property). Returns an empty list if no such message is found.
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getMessageByCode

        public M getMessageByCode​(java.lang.String code)
        Returns the first message in the list that has the specified message code. Returns null if the list does not contain such a message.
        Parameters:
        code - the code to look for. May be null, as messages may have null as their message code.
      • getMessagesByCode

        public L getMessagesByCode​(java.lang.String code)
        Returns a new message list containing all the message in this list that have the specified message code. Returns an empty list if this list does not contain any message with the given code.
        Parameters:
        code - the code to look for. May be null, as messages may have null as their message code.
      • getText

        public java.lang.String getText()
        Returns the text of all messages in the list, separated by the system's default line separator.
      • containsErrorMsg

        public abstract boolean containsErrorMsg()
        Returns true if one the messages in the list is an error message, otherwise false.
      • getMessageWithHighestSeverity

        public abstract M getMessageWithHighestSeverity()
        Returns the message with the highest severity. If there are multiple such messages, the first one is returned. If this list isEmpty(), null is returned.
      • getMessagesFor

        public abstract L getMessagesFor​(java.lang.Object object,
                                         java.lang.String property,
                                         int index)
        Returns a new list with the messages in this list that belong to the given object and property and the property is of the given index. Returns an empty list if no such message is found.
      • createEmptyMessageList

        protected abstract L createEmptyMessageList()
        Creates a new empty message list.
      • spliterator

        public java.util.Spliterator<M> spliterator()
        Creates a Spliterator over the included messages.
        Specified by:
        spliterator in interface java.lang.Iterable<M extends IMessage>
        Since:
        21.6
      • stream

        public java.util.stream.Stream<M> stream()
        Returns a sequential Stream of the included messages.
        Since:
        21.6
      • parallelStream

        public java.util.stream.Stream<M> parallelStream()
        Returns a parallel Stream of the included messages.
        Since:
        21.6