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:
    Any, Empty, 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 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:
        asString in interface net.morimekta.util.Stringable
        Returns:
        String representation.