Package org.faktorips.runtime.util
Class AbstractMessageList<M extends IMessage,L extends AbstractMessageList<M,L>>
- java.lang.Object
-
- org.faktorips.runtime.util.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>
-
-
Constructor Summary
Constructors Constructor Description AbstractMessageList()AbstractMessageList(M message)Creates a message list that contains the given message.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadd(L messageList)Adds the messages in the given list to this list.voidadd(M message)Adds the message to the list.voidclear()Removes all of the messages from this list.abstract booleancontainsErrorMsg()Returns true if one the messages in the list is an error message, otherwise false.protected abstract LcreateEmptyMessageList()Creates a new empty message list.booleanequals(java.lang.Object obj)MgetMessage(int index)Returns the message at the indicated index (indexing starts with 0).MgetMessageByCode(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.LgetMessagesByCode(java.lang.String code)Returns a new message list containing all the message in this list that have the specified message code.LgetMessagesFor(java.lang.Object object)Returns a new list with the messages in this list that belong to the given object (any property).LgetMessagesFor(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 LgetMessagesFor(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 MgetMessageWithHighestSeverity()Returns the message with the highest severity.intgetNoOfMessages()Deprecated.Use #size() insteadjava.lang.StringgetText()Returns the text of all messages in the list, separated by the system's default line separator.inthashCode()booleanisEmpty()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 parallelStreamof the included messages.voidsetMessages(java.util.List<M> messages)Sets the message list.intsize()Returns the total number of messages in the list.java.util.Spliterator<M>spliterator()Creates aSpliteratorover the included messages.java.util.stream.Stream<M>stream()Returns a sequentialStreamof the included messages.java.lang.StringtoString()Returns all messages in the list separated by a line separator.
-
-
-
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 ifnull.
-
-
Method Detail
-
add
public void add(M message)
Adds the message to the list.- Parameters:
message- the message to add. Ignored ifnull.
-
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() insteadReturns 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:
toStringin classjava.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.
-
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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getMessageByCode
public M getMessageByCode(java.lang.String code)
Returns the first message in the list that has the specified message code. Returnsnullif the list does not contain such a message.- Parameters:
code- the code to look for. May benull, as messages may havenullas 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 benull, as messages may havenullas 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 listisEmpty(),nullis 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 aSpliteratorover the included messages.
-
stream
public java.util.stream.Stream<M> stream()
Returns a sequentialStreamof the included messages.- Since:
- 21.6
-
parallelStream
public java.util.stream.Stream<M> parallelStream()
Returns a parallelStreamof the included messages.- Since:
- 21.6
-
-