Package net.morimekta.providence
Interface PMessage<Message extends PMessage<Message,Field>,Field extends PField>
-
- All Superinterfaces:
java.lang.Comparable<Message>,PValue<Message>,net.morimekta.util.Stringable
- All Known Subinterfaces:
PUnion<Union,Field>
- All Known Implementing Classes:
PApplicationException
public interface PMessage<Message extends PMessage<Message,Field>,Field extends PField> extends PValue<Message>, net.morimekta.util.Stringable
Base class for all messages.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.lang.StringasString()Pure string representation of content.PMessageDescriptor<Message,Field>descriptor()<T> Tget(int key)default <T> Tget(Field field)booleanhas(int key)default booleanhas(Field field)default MessagemergeWith(Message other)Shorthand for merging two messages.PMessageBuilder<Message,Field>mutate()Get a builder that extends the current object.
-
-
-
Method Detail
-
has
boolean has(int key)
- Parameters:
key- The key of the field.- Returns:
- Whether the field is present.
-
has
default boolean has(@Nonnull Field field)- Parameters:
field- The field.- Returns:
- Whether the field is present.
-
get
<T> T get(int key)
- Type Parameters:
T- The return type.- Parameters:
key- The key of the field.- Returns:
- The value of the field.
-
get
default <T> T get(@Nonnull Field field)- Type Parameters:
T- The return type.- Parameters:
field- The field.- Returns:
- Whether the field is present.
-
mutate
@Nonnull PMessageBuilder<Message,Field> mutate()
Get a builder that extends the current object.- Returns:
- The builder instance.
-
mergeWith
@Nonnull default Message mergeWith(Message other)
Shorthand for merging two messages.- Parameters:
other- The message to merge over this messages' values.- Returns:
- The merged message.
-
asString
@Nonnull java.lang.String asString()
Pure string representation of content. Does not contain type info.- Specified by:
asStringin interfacenet.morimekta.util.Stringable- Returns:
- String representation.
-
descriptor
@Nonnull PMessageDescriptor<Message,Field> descriptor()
-
-