Class MessageValidator.Builder<M extends PMessage<M>,​E extends java.lang.Exception>

  • Type Parameters:
    M - Message type.
    E - Exception type.
    Enclosing class:
    MessageValidator<M extends PMessage<M>,​E extends java.lang.Exception>

    public static class MessageValidator.Builder<M extends PMessage<M>,​E extends java.lang.Exception>
    extends java.lang.Object
    Builder vlass for message validators.
    • Method Detail

      • build

        @Nonnull
        public MessageValidator<M,​E> build()
        Build the validator.
        Returns:
        The validator instance.
      • expect

        @Nonnull
        public MessageValidator.Builder<M,​E> expect​(@Nonnull
                                                          java.lang.String text,
                                                          @Nonnull
                                                          java.util.function.Predicate<M> predicate)
        Make a specific expectation for the message.
        Parameters:
        text - The message text on expectation failure.
        predicate - Expectation predicate.
        Returns:
        The builder instance.
      • expect

        @Nonnull
        public <M2 extends PMessage<M2>> MessageValidator.Builder<M,​E> expect​(@Nonnull
                                                                                    PField<M> field,
                                                                                    @Nonnull
                                                                                    PMessageDescriptor<M2> descriptor,
                                                                                    @Nonnull
                                                                                    java.util.function.Consumer<MessageValidator.Builder<M2,​E>> builderConsumer)
        Given the field and type descriptor (which must match the field type), build an inner validator to check the value of the field.
        Type Parameters:
        M2 - The inner message type.
        Parameters:
        field - The field to check.
        descriptor - The message descriptor matching the field.
        builderConsumer - Consumer to configure the inner validator.
        Returns:
        The builder instance.
      • expectNotNull

        @Nonnull
        public MessageValidator.Builder<M,​E> expectNotNull()
        Expect the message to be non-null value.
        Returns:
        The builder instance.
      • expectNotNull

        @Nonnull
        public MessageValidator.Builder<M,​E> expectNotNull​(@Nonnull
                                                                 java.lang.String text)
        Expect the message to be non-null value.
        Parameters:
        text - The failure message on null value.
        Returns:
        The builder instance.
      • expectPresent

        @Nonnull
        @SafeVarargs
        public final MessageValidator.Builder<M,​E> expectPresent​(@Nonnull
                                                                       PField<M>... fields)
        Expect field to be present on message.
        Parameters:
        fields - The fields to be present.
        Returns:
        The builder instance.
      • expectPresent

        @Nonnull
        public MessageValidator.Builder<M,​E> expectPresent​(@Nonnull
                                                                 java.lang.String text,
                                                                 @Nonnull
                                                                 PField<M> field)
        Expect field to be present on message.
        Parameters:
        text - The failure message on missing field.
        field - The field to be present.
        Returns:
        The builder instance.
      • expectMissing

        @Nonnull
        @SafeVarargs
        public final MessageValidator.Builder<M,​E> expectMissing​(@Nonnull
                                                                       PField<M>... fields)
        Expect field to be present on message.
        Parameters:
        fields - The fields to be present.
        Returns:
        The builder instance.
      • expectMissing

        @Nonnull
        public MessageValidator.Builder<M,​E> expectMissing​(@Nonnull
                                                                 java.lang.String text,
                                                                 @Nonnull
                                                                 PField<M> field)
        Expect field to be present on message.
        Parameters:
        text - The failure message on present field.
        field - The field to be present.
        Returns:
        The builder instance.