/** * Checks if the specified CharSequence is a valid representation of the Java type of this definition. * <p> * For example, if the Java type of this Definition was {@code int.class} then the value {@code "foo"} would be * invalid whereas the value {@code 42} would be recognised to be valid. * </p> * * @param value the value to be validated. * @throws IllegalArgumentException if {@code value} is not a valid representation of this definition's Java type. * @see #getJavaType() */ default void validateValue(@Nullable final CharSequence value) { final HeaderValueValidator validator = HeaderValueValidator.getInstance(); validator.accept(this, value); }
@Override public void accept(@Nonnull final HeaderDefinition definition, @Nullable final CharSequence charSequence) { final Class<?> definitionJavaType = checkNotNull(definition, "Definition").getJavaType(); if (isInt(definitionJavaType)) { validateIntegerValue(definition.getKey(), charSequence); } else if (isLong(definitionJavaType)) { validateLongValue(definition.getKey(), charSequence); } else if (isBoolean(definitionJavaType)) { validateBooleanValue(definition.getKey(), charSequence); } else if (isJsonArray(definitionJavaType)) { validateJsonArrayValue(definition.getKey(), charSequence); } else if (isEntityTag(definitionJavaType)) { validateEntityTag(definition.getKey(), charSequence); } else if (isEntityTagMatchers(definitionJavaType)) { validateEntityTagMatchers(definition.getKey(), charSequence); } }
@Override public void accept(@Nonnull final HeaderDefinition definition, @Nullable final CharSequence charSequence) { final Class<?> definitionJavaType = checkNotNull(definition, "Definition").getJavaType(); if (isInt(definitionJavaType)) { validateIntegerValue(definition.getKey(), charSequence); } else if (isLong(definitionJavaType)) { validateLongValue(definition.getKey(), charSequence); } else if (isBoolean(definitionJavaType)) { validateBooleanValue(definition.getKey(), charSequence); } else if (isJsonArray(definitionJavaType)) { validateJsonArrayValue(definition.getKey(), charSequence); } else if (isEntityTag(definitionJavaType)) { validateEntityTag(definition.getKey(), charSequence); } else if (isEntityTagMatchers(definitionJavaType)) { validateEntityTagMatchers(definition.getKey(), charSequence); } }
/** * Checks if the specified CharSequence is a valid representation of the Java type of this definition. * <p> * For example, if the Java type of this Definition was {@code int.class} then the value {@code "foo"} would be * invalid whereas the value {@code 42} would be recognised to be valid. * </p> * * @param value the value to be validated. * @throws IllegalArgumentException if {@code value} is not a valid representation of this definition's Java type. * @see #getJavaType() */ default void validateValue(@Nullable final CharSequence value) { final HeaderValueValidator validator = HeaderValueValidator.getInstance(); validator.accept(this, value); }