Package net.morimekta.providence.util
Class MessageValidation.Builder<M extends PMessage<M>,E extends java.lang.Exception>
- java.lang.Object
-
- net.morimekta.providence.util.MessageValidation.Builder<M,E>
-
- 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.ObjectBuilder vlass for message validators.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MessageValidation<M,E>build()Build the validator.MessageValidation.Builder<M,E>expect(MessageValidation.Expectation<M> expectation)Make a specific expectation for the message.MessageValidation.Builder<M,E>expect(MessageValidation.SimpleExpectation<M> expectation)Make a specific expectation for the message.<M2 extends PMessage<M2>>
MessageValidation.Builder<M,E>expectIfPresent(PField<M> field, PMessageDescriptor<M2> descriptor, 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.<V> MessageValidation.Builder<M,E>expectIfPresent(PField<M> field, 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.<V> MessageValidation.Builder<M,E>expectIfPresent(PField<M> field, 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.MessageValidation.Builder<M,E>expectMissing(PField<M>... fields)Expect field to be present on message.MessageValidation.Builder<M,E>expectNotNull()Expect the message to be non-null value.MessageValidation.Builder<M,E>expectPresent(PField<M>... fields)Expect field to be present on message.
-
-
-
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.
-
expect
@Nonnull public MessageValidation.Builder<M,E> expect(@Nonnull MessageValidation.SimpleExpectation<M> expectation)
Make a specific expectation for the message.- Parameters:
expectation- Expectation predicate.- Returns:
- The builder instance.
-
expect
@Nonnull public MessageValidation.Builder<M,E> expect(@Nonnull MessageValidation.Expectation<M> expectation)
Make a specific expectation for the message.- Parameters:
expectation- Expectation predicate.- 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.
-
-