@SuppressWarnings({"squid:S2201", "ResultOfMethodCallIgnored"}) @Override public void validateValue(@Nullable final CharSequence value) { super.validateValue(value); try { Duration.ofSeconds(Long.parseLong(String.valueOf(value))); } catch (final NumberFormatException | DateTimeParseException e) { final String msgTemplate = "<{0}> is not a valid timeout!"; throw new IllegalArgumentException(MessageFormat.format(msgTemplate, value), e); } } },
@SuppressWarnings({"squid:S2201", "ResultOfMethodCallIgnored"}) @Override public void validateValue(@Nullable final CharSequence value) { super.validateValue(value); try { OffsetDateTime.parse(String.valueOf(value)); } catch (final DateTimeParseException e) { final String msgTemplate = "<{0}> is not a valid timestamp!"; throw new IllegalArgumentException(MessageFormat.format(msgTemplate, value), e); } } },
@SuppressWarnings({"squid:S2201", "ResultOfMethodCallIgnored"}) @Override public void validateValue(@Nullable final CharSequence value) { super.validateValue(value); HttpStatusCode.forInt(Integer.parseInt(String.valueOf(value))).orElseThrow(() -> { final String msgTemplate = "<{0}> is not a HTTP status code!"; return new IllegalArgumentException(MessageFormat.format(msgTemplate, value)); }); } },
@Override public void validateValue(@Nullable final CharSequence value) { super.validateValue(value); final Validator subjectValidator = IdValidator.newInstance(value, SUBJECT_REGEX); if (!subjectValidator.isValid()) { final String msgTemplate = "The subject <{0}> is invalid because it did not match the pattern <{1}>!"; throw SubjectInvalidException.newBuilder(String.valueOf(value)) .message(() -> MessageFormat.format(msgTemplate, value, SUBJECT_REGEX)) .build(); } } },