Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/main/java/io/skelp/verifier/AbstractCustomVerifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public V equalTo(final Object other, final Object name) {
final T value = verification.getValue();
final boolean result = isEqualTo(value, other);

verification.check(result, MessageKeys.EQUAL_TO, name);
verification.report(result, MessageKeys.EQUAL_TO, name);

return chain();
}
Expand All @@ -202,7 +202,7 @@ public V equalToAny(final Object... others) {
final T value = verification.getValue();
final boolean result = matchAny(others, input -> isEqualTo(value, input));

verification.check(result, MessageKeys.EQUAL_TO_ANY, (Object) others);
verification.report(result, MessageKeys.EQUAL_TO_ANY, (Object) others);

return chain();
}
Expand All @@ -212,7 +212,7 @@ public V hashedAs(final int hashCode) {
final T value = verification.getValue();
final boolean result = value != null && value.hashCode() == hashCode;

verification.check(result, MessageKeys.HASHED_AS, hashCode);
verification.report(result, MessageKeys.HASHED_AS, hashCode);

return chain();
}
Expand All @@ -221,7 +221,7 @@ public V hashedAs(final int hashCode) {
public V instanceOf(final Class<?> cls) {
final boolean result = cls != null && cls.isInstance(verification.getValue());

verification.check(result, MessageKeys.INSTANCE_OF, cls);
verification.report(result, MessageKeys.INSTANCE_OF, cls);

return chain();
}
Expand All @@ -231,7 +231,7 @@ public V instanceOfAll(final Class<?>... classes) {
final T value = verification.getValue();
final boolean result = value != null && matchAll(classes, input -> input != null && input.isInstance(value));

verification.check(result, MessageKeys.INSTANCE_OF_ALL, (Object) classes);
verification.report(result, MessageKeys.INSTANCE_OF_ALL, (Object) classes);

return chain();
}
Expand All @@ -241,7 +241,7 @@ public V instanceOfAny(final Class<?>... classes) {
final T value = verification.getValue();
final boolean result = value != null && matchAny(classes, input -> input != null && input.isInstance(value));

verification.check(result, MessageKeys.INSTANCE_OF_ANY, (Object) classes);
verification.report(result, MessageKeys.INSTANCE_OF_ANY, (Object) classes);

return chain();
}
Expand Down Expand Up @@ -276,7 +276,7 @@ public V not() {
public V nulled() {
final boolean result = verification.getValue() == null;

verification.check(result, MessageKeys.NULLED);
verification.report(result, MessageKeys.NULLED);

return chain();
}
Expand All @@ -290,7 +290,7 @@ public V sameAs(final Object other) {
public V sameAs(final Object other, final Object name) {
final boolean result = verification.getValue() == other;

verification.check(result, MessageKeys.SAME_AS, name);
verification.report(result, MessageKeys.SAME_AS, name);

return chain();
}
Expand All @@ -300,7 +300,7 @@ public V sameAsAny(final Object... others) {
final T value = verification.getValue();
final boolean result = matchAny(others, input -> value == input);

verification.check(result, MessageKeys.SAME_AS_ANY, (Object) others);
verification.report(result, MessageKeys.SAME_AS_ANY, (Object) others);

return chain();
}
Expand All @@ -317,7 +317,7 @@ public V that(final VerifierAssertion<T> assertion, final MessageKey key, final

final boolean result = assertion.verify(verification.getValue());

verification.check(result, key, args);
verification.report(result, key, args);

return chain();
}
Expand All @@ -329,7 +329,7 @@ public V that(final VerifierAssertion<T> assertion, final String message, final

final boolean result = assertion.verify(verification.getValue());

verification.check(result, message, args);
verification.report(result, message, args);

return chain();
}
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/io/skelp/verifier/CustomVerifierProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
* Provides {@link CustomVerifier} instances to be used to verify custom data types based on their class and the current
* {@link Verification}.
* </p>
* <p>
* {@code CustomVerifierProviders} are registered via Java's SPI, so in order to register a custom
* {@code CustomVerifierProvider} projects should contain should create a
* {@code io.skelp.verifier.CustomVerifierProvider} file within {@code META-INF/services} listing the class reference
* for each custom {@code CustomVerifierProvider} (e.g. {@code com.example.verifier.MyCustomCustomVerifierProvider}) on
* separate lines. {@code CustomVerifierProviders} are also {@link Weighted}, which means that they are loaded in
* priority order (the lower the weight, the higher the priority). Verifier has a built-in default
* {@code CustomVerifierProvider} which is given a low priority (i.e. {@value #DEFAULT_IMPLEMENTATION_WEIGHT}) to allow
* custom implementations to be easily ordered around it.
* </p>
*
* @author Alasdair Mercer
* @since 0.2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public Formatter getFormatter(final Object obj) {
}

@Override
public String getMessage(final Verification<?> verification, final MessageKey key, final Object... args) {
public String getMessage(final Verification<?> verification, final MessageKey key, final Object[] args) {
final String formattedMessage = getMessageInternal(key, args, verification);
if (formattedMessage != null) {
return buildMessage(formattedMessage, verification);
Expand All @@ -305,7 +305,7 @@ public String getMessage(final Verification<?> verification, final MessageKey ke
}

@Override
public String getMessage(final Verification<?> verification, final String message, final Object... args) {
public String getMessage(final Verification<?> verification, final String message, final Object[] args) {
final String formattedMessage = getMessageInternal(message, args, verification);
if (formattedMessage != null) {
return buildMessage(formattedMessage, verification);
Expand All @@ -317,7 +317,7 @@ public String getMessage(final Verification<?> verification, final String messag

/**
* <p>
* Called internally by {@link #getMessage(Verification, MessageKey, Object...)} to handle the actual logic of
* Called internally by {@link #getMessage(Verification, MessageKey, Object[])} to handle the actual logic of
* looking up a message based on the specified {@code key} and potentially formatting it using the optional format
* {@code args} provided.
* </p>
Expand All @@ -342,7 +342,7 @@ public String getMessage(final Verification<?> verification, final String messag
* @throws IllegalArgumentException
* If the resolved message is formatted but is an invalid format pattern or any of the format {@code args}
* are invalid for their placeholders.
* @see #getMessage(Verification, MessageKey, Object...)
* @see #getMessage(Verification, MessageKey, Object[])
*/
protected String getMessageInternal(final MessageKey key, final Object[] args, final Verification<?> verification) {
if (key == null) {
Expand All @@ -366,7 +366,7 @@ protected String getMessageInternal(final MessageKey key, final Object[] args, f

/**
* <p>
* Called internally by {@link #getMessage(Verification, String, Object...)} to handle the actual logic of
* Called internally by {@link #getMessage(Verification, String, Object[])} to handle the actual logic of
* potentially formatting {@code message} using the optional format {@code args} provided.
* </p>
* <p>
Expand All @@ -388,7 +388,7 @@ protected String getMessageInternal(final MessageKey key, final Object[] args, f
* @throws IllegalArgumentException
* If {@code message} is formatted but is an invalid format pattern or any of the format {@code args} are
* invalid for their placeholders.
* @see #getMessage(Verification, String, Object...)
* @see #getMessage(Verification, String, Object[])
*/
protected String getMessageInternal(final String message, final Object[] args, final Verification<?> verification) {
if (message == null) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/skelp/verifier/message/MessageSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public interface MessageSource {
* @throws NoSuchMessageException
* If no message could be found for {@code key} or any other that is required to build the full message.
*/
String getMessage(Verification<?> verification, MessageKey key, Object... args);
String getMessage(Verification<?> verification, MessageKey key, Object[] args);

/**
* <p>
Expand All @@ -102,5 +102,5 @@ public interface MessageSource {
* @throws NoSuchMessageException
* If no message could be found for any keys that are required to build the full message.
*/
String getMessage(Verification<?> verification, String message, Object... args);
String getMessage(Verification<?> verification, String message, Object[] args);
}
10 changes: 10 additions & 0 deletions src/main/java/io/skelp/verifier/message/MessageSourceProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@
* <p>
* Provides {@link MessageSource} instances to be used to retrieve localized and/or formatted messages.
* </p>
* <p>
* {@code MessageSourceProviders} are registered via Java's SPI, so in order to register a custom
* {@code MessageSourceProvider} projects should contain should create a
* {@code io.skelp.verifier.verification.message.MessageSourceProvider} file within {@code META-INF/services} listing
* the class reference for each custom {@code MessageSourceProvider} (e.g.
* {@code com.example.verifier.MyCustomMessageSourceProvider}) on separate lines. {@code MessageSourceProviders} are
* also {@link Weighted}, which means that they are loaded in priority order (the lower the weight, the higher the
* priority). Verifier has a built-in default {@code MessageSourceProvider} which is given a low priority (i.e.
* {@value #DEFAULT_IMPLEMENTATION_WEIGHT}) to allow custom implementations to be easily ordered around it.
* </p>
*
* @author Alasdair Mercer
* @since 0.2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
* {@code Formatters} can choose which types of objects that they support to allow other implementations to provide more
* precise formatting for that type as only one {@code Formatter} will be used for a single instance.
* </p>
* <p>
* {@code Formatters} are registered via Java's SPI, so in order to register a custom {@code Formatter} projects should
* contain should create a {@code io.skelp.verifier.message.formatter.Formatter} file within {@code META-INF/services}
* listing the class reference for each custom {@code Formatter} (e.g. {@code com.example.verifier.MyCustomFormatter})
* on separate lines.
* </p>
*
* @author Alasdair Mercer
* @since 0.2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @see Locale#getDefault()
* @since 0.2.0
*/
public class DefaultLocaleContextProvider implements LocaleContextProvider {
public final class DefaultLocaleContextProvider implements LocaleContextProvider {

@Override
public LocaleContext getLocaleContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@
* <p>
* Provides {@link LocaleContext} instances to be used to localize messages.
* </p>
* <p>
* {@code LocaleContextProviders} are registered via Java's SPI, so in order to register a custom
* {@code LocaleContextProvider} projects should contain should create a
* {@code io.skelp.verifier.verification.message.locale.LocaleContextProvider} file within {@code META-INF/services}
* listing the class reference for each custom {@code LocaleContextProvider} (e.g.
* {@code com.example.verifier.MyCustomLocaleContextProvider}) on separate lines. {@code LocaleContextProviders} are
* also {@link Weighted}, which means that they are loaded in priority order (the lower the weight, the higher the
* priority). Verifier has a built-in default {@code LocaleContextProvider} which is given a low priority (i.e.
* {@value #DEFAULT_IMPLEMENTATION_WEIGHT}) to allow custom implementations to be easily ordered around it.
* </p>
*
* @author Alasdair Mercer
* @since 0.2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @see Locale#getDefault()
* @since 0.2.0
*/
public class SimpleLocaleContext implements LocaleContext {
public final class SimpleLocaleContext implements LocaleContext {

private final Locale locale;

Expand Down
16 changes: 8 additions & 8 deletions src/main/java/io/skelp/verifier/type/BigDecimalVerifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public BigDecimalVerifier even() {
final BigDecimal value = verification().getValue();
final boolean result = value != null && !value.stripTrailingZeros().unscaledValue().testBit(0);

verification().check(result, BaseNumberVerifier.MessageKeys.EVEN);
verification().report(result, BaseNumberVerifier.MessageKeys.EVEN);

return this;
}
Expand All @@ -70,7 +70,7 @@ public BigDecimalVerifier falsy() {
final BigDecimal value = verification().getValue();
final boolean result = value == null || value.compareTo(BigDecimal.ZERO) == 0;

verification().check(result, BaseTruthVerifier.MessageKeys.FALSY);
verification().report(result, BaseTruthVerifier.MessageKeys.FALSY);

return this;
}
Expand All @@ -80,7 +80,7 @@ public BigDecimalVerifier negative() {
final BigDecimal value = verification().getValue();
final boolean result = value != null && value.compareTo(BigDecimal.ZERO) < 0;

verification().check(result, BaseNumberVerifier.MessageKeys.NEGATIVE);
verification().report(result, BaseNumberVerifier.MessageKeys.NEGATIVE);

return this;
}
Expand All @@ -90,7 +90,7 @@ public BigDecimalVerifier odd() {
final BigDecimal value = verification().getValue();
final boolean result = value != null && value.stripTrailingZeros().unscaledValue().testBit(0);

verification().check(result, BaseNumberVerifier.MessageKeys.ODD);
verification().report(result, BaseNumberVerifier.MessageKeys.ODD);

return this;
}
Expand All @@ -100,7 +100,7 @@ public BigDecimalVerifier one() {
final BigDecimal value = verification().getValue();
final boolean result = value != null && value.compareTo(BigDecimal.ONE) == 0;

verification().check(result, BaseNumberVerifier.MessageKeys.ONE);
verification().report(result, BaseNumberVerifier.MessageKeys.ONE);

return this;
}
Expand All @@ -110,7 +110,7 @@ public BigDecimalVerifier positive() {
final BigDecimal value = verification().getValue();
final boolean result = value != null && value.compareTo(BigDecimal.ZERO) >= 0;

verification().check(result, BaseNumberVerifier.MessageKeys.POSITIVE);
verification().report(result, BaseNumberVerifier.MessageKeys.POSITIVE);

return this;
}
Expand All @@ -120,7 +120,7 @@ public BigDecimalVerifier truthy() {
final BigDecimal value = verification().getValue();
final boolean result = value != null && value.compareTo(BigDecimal.ONE) == 0;

verification().check(result, BaseTruthVerifier.MessageKeys.TRUTHY);
verification().report(result, BaseTruthVerifier.MessageKeys.TRUTHY);

return this;
}
Expand All @@ -130,7 +130,7 @@ public BigDecimalVerifier zero() {
final BigDecimal value = verification().getValue();
final boolean result = value != null && value.compareTo(BigDecimal.ZERO) == 0;

verification().check(result, BaseNumberVerifier.MessageKeys.ZERO);
verification().report(result, BaseNumberVerifier.MessageKeys.ZERO);

return this;
}
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/io/skelp/verifier/type/BigIntegerVerifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public BigIntegerVerifier even() {
final BigInteger value = verification().getValue();
final boolean result = value != null && !value.testBit(0);

verification().check(result, BaseNumberVerifier.MessageKeys.EVEN);
verification().report(result, BaseNumberVerifier.MessageKeys.EVEN);

return this;
}
Expand All @@ -70,7 +70,7 @@ public BigIntegerVerifier falsy() {
final BigInteger value = verification().getValue();
final boolean result = value == null || value.compareTo(BigInteger.ZERO) == 0;

verification().check(result, BaseTruthVerifier.MessageKeys.FALSY);
verification().report(result, BaseTruthVerifier.MessageKeys.FALSY);

return this;
}
Expand All @@ -80,7 +80,7 @@ public BigIntegerVerifier negative() {
final BigInteger value = verification().getValue();
final boolean result = value != null && value.compareTo(BigInteger.ZERO) < 0;

verification().check(result, BaseNumberVerifier.MessageKeys.NEGATIVE);
verification().report(result, BaseNumberVerifier.MessageKeys.NEGATIVE);

return this;
}
Expand All @@ -90,7 +90,7 @@ public BigIntegerVerifier odd() {
final BigInteger value = verification().getValue();
final boolean result = value != null && value.testBit(0);

verification().check(result, BaseNumberVerifier.MessageKeys.ODD);
verification().report(result, BaseNumberVerifier.MessageKeys.ODD);

return this;
}
Expand All @@ -100,7 +100,7 @@ public BigIntegerVerifier one() {
final BigInteger value = verification().getValue();
final boolean result = value != null && value.compareTo(BigInteger.ONE) == 0;

verification().check(result, BaseNumberVerifier.MessageKeys.ONE);
verification().report(result, BaseNumberVerifier.MessageKeys.ONE);

return this;
}
Expand All @@ -110,7 +110,7 @@ public BigIntegerVerifier positive() {
final BigInteger value = verification().getValue();
final boolean result = value != null && value.compareTo(BigInteger.ZERO) >= 0;

verification().check(result, BaseNumberVerifier.MessageKeys.POSITIVE);
verification().report(result, BaseNumberVerifier.MessageKeys.POSITIVE);

return this;
}
Expand All @@ -120,7 +120,7 @@ public BigIntegerVerifier truthy() {
final BigInteger value = verification().getValue();
final boolean result = value != null && value.compareTo(BigInteger.ONE) == 0;

verification().check(result, BaseTruthVerifier.MessageKeys.TRUTHY);
verification().report(result, BaseTruthVerifier.MessageKeys.TRUTHY);

return this;
}
Expand All @@ -130,7 +130,7 @@ public BigIntegerVerifier zero() {
final BigInteger value = verification().getValue();
final boolean result = value != null && value.compareTo(BigInteger.ZERO) == 0;

verification().check(result, BaseNumberVerifier.MessageKeys.ZERO);
verification().report(result, BaseNumberVerifier.MessageKeys.ZERO);

return this;
}
Expand Down
Loading