Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/adjust java docs #50

Merged
merged 5 commits into from
Sep 26, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import jakarta.validation.constraints.NotNull;

/**
* Class used for demo purposes.
*/
public class IgnoredClass {
@NotNull
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;

/**
* Person class used for demo purposes.
*/
public class Person {
@NotNull(message = "\\foo")
private String firstName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,45 @@
public enum BuiltInConstraint {

// CHECKSTYLE:OFF
/**
* Required validation constraint.
*/
REQUIRED("required", NotNull.class),
/**
* Min validation constraint.
*/
MIN("min", Min.class),
/**
* Max validation constraint.
*/
MAX("max", Max.class),
/**
* Size validation constraint.
*/
SIZE("size", Size.class),
/**
* Number validation constraint.
*/
DIGITS("digits", Digits.class),
/**
* Pattern validation constraint.
*/
PATTERN("pattern", Pattern.class, PatternDecorator.class),
/**
* Date/Time in the future validation constraint.
*/
FUTURE("future", Future.class),
/**
* Date/Time in the past validation constraint.
*/
PAST("past", Past.class),
/**
* Email validation constraint.
*/
EMAIL("email", Email.class),
/**
* URL validation constraint.
*/
URL("hibernateUrl", org.hibernate.validator.constraints.URL.class);
// CHECKSTYLE:ON

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public interface MinimalMap<V> {
/**
* Returns a {@link Set} view of the mappings contained in this map. The set is backed by the map,
* so changes to the map are reflected in the set, and vice-versa. If the map is modified while an
* iteration over the set is in progress (except through the iterator's own <tt>remove</tt> operation,
* or through the <tt>setValue</tt> operation on a map entry returned by the iterator) the results of
* iteration over the set is in progress (except through the iterator's own <code>remove</code> operation,
* or through the <code>setValue</code> operation on a map entry returned by the iterator) the results of
* the iteration are undefined. The set supports element removal, which removes the corresponding
* mapping from the map, via the <tt>Iterator.remove</tt>, <tt>Set.remove</tt>, <tt>removeAll</tt>,
* <tt>retainAll</tt> and <tt>clear</tt> operations. It does not support the <tt>add</tt> or
* <tt>addAll</tt> operations.
* mapping from the map, via the <code>Iterator.remove</code>, <code>Set.remove</code>, <code>removeAll</code>,
* <code>retainAll</code> and <code>clear</code> operations. It does not support the <code>add</code> or
* <code>addAll</code> operations.
*
* @return a set view of the mappings contained in this map
*/
Expand All @@ -30,11 +30,11 @@ public interface MinimalMap<V> {
*
* @param key key with which the specified value is to be associated
* @param value value to be associated with the specified key
* @return the previous value associated with <tt>key</tt>, or <tt>null</tt> if there was no mapping for
* <tt>key</tt>. (A <tt>null</tt> return can also indicate that the map previously associated <tt>null</tt>
* with
* <tt>key</tt>, if the implementation supports <tt>null</tt> values.)
* @throws UnsupportedOperationException if the <tt>put</tt> operation
* @return the previous value associated with <code>key</code>, or <code>null</code> if there was no mapping for
* <code>key</code>. (A <code>null</code> return can also indicate that the map previously associated <code>null</code>
* with
* <code>key</code>, if the implementation supports <code>null</code> values.)
* @throws UnsupportedOperationException if the <code>put</code> operation
* is not supported by this map
* @throws ClassCastException if the class of the specified key or value
* prevents it from being stored in this map
Expand All @@ -46,8 +46,8 @@ public interface MinimalMap<V> {
V put(String key, V value);

/**
* Returns the number of key-value mappings in this map. If the map contains more than <tt>Integer.MAX_VALUE</tt>
* elements, returns <tt>Integer.MAX_VALUE</tt>.
* Returns the number of key-value mappings in this map. If the map contains more than <code>Integer.MAX_VALUE</code>
* elements, returns <code>Integer.MAX_VALUE</code>.
*
* @return the number of key-value mappings in this map
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* configured model packages in the classpath are parsed for classes containing supported or
* custom Bean Validation annotations. The Servlet then builds and returns a JSON document with all validation rules
* (i.e. Bean Validation constraints). The JSON document adheres to structure specified by valdr.</p>
*
* <p>
* Servlet can be configured using following {@link jakarta.servlet.ServletConfig} init parameters (* = mandatory):
* <ul>
* <li>configFile: path to JSON configuration file, if omitted valdr-bean-validation.json is expected at root of class
Expand All @@ -33,10 +33,25 @@
* @see Options
*/
public class ValidationRulesServlet extends HttpServlet {
/**
* Logger for ValidationRulesServlet.
*/
private final Logger logger = LoggerFactory.getLogger(ValidationRulesServlet.class);
/**
* Indicates that there are not errors in the configuration.
*/
private boolean correctlyConfigured = false;
/**
* CORS allow origin pattern.
*/
private String corsAllowOriginPattern;
/**
* Holds info about reason for the invalid configuration.
*/
private String invalidConfigurationMessage;
/**
* Constraint parser.
*/
private ConstraintParser parser;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
*/
public class NullDecorator extends AbstractConstraintAttributesDecorator {
// CHECKSTYLE:OFF

/**
* Contructor.
*
* @param decoratee constraint attributes
*/
public NullDecorator(ConstraintAttributes decoratee) {
super(decoratee);
}
Expand All @@ -18,4 +24,4 @@ public NullDecorator(ConstraintAttributes decoratee) {
public Set<Map.Entry<String, Object>> entrySet() {
return getDecoratee().entrySet();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,41 +86,98 @@ public static AnnotationAttributes fromMap(Map<String, Object> map) {
return new AnnotationAttributes(map);
}

/**
* Gets value of type {@link String} for the given attribute name.
*
* @param attributeName attribute name
* @return value of type {@link String}
*/
public String getString(String attributeName) {
return doGet(attributeName, String.class);
}

/**
* Gets value of type {@link String} array for the given attribute name.
*
* @param attributeName attribute name
* @return value of type {@link String} array
*/
public String[] getStringArray(String attributeName) {
return doGet(attributeName, String[].class);
}

/**
* Gets value of type {@link Boolean} for the given attribute name.
*
* @param attributeName attribute name
* @return value of type {@link Boolean}
*/
public boolean getBoolean(String attributeName) {
return doGet(attributeName, Boolean.class);
}

/**
* Gets value of type {@link Number} for the given attribute name.
*
* @param attributeName attribute name
* @param <N> type of {@link Number}
* @return value of type {@link Number}
*/
@SuppressWarnings("unchecked")
public <N extends Number> N getNumber(String attributeName) {
return (N) doGet(attributeName, Integer.class);
}

/**
* Gets value of type {@link Enum} for the given attribute name.
*
* @param attributeName attribute name
* @param <E> extends Enum
* @return value of type {@link Enum}
*/
@SuppressWarnings("unchecked")
public <E extends Enum<?>> E getEnum(String attributeName) {
return (E) doGet(attributeName, Enum.class);
}

/**
* Gets value of type {@link Class} for the given attribute name.
*
* @param attributeName attribute name
* @param <T> class
* @return value of type {@link Class}
*/
@SuppressWarnings("unchecked")
public <T> Class<? extends T> getClass(String attributeName) {
return doGet(attributeName, Class.class);
}

/**
* Gets value of type {@link Class} array for the given attribute name.
*
* @param attributeName attribute name
* @return value of type {@link Class} array
*/
public Class<?>[] getClassArray(String attributeName) {
return doGet(attributeName, Class[].class);
}

/**
* Gets value of type {@link AnnotationAttributes} for the given attribute name.
*
* @param attributeName attribute name
* @return value of type {@link AnnotationAttributes}
*/
public AnnotationAttributes getAnnotation(String attributeName) {
return doGet(attributeName, AnnotationAttributes.class);
}

/**
* Gets value of type {@link AnnotationAttributes} array for the given attribute name.
*
* @param attributeName attribute name
* @return value of type {@link AnnotationAttributes} array
*/
public AnnotationAttributes[] getAnnotationArray(String attributeName) {
return doGet(attributeName, AnnotationAttributes[].class);
}
Expand Down