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

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

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

      • build

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

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

        @Nonnull
        @SafeVarargs
        public final MessageValidation.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.
      • expectMissing

        @Nonnull
        @SafeVarargs
        public final MessageValidation.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.
      • expectIfPresent

        @Nonnull
        public <V> MessageValidation.Builder<M,​E> expectIfPresent​(@Nonnull
                                                                        PField<M> field,
                                                                        @Nonnull
                                                                        MessageValidation.SimpleExpectation<V> valueExpectation)
        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:
        V - The inner message type.
        Parameters:
        field - The field to check.
        valueExpectation - Expectation of field value.
        Returns:
        The builder instance.
      • expectIfPresent

        @Nonnull
        public <V> MessageValidation.Builder<M,​E> expectIfPresent​(@Nonnull
                                                                        PField<M> field,
                                                                        @Nonnull
                                                                        MessageValidation.Expectation<V> valueExpectation)
        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:
        V - The inner message type.
        Parameters:
        field - The field to check.
        valueExpectation - Expectation of field value.
        Returns:
        The builder instance.
      • expectIfPresent

        @Nonnull
        public <M2 extends PMessage<M2>> MessageValidation.Builder<M,​E> expectIfPresent​(@Nonnull
                                                                                              PField<M> field,
                                                                                              @Nonnull
                                                                                              PMessageDescriptor<M2> descriptor,
                                                                                              @Nonnull
                                                                                              java.util.function.Consumer<MessageValidation.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.