Package org.faktorips.runtime
Class MessageList
- java.lang.Object
-
- org.faktorips.runtime.util.AbstractMessageList<Message,MessageList>
-
- org.faktorips.runtime.MessageList
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Iterable<Message>
public class MessageList extends AbstractMessageList<Message,MessageList> implements java.io.Serializable
A list ofMessages.- See Also:
Message, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MessageList()Creates an empty message list.MessageList(Message message)Creates a message list that contains the given message.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(MessageList messageList, ObjectProperty invalidObjectProperty, boolean override)Copies the messages from the given list to this list and sets the message's invalid object properties.booleancontainsErrorMsg()Returns true if one the messages in the list is an error message, otherwise false.static MessageListcreateCopy(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.protected MessageListcreateEmptyMessageList()Creates a new empty message list.MessagegetFirstMessage(Severity severity)Returns the first message with the given severity or null if none is found.MessageListgetMessagesByMarker(java.util.function.Predicate<IMarker> markerPredicate)Returns a new message list containing all the message in this list with aIMarkerthe specifiedPredicatematches.MessageListgetMessagesByMarker(IMarker marker)Returns a new message list containing all the message in this list that have the specifiedIMarker.MessageListgetMessagesFor(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.MessagegetMessageWithHighestSeverity()Returns the message with the highest severity.SeveritygetSeverity()Returns the message list's severity.static MessageListof(Message... messages)Returns a newMessageListthat consists of the givenMessages.static MessageListofErrors(java.lang.String... texts)Returns a newMessageListthat contains error messages with the given texts.-
Methods inherited from class org.faktorips.runtime.util.AbstractMessageList
add, add, clear, equals, getMessage, getMessageByCode, getMessages, getMessagesByCode, getMessagesFor, getMessagesFor, getNoOfMessages, getText, hashCode, isEmpty, iterator, parallelStream, setMessages, size, spliterator, stream, toString
-
-
-
-
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
-
createEmptyMessageList
protected MessageList createEmptyMessageList()
Description copied from class:AbstractMessageListCreates a new empty message list.- Specified by:
createEmptyMessageListin classAbstractMessageList<Message,MessageList>
-
of
public static final MessageList of(Message... messages)
Returns a newMessageListthat consists of the givenMessages. Returns an emptyMessageListifnullis given.- Parameters:
messages- theMessagesthat the newMessageListwill contain. May benull- Returns:
- a new
MessageListthat consist of the givenMessages
-
ofErrors
public static final MessageList ofErrors(java.lang.String... texts)
Returns a newMessageListthat contains error messages with the given texts. Returns an emptyMessageListifnullor an empty array is given.- Parameters:
texts- the texts of the error messages in the newMessageList. May benullor empty- Returns:
- a new
MessageListthat contains error messages with the given texts or an emptyMessageList
-
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 copyoldObject- 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-trueif the invalidObjectProperty should be set in all messages.falseif 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.
-
getMessageWithHighestSeverity
public Message getMessageWithHighestSeverity()
Description copied from class:AbstractMessageListReturns the message with the highest severity. If there are multiple such messages, the first one is returned. If this listAbstractMessageList.isEmpty(),nullis returned.- Specified by:
getMessageWithHighestSeverityin classAbstractMessageList<Message,MessageList>
-
getMessagesByMarker
public MessageList getMessagesByMarker(IMarker marker)
-
getMessagesByMarker
public MessageList getMessagesByMarker(java.util.function.Predicate<IMarker> markerPredicate)
Returns a new message list containing all the message in this list with aIMarkerthe specifiedPredicatematches. Returns an empty list if this list does not contain any such message.Sample usage:
messages.getMessagesByMarker(IMarker::isRequiredInformationMissing);- Parameters:
markerPredicate- to match anIMarker. Must not benull- Throws:
java.lang.NullPointerException- if markerPredicate isnull
-
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.
-
containsErrorMsg
public boolean containsErrorMsg()
Description copied from class:AbstractMessageListReturns true if one the messages in the list is an error message, otherwise false.- Specified by:
containsErrorMsgin classAbstractMessageList<Message,MessageList>
-
getMessagesFor
public MessageList getMessagesFor(java.lang.Object object, java.lang.String property, int index)
Description copied from class:AbstractMessageListReturns 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:
getMessagesForin classAbstractMessageList<Message,MessageList>
-
-