Skip to content

Commit eb7e096

Browse files
committed
docs: Eliminate all maven-javadoc-plugin warnings
Adds detailed but concise javadoc across the public API and internal implementation classes so `mvn package` runs the attached-javadocs goal without any warnings (previously 174). No code behaviour changes. Also adds an explicit no-arg constructor with javadoc to FormTypeMapper, FormUrlEncodedParser, NotFoundHandler, TextPlainParser, and TextTypeMapper so the synthesised default constructor no longer trips doclint, and imports ValidationException in Validator to resolve the {@link} references in its contract javadoc.
1 parent d613f05 commit eb7e096

78 files changed

Lines changed: 1382 additions & 24 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/com/retailsvc/http/AfterResponseHook.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,18 @@
1818
@FunctionalInterface
1919
public interface AfterResponseHook {
2020

21+
/**
22+
* Invoked after the response has been written to the client.
23+
*
24+
* <p>Any exception thrown by this method is logged at DEBUG and swallowed; it does not affect the
25+
* response (already sent) and does not prevent subsequent hooks from running.
26+
*
27+
* @param request the resolved {@link Request} that was handled; routing and parameter/body
28+
* validation have already passed by the time this is called
29+
* @param response the {@link Response} that was written to the client. {@link Response#status()}
30+
* and {@link Response#headers()} reflect what was sent on the wire; {@link Response#body()}
31+
* may be {@code null} on streaming responses (and is always {@code null} on the error path,
32+
* since the body bytes have already been emitted)
33+
*/
2134
void after(Request request, Response response);
2235
}

