Class MessageList

    • Constructor Detail

      • MessageList

        public MessageList()
        Creates an empty message list.
      • MessageList

        public MessageList​(Message message)
        Creates a message list that contains the given message.
        Throws:
        java.lang.NullPointerException - if message is null.
    • Method Detail

      • of

        public static final MessageList of​(Message... messages)
        Returns a new MessageList that consists of the given Messages. Returns an empty MessageList if null is given.
        Parameters:
        messages - the Messages that the new MessageList will contain. May be null
        Returns:
        a new MessageList that consist of the given Messages
      • ofErrors

        public static final MessageList ofErrors​(java.lang.String... texts)
        Returns a new MessageList that contains error messages with the given texts. Returns an empty MessageList if null or an empty array is given.
        Parameters:
        texts - the texts of the error messages in the new MessageList. May be null or empty
        Returns:
        a new MessageList that contains error messages with the given texts or an empty MessageList
      • createCopy

        public static final MessageList createCopy​(MessageList list,
                                                   java.lang.Object oldObject,
                                                   java.lang.Object newObject)
        Creates a copy from the message list and replaces all references to the old object with the new object.
        Parameters:
        list - the list to copy
        oldObject - the old object reference that should be replaced.
        newObject - the object reference to set
      • add

        public void add​(MessageList messageList,
                        ObjectProperty invalidObjectProperty,
                        boolean override)
        Copies the messages from the given list to this list and sets the message's invalid object properties.
        Parameters:
        messageList - the list to copy the messages from.
        invalidObjectProperty - the object and it's property that the messages refer to.
        override - true if the invalidObjectProperty should be set in all messages. false if the invalidObjectProperty is set only for messages that do not contain any invalid object property information.
      • getFirstMessage

        public Message getFirstMessage​(Severity severity)
        Returns the first message with the given severity or null if none is found.
      • getMessagesByMarker

        public MessageList getMessagesByMarker​(IMarker marker)
        Returns a new message list containing all the message in this list that have the specified IMarker. Returns an empty list if this list does not contain any message with the given IMarker.
        Parameters:
        marker - the IMarker to look for. If null, all messages without a IMarker are returned.
      • getMessagesByMarker

        public MessageList getMessagesByMarker​(java.util.function.Predicate<IMarker> markerPredicate)
        Returns a new message list containing all the message in this list with a IMarker the specified Predicate matches. Returns an empty list if this list does not contain any such message.

        Sample usage: messages.getMessagesByMarker(IMarker::isRequiredInformationMissing);

        Parameters:
        markerPredicate - to match an IMarker. Must not be null
        Throws:
        java.lang.NullPointerException - if markerPredicate is null
      • getSeverity

        public Severity getSeverity()
        Returns the message list's severity. This is the maximum severity of the list's messages. If the list does not contain any messages, the method returns 0.
      • getMessagesFor

        public MessageList getMessagesFor​(java.lang.Object object,
                                          java.lang.String property,
                                          int index)
        Description copied from class: AbstractMessageList
        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.
        Specified by:
        getMessagesFor in class AbstractMessageList<Message,​MessageList>