Skip to content

Commit f8e9054

Browse files
committed
javadoc
1 parent 9d9b8c1 commit f8e9054

File tree

4 files changed

+86
-3
lines changed

4 files changed

+86
-3
lines changed

validator/src/main/java/io/avaje/validation/adapter/MethodAdapterProvider.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,58 @@
33
import java.lang.reflect.Method;
44
import java.util.List;
55

6+
/**
7+
* Provides adapters for method validation, including parameter, return, and cross-parameter adapters.
8+
* <p>
9+
* Implementations supply the target {@link Method} and adapters for validating method parameters,
10+
* return values, and cross-parameter constraints within a validation context.
11+
*/
612
public interface MethodAdapterProvider {
713

14+
/**
15+
* Returns the target method to be validated.
16+
*
17+
* @return the {@link Method} instance
18+
* @throws Exception if the method cannot be provided
19+
*/
820
Method method() throws Exception;
921

22+
/**
23+
* Provides adapters for validating each method parameter.
24+
*
25+
* @param ctx the validation context
26+
* @return list of parameter adapters
27+
*/
1028
List<ValidationAdapter<Object>> paramAdapters(ValidationContext ctx);
1129

30+
/**
31+
* Provides an adapter for validating the method return value.
32+
* Default implementation returns a no-op adapter.
33+
*
34+
* @param ctx the validation context
35+
* @return the return value adapter
36+
*/
1237
default ValidationAdapter<Object> returnAdapter(ValidationContext ctx) {
1338
return ctx.noop();
1439
}
1540

41+
/**
42+
* Provides an adapter for cross-parameter validation (constraints involving multiple parameters).
43+
* Default implementation returns a no-op adapter.
44+
*
45+
* @param ctx the validation context
46+
* @return the cross-parameter adapter
47+
*/
1648
default ValidationAdapter<Object[]> crossParamAdapter(ValidationContext ctx) {
1749
return ctx.noop();
1850
}
1951

52+
/**
53+
* Provides the target method, wrapping checked exceptions as {@link IllegalStateException}.
54+
*
55+
* @return the {@link Method} instance
56+
* @throws IllegalStateException if the method cannot be provided
57+
*/
2058
default Method provide() {
2159
try {
2260
return method();

validator/src/main/java/io/avaje/validation/spi/ValidationExtension.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,22 @@
22

33
import io.avaje.spi.Service;
44

5-
/** Super interface for all validation SPIs */
5+
/**
6+
* Marker super interface for all validation Service Provider Interfaces (SPIs).
7+
*
8+
* <p>Implementations of this interface extend the validation system with custom adapters,
9+
* annotation handling, message interpolation, and other validation-related features.
10+
*
11+
* <p>Permitted subtypes include:
12+
*
13+
* <ul>
14+
* <li>{@link AdapterFactory} - Provides adapters for validation logic.
15+
* <li>{@link AnnotationFactory} - Provides adapters for annotations.
16+
* <li>{@link GeneratedComponent} - Registry of generated validation adapters.
17+
* <li>{@link MessageInterpolator} - Interpolates validation messages.
18+
* <li>{@link ValidatorCustomizer} - Allows customization of the validator instance.
19+
* </ul>
20+
*/
621
@Service
722
public sealed interface ValidationExtension
823
permits AdapterFactory,

validator/src/main/java/io/avaje/validation/spi/ValidatorCustomizer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package io.avaje.validation.spi;
22

3+
import io.avaje.spi.ServiceProvider;
34
import io.avaje.validation.Validator;
45

56
/**
67
* Callback interface that's used to customize a Validator.Builder.
78
*
89
* <p>These are service loaded when a Validator starts. The classes can be registered with {@link
9-
* BuilderCustomizer} or via a {@code provides} clause in module-info when using the java module
10+
* ServiceProvider} or via a {@code provides} clause in module-info when using the java module
1011
* system.
1112
*/
1213
@FunctionalInterface

validator/src/main/java/module-info.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,33 @@
1-
/** Avaje Validation Library */
1+
/**
2+
* Avaje Validation API - see {@link io.avaje.validation.Validator}.
3+
*
4+
* <h2>Example:</h2>
5+
*
6+
* <pre>{@code
7+
* // Annotate classes with @Valid
8+
*
9+
* @Valid
10+
* public class Address {
11+
*
12+
* // annotate fields with constraints
13+
* @NotBlank
14+
* private String street;
15+
*
16+
* @NotEmpty(message="must not be empty")
17+
* private List<@NotBlank String> owners; // message will be interpolated from bundle
18+
*
19+
* //getters/setters
20+
* }
21+
*
22+
* --------------------------------------------------
23+
*
24+
* final Validator validator = Validator.builder().build();
25+
*
26+
* Address address = ...;
27+
* validator.validate(address);
28+
*
29+
* }</pre>
30+
*/
231
module io.avaje.validation {
332
exports io.avaje.validation;
433
exports io.avaje.validation.adapter;

0 commit comments

Comments
 (0)