src/main/java/com/retailsvc/http/BadRequestException.java

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,58 @@ public final class BadRequestException extends RuntimeException {
1616

1717
private static final int DEFAULT_STATUS = 400;
1818

19+
/** HTTP 4xx status code carried by this exception. */
1920
private final int status;
21+
22+
/** JSON Pointer (RFC 6901) to the offending property; may be {@code null}. */
2023
private final String pointer;
24+
25+
/** Validation keyword that failed (for example {@code "required"}); may be {@code null}. */
2126
private final String keyword;
2227

28+
/**
29+
* Creates a new exception with the default HTTP status {@code 400 Bad Request}.
30+
*
31+
* <p>Equivalent to {@link #BadRequestException(int, String, String, String)} invoked with {@code
32+
* status = 400} and no pointer or keyword.
33+
*
34+
* @param detail human-readable explanation of the error; surfaced as the RFC 7807 {@code detail}
35+
* member
36+
*/
2337
public BadRequestException(String detail) {
2438
this(DEFAULT_STATUS, detail, null, null);
2539
}
2640

41+
/**
42+
* Creates a new exception with an explicit 4xx HTTP status.
43+
*
44+
* <p>Equivalent to {@link #BadRequestException(int, String, String, String)} with no pointer or
45+
* keyword.
46+
*
47+
* @param status the HTTP status code; must be in the range {@code 400}-{@code 499} or an {@link
48+
* IllegalArgumentException} is thrown
49+
* @param detail human-readable explanation of the error; surfaced as the RFC 7807 {@code detail}
50+
* member
51+
*/
2752
public BadRequestException(int status, String detail) {
2853
this(status, detail, null, null);
2954
}
3055

56+
/**
57+
* Creates a new exception with the full set of RFC 7807 problem fields. Intended for
58+
* validation-style errors where the offending property can be pinpointed with a JSON Pointer and
59+
* the failing rule identified by a JSON Schema keyword.
60+
*
61+
* @param status the HTTP status code; must be in the range {@code 400}-{@code 499}
62+
* @param detail human-readable explanation of the error; surfaced as the RFC 7807 {@code detail}
63+
* member
64+
* @param pointer JSON Pointer (RFC 6901) to the offending property in the request payload; may be
65+
* {@code null} when not applicable
66+
* @param keyword JSON Schema / validation keyword that failed (for example {@code "required"},
67+
* {@code "pattern"}, {@code "maxLength"}); may be {@code null} when not applicable
68+
* @throws NullPointerException if {@code detail} is {@code null}
69+
* @throws IllegalArgumentException if {@code status} is not in the range {@code 400}-{@code 499}
70+
*/
3171
public BadRequestException(int status, String detail, String pointer, String keyword) {
3272
super(Objects.requireNonNull(detail, "detail must not be null"));
3373
if (status < 400 || status > 499) {
@@ -38,14 +78,32 @@ public BadRequestException(int status, String detail, String pointer, String key
3878
this.keyword = keyword;
3979
}
4080

81+
/**
82+
* Returns the HTTP status code carried by this exception.
83+
*
84+
* @return the HTTP status code; always a 4xx value in the range {@code 400}-{@code 499}
85+
*/
4186
public int status() {
4287
return status;
4388
}
4489

90+
/**
91+
* Returns the JSON Pointer locating the offending property in the request payload.
92+
*
93+
* @return an {@link Optional} containing the JSON Pointer (RFC 6901) to the offending property,
94+
* or {@link Optional#empty()} when no pointer was supplied
95+
*/
4596
public Optional<String> pointer() {
4697
return Optional.ofNullable(pointer);
4798
}
4899

100+
/**
101+
* Returns the JSON Schema / validation keyword that failed.
102+
*
103+
* @return an {@link Optional} containing the failing JSON Schema or validation keyword (for
104+
* example {@code "required"}, {@code "pattern"}), or {@link Optional#empty()} when no keyword
105+
* was supplied
106+
*/
49107
public Optional<String> keyword() {
50108
return Optional.ofNullable(keyword);
51109
}

src/main/java/com/retailsvc/http/Credential.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,25 @@
77
public sealed interface Credential
88
permits Credential.ApiKeyCredential, Credential.BearerCredential, Credential.BasicCredential {
99

10+
/**
11+
* Credential extracted from an OpenAPI {@code apiKey} security scheme (header, query, or cookie).
12+
*
13+
* @param value raw key value as presented by the client.
14+
*/
1015
record ApiKeyCredential(String value) implements Credential {}
1116

17+
/**
18+
* Credential extracted from an {@code http} security scheme with {@code bearer} style.
19+
*
20+
* @param token raw bearer token (no {@code Bearer } prefix).
21+
*/
1222
record BearerCredential(String token) implements Credential {}
1323

24+
/**
25+
* Credential extracted from an {@code http} security scheme with {@code basic} style.
26+
*
27+
* @param username decoded username portion.
28+
* @param password decoded password portion.
29+
*/
1430
record BasicCredential(String username, String password) implements Credential {}
1531
}

src/main/java/com/retailsvc/http/Dependency.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
* @param up whether the dependency is healthy
1313
*/
1414
public record Dependency(String id, boolean up) {
15+
/**
16+
* Canonical constructor that validates {@code id} is non-null.
17+
*
18+
* @throws NullPointerException if {@code id} is {@code null}
19+
*/
1520
public Dependency {
1621
Objects.requireNonNull(id, "id");
1722
}

src/main/java/com/retailsvc/http/ExceptionHandler.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,13 @@
1010
@FunctionalInterface
1111
public interface ExceptionHandler {
1212

13+
/**
14+
* Maps the throwable to the {@link Response} to render.
15+
*
16+
* @param t the exception thrown anywhere in the request pipeline (never null)
17+
* @return the response to write; library default maps {@code BadRequestException} to 4xx
18+
* problem+json and anything else to 500 problem+json with the exception message redacted by
19+
* default
20+
*/
1321
Response handle(Throwable t);
1422
}

src/main/java/com/retailsvc/http/GsonTypeMapper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public GsonTypeMapper() {
3737
/**
3838
* Creates a mapper backed by the supplied {@link Gson}.
3939
*
40+
* @param gson the {@link Gson} instance to delegate to
4041
* @throws NullPointerException if {@code gson} is null
4142
*/
4243
public GsonTypeMapper(Gson gson) {
@@ -47,6 +48,8 @@ public GsonTypeMapper(Gson gson) {
4748
* Returns a {@link GsonBuilder} pre-populated with the wrapped {@link Gson}'s configuration, so
4849
* callers can derive a customized {@link Gson} from the library default (or from their own
4950
* starting point).
51+
*
52+
* @return a new {@link GsonBuilder} seeded with the wrapped {@link Gson}'s configuration
5053
*/
5154
public GsonBuilder gsonBuilder() {
5255
return delegate.gson().newBuilder();

src/main/java/com/retailsvc/http/Handlers.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,20 @@
2121
import org.slf4j.Logger;
2222
import org.slf4j.LoggerFactory;
2323

24+
/** Built-in {@link RequestHandler} and {@link ExceptionHandler} factories. */
2425
public final class Handlers {
2526

2627
private static final Logger LOG = LoggerFactory.getLogger(Handlers.class);
2728

2829
private Handlers() {}
2930

31+
/**
32+
* Default {@link ExceptionHandler} that maps common library exceptions to RFC 7807 problem
33+
* responses and falls back to a 500 for anything unrecognised.
34+
*
35+
* @param jsonMapper mapper used to serialise problem detail bodies
36+
* @return the exception handler
37+
*/
3038
public static ExceptionHandler defaultExceptionHandler(TypeMapper jsonMapper) {
3139
Objects.requireNonNull(jsonMapper, "jsonMapper must not be null");
3240
return t ->
@@ -54,7 +62,12 @@ public static ExceptionHandler defaultExceptionHandler(TypeMapper jsonMapper) {
5462
};
5563
}
5664

57-
/** Returns 204 No Content on GET/HEAD; 405 with {@code Allow: GET, HEAD} otherwise. */
65+
/**
66+
* Liveness handler that returns 204 No Content on GET/HEAD; 405 with {@code Allow: GET, HEAD}
67+
* otherwise.
68+
*
69+
* @return the liveness handler
70+
*/
5871
public static RequestHandler aliveHandler() {
5972
return req ->
6073
switch (req.method()) {
@@ -79,6 +92,7 @@ public static RequestHandler aliveHandler() {
7992
* <p>The body is rendered by a built-in writer; no JSON library on the classpath is required.
8093
*
8194
* @param probe supplier of the current {@link HealthOutcome}
95+
* @return the health handler
8296
*/
8397
public static RequestHandler healthHandler(Supplier<HealthOutcome> probe) {
8498
Objects.requireNonNull(probe, "probe");
@@ -110,6 +124,7 @@ public static RequestHandler healthHandler(Supplier<HealthOutcome> probe) {
110124
* request — the handler owns the stream lifecycle.
111125
*
112126
* @param classpathResource absolute classpath path, e.g. {@code /schemas/v1/openapi.yaml}
127+
* @return the spec handler
113128
*/
114129
public static RequestHandler resourceHandler(String classpathResource) {
115130
return resourceHandler(ResourceSource.ofClasspath(classpathResource));
@@ -119,6 +134,9 @@ public static RequestHandler resourceHandler(String classpathResource) {
119134
* Serves a filesystem file as a streaming response. Content-Type is inferred from the file
120135
* extension. Existence and length are resolved at construction; a missing file fails immediately
121136
* with {@link IllegalArgumentException}. The file is opened and closed per request.
137+
*
138+
* @param file path to the file to serve
139+
* @return a handler that streams {@code file} on {@code GET}
122140
*/
123141
public static RequestHandler resourceHandler(Path file) {
124142
return resourceHandler(ResourceSource.ofFile(file));

src/main/java/com/retailsvc/http/HealthOutcome.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@
1414
*/
1515
public record HealthOutcome(List<Dependency> dependencies) {
1616

17+
/** Canonical constructor; normalises a {@code null} dependency list to an empty list. */
1718
public HealthOutcome {
1819
dependencies = List.copyOf(Objects.requireNonNullElse(dependencies, List.of()));
1920
}
2021

21-
/** {@code true} when every dependency is up (vacuously true for an empty list). */
22+
/**
23+
* Reports the aggregate health derived from {@link #dependencies()}.
24+
*
25+
* @return {@code true} when every dependency is up (vacuously true for an empty list)
26+
*/
2227
public boolean up() {
2328
return dependencies.stream().allMatch(Dependency::up);
2429
}

src/main/java/com/retailsvc/http/Jackson2JsonTypeMapper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ public final class Jackson2JsonTypeMapper implements TypedTypeMapper {
3131

3232
private final ObjectMapper mapper;
3333

34+
/**
35+
* Creates a new mapper backed by the given Jackson {@link ObjectMapper}.
36+
*
37+
* @param mapper the fully-configured Jackson mapper to delegate to; must not be {@code null}
38+
*/
3439
public Jackson2JsonTypeMapper(ObjectMapper mapper) {
3540
this.mapper = Objects.requireNonNull(mapper, "mapper must not be null");
3641
}

src/main/java/com/retailsvc/http/Jackson3JsonTypeMapper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public final class Jackson3JsonTypeMapper implements TypedTypeMapper {
3737

3838
private final ObjectMapper mapper;
3939

40+
/**
41+
* Creates a new mapper backed by the given Jackson 3 {@link ObjectMapper}.
42+
*
43+
* @param mapper the fully-configured Jackson 3 mapper to delegate to; must not be {@code null}
44+
*/
4045
public Jackson3JsonTypeMapper(ObjectMapper mapper) {
4146
this.mapper = Objects.requireNonNull(mapper, "mapper must not be null");
4247
}

0 commit comments

Comments
 (0)