Skip to content

Commit 78c47b3

Browse files
committed
Update copyright years to 2026
1 parent 1e964cc commit 78c47b3

26 files changed

+171
-168
lines changed

.idea/scopes/Source_Code.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2015-2025, Erik C. Thauvin (erik@thauvin.net)
1+
Copyright (c) 2015-2026, Erik C. Thauvin (erik@thauvin.net)
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without

src/bld/java/net/thauvin/erik/httpstatus/HttpStatusBuild.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* HttpStatusBuild.java
33
*
4-
* Copyright 2015-2025 Erik C. Thauvin (erik@thauvin.net)
4+
* Copyright 2015-2026 Erik C. Thauvin (erik@thauvin.net)
55
* All rights reserved.
66
*
77
* Redistribution and use in source and binary forms, with or without
@@ -153,11 +153,6 @@ public void publishLocal() throws Exception {
153153
pomRoot();
154154
}
155155

156-
private void pomRoot() throws FileUtilsErrorException {
157-
PomBuilder.generateInto(publishOperation().fromProject(this).info(), dependencies(),
158-
new File("pom.xml"));
159-
}
160-
161156
public static void main(String[] args) {
162157
new HttpStatusBuild().start(args);
163158
}
@@ -194,4 +189,9 @@ public void spotbugs() throws Exception {
194189
.home("/opt/spotbugs")
195190
.execute();
196191
}
192+
193+
private void pomRoot() throws FileUtilsErrorException {
194+
PomBuilder.generateInto(publishOperation().fromProject(this).info(), dependencies(),
195+
new File("pom.xml"));
196+
}
197197
}

src/main/java/net/thauvin/erik/httpstatus/Reasons.java

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Reasons.java
33
*
4-
* Copyright 2015-2025 Erik C. Thauvin (erik@thauvin.net)
4+
* Copyright 2015-2026 Erik C. Thauvin (erik@thauvin.net)
55
* All rights reserved.
66
*
77
* Redistribution and use in source and binary forms, with or without
@@ -72,6 +72,27 @@ private Reasons() {
7272
throw new UnsupportedOperationException("Illegal constructor call.");
7373
}
7474

75+
/**
76+
* Retrieves a map of reason phrases associated with a specific standard HTTP response class.
77+
* <p>
78+
* The response class is determined by the first digit of the status codes provided by the {@code StatusCodeClass}.
79+
* This method filters and collects those reason phrases whose status code starts with the specified class digit.
80+
*
81+
* @param reasonClass The {@code StatusCodeClass} enum representing the HTTP response class
82+
* @return A map where the keys are status code strings and the values are the corresponding reason phrases
83+
* @since 2.0.0
84+
*/
85+
public static Map<String, String> getReasonClass(StatusCodeClass reasonClass) {
86+
var reasons = new ConcurrentSkipListMap<String, String>();
87+
var firstDigit = String.valueOf(reasonClass.getFirstDigit());
88+
REASON_PHRASES.keySet().forEach(k -> {
89+
if (k.startsWith(firstDigit)) {
90+
reasons.put(k, REASON_PHRASES.get(k));
91+
}
92+
});
93+
return reasons;
94+
}
95+
7596
/**
7697
* Returns the reason phrase for the specified status code.
7798
*
@@ -83,12 +104,6 @@ public static <T> String getReasonPhrase(T statusCode) {
83104
return REASON_PHRASES.get(toStatusCodeString(statusCode));
84105
}
85106

86-
private static <T> String toStatusCodeString(T statusCode) {
87-
return (statusCode instanceof Integer)
88-
? Integer.toString((Integer) statusCode)
89-
: String.valueOf(statusCode);
90-
}
91-
92107
/**
93108
* Returns the reason phrase for the specified status code.
94109
*
@@ -105,6 +120,10 @@ public static <T> String getReasonPhrase(T statusCode, String defaultReason) {
105120
return reason;
106121
}
107122

123+
private static boolean isStatusCodeClass(String code) {
124+
return code.matches("[1-5]xx");
125+
}
126+
108127
/**
109128
* Prints the reason phrase for the given status code(s).
110129
*
@@ -125,21 +144,26 @@ private static void printAllReasonPhrases() {
125144
System.out.println("Total: " + REASON_PHRASES.size());
126145
}
127146

128-
private static void processStatusCode(String code) {
129-
if (isStatusCodeClass(code)) {
130-
processStatusCodeClass(code);
131-
} else {
132-
printSingleStatusCode(code);
133-
}
147+
private static void printReasonClassPhrases(Map<String, String> reasons) {
148+
reasons.forEach(Reasons::printReasonPhrase);
134149
}
135150

136151
@SuppressWarnings("PMD.SystemPrintln")
137152
private static void printReasonPhrase(String code, String phrase) {
138153
System.out.println(code + ": " + phrase);
139154
}
140155

141-
private static boolean isStatusCodeClass(String code) {
142-
return code.matches("[1-5]xx");
156+
private static void printSingleStatusCode(String code) {
157+
Optional.ofNullable(REASON_PHRASES.get(code))
158+
.ifPresent(phrase -> printReasonPhrase(code, phrase));
159+
}
160+
161+
private static void processStatusCode(String code) {
162+
if (isStatusCodeClass(code)) {
163+
processStatusCodeClass(code);
164+
} else {
165+
printSingleStatusCode(code);
166+
}
143167
}
144168

145169
private static void processStatusCodeClass(String code) {
@@ -148,33 +172,9 @@ private static void processStatusCodeClass(String code) {
148172
.ifPresent(reasonClass -> printReasonClassPhrases(getReasonClass(reasonClass)));
149173
}
150174

151-
private static void printSingleStatusCode(String code) {
152-
Optional.ofNullable(REASON_PHRASES.get(code))
153-
.ifPresent(phrase -> printReasonPhrase(code, phrase));
154-
}
155-
156-
private static void printReasonClassPhrases(Map<String, String> reasons) {
157-
reasons.forEach(Reasons::printReasonPhrase);
158-
}
159-
160-
/**
161-
* Retrieves a map of reason phrases associated with a specific standard HTTP response class.
162-
* <p>
163-
* The response class is determined by the first digit of the status codes provided by the {@code StatusCodeClass}.
164-
* This method filters and collects those reason phrases whose status code starts with the specified class digit.
165-
*
166-
* @param reasonClass The {@code StatusCodeClass} enum representing the HTTP response class
167-
* @return A map where the keys are status code strings and the values are the corresponding reason phrases
168-
* @since 2.0.0
169-
*/
170-
public static Map<String, String> getReasonClass(StatusCodeClass reasonClass) {
171-
var reasons = new ConcurrentSkipListMap<String, String>();
172-
var firstDigit = String.valueOf(reasonClass.getFirstDigit());
173-
REASON_PHRASES.keySet().forEach(k -> {
174-
if (k.startsWith(firstDigit)) {
175-
reasons.put(k, REASON_PHRASES.get(k));
176-
}
177-
});
178-
return reasons;
175+
private static <T> String toStatusCodeString(T statusCode) {
176+
return (statusCode instanceof Integer)
177+
? Integer.toString((Integer) statusCode)
178+
: String.valueOf(statusCode);
179179
}
180180
}

src/main/java/net/thauvin/erik/httpstatus/StatusCode.java

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* StatusCode.java
33
*
4-
* Copyright 2015-2025 Erik C. Thauvin (erik@thauvin.net)
4+
* Copyright 2015-2026 Erik C. Thauvin (erik@thauvin.net)
55
* All rights reserved.
66
*
77
* Redistribution and use in source and binary forms, with or without
@@ -79,15 +79,25 @@ public static String getReason(int code) {
7979
}
8080

8181
/**
82-
* Checks if the status code is informational.
82+
* Checks if the status code is a client error. (e.g.: <code>Internal Server Error</code>)
8383
*
8484
* @param code the status code
85-
* @return <code>true</code> if the status code is informational, <code>false</code>
86-
* @see #isInfo(int)
85+
* @return <code>true</code> if the status code is a client error, <code>false</code> otherwise
8786
* @since 2.0.0
8887
*/
89-
public static boolean isInformational(int code) {
90-
return isInfo(code);
88+
public static boolean isClientError(int code) {
89+
return code >= 400 && code < 500;
90+
}
91+
92+
/**
93+
* Checks if the status code is a client or server error.
94+
*
95+
* @param code the status code
96+
* @return <code>true</code> if the status code is an error, <code>false</code> otherwise
97+
* @since 2.0.0
98+
*/
99+
public static boolean isError(int code) {
100+
return code >= 400 && code < 600;
91101
}
92102

93103
/**
@@ -103,15 +113,37 @@ public static boolean isInfo(int code) {
103113
}
104114

105115
/**
106-
* Checks if the status code is a (<code>OK</code>) success.
116+
* Checks if the status code is informational.
107117
*
108118
* @param code the status code
109-
* @return <code>true</code> if the status code is a success, <code>false</code> otherwise
110-
* @see #isSuccess(int)
119+
* @return <code>true</code> if the status code is informational, <code>false</code>
120+
* @see #isInfo(int)
111121
* @since 2.0.0
112122
*/
113-
public static boolean isSuccessful(int code) {
114-
return isSuccess(code);
123+
public static boolean isInformational(int code) {
124+
return isInfo(code);
125+
}
126+
127+
/**
128+
* Checks if the status code is a redirect.
129+
*
130+
* @param code the status code
131+
* @return <code>true</code> if the status code is a redirect, <code>false</code> otherwise
132+
* @since 2.0.0
133+
*/
134+
public static boolean isRedirect(int code) {
135+
return code >= 300 && code < 400;
136+
}
137+
138+
/**
139+
* Checks if the status code is a server error.
140+
*
141+
* @param code the status code
142+
* @return <code>true</code> if the status code is a server error, <code>false</code> otherwise
143+
* @since 2.0.0
144+
*/
145+
public static boolean isServerError(int code) {
146+
return code >= 500 && code < 600;
115147
}
116148

117149
/**
@@ -126,6 +158,28 @@ public static boolean isSuccess(int code) {
126158
return code >= 200 && code < 300;
127159
}
128160

161+
/**
162+
* Checks if the status code is a (<code>OK</code>) success.
163+
*
164+
* @param code the status code
165+
* @return <code>true</code> if the status code is a success, <code>false</code> otherwise
166+
* @see #isSuccess(int)
167+
* @since 2.0.0
168+
*/
169+
public static boolean isSuccessful(int code) {
170+
return isSuccess(code);
171+
}
172+
173+
/**
174+
* Checks if the status code is valid.
175+
*
176+
* @param code the status code
177+
* @return <code>true</code> if the status code is valid, <code>false</code> otherwise
178+
*/
179+
public static boolean isValid(int code) {
180+
return code == 783 || (code >= 100 && code < 600);
181+
}
182+
129183
/**
130184
* Returns the status code.
131185
*/
@@ -161,17 +215,6 @@ public boolean isClientError() {
161215
return isClientError(code);
162216
}
163217

164-
/**
165-
* Checks if the status code is a client error. (e.g.: <code>Internal Server Error</code>)
166-
*
167-
* @param code the status code
168-
* @return <code>true</code> if the status code is a client error, <code>false</code> otherwise
169-
* @since 2.0.0
170-
*/
171-
public static boolean isClientError(int code) {
172-
return code >= 400 && code < 500;
173-
}
174-
175218
/**
176219
* Checks if the status code is a client or server error.
177220
*
@@ -181,17 +224,6 @@ public boolean isError() {
181224
return isError(code);
182225
}
183226

184-
/**
185-
* Checks if the status code is a client or server error.
186-
*
187-
* @param code the status code
188-
* @return <code>true</code> if the status code is an error, <code>false</code> otherwise
189-
* @since 2.0.0
190-
*/
191-
public static boolean isError(int code) {
192-
return code >= 400 && code < 600;
193-
}
194-
195227
/**
196228
* Checks if the status code is informational.
197229
*
@@ -220,17 +252,6 @@ public boolean isRedirect() {
220252
return isRedirect(code);
221253
}
222254

223-
/**
224-
* Checks if the status code is a redirect.
225-
*
226-
* @param code the status code
227-
* @return <code>true</code> if the status code is a redirect, <code>false</code> otherwise
228-
* @since 2.0.0
229-
*/
230-
public static boolean isRedirect(int code) {
231-
return code >= 300 && code < 400;
232-
}
233-
234255
/**
235256
* Checks if the status code is a server error.
236257
*
@@ -240,17 +261,6 @@ public boolean isServerError() {
240261
return isServerError(code);
241262
}
242263

243-
/**
244-
* Checks if the status code is a server error.
245-
*
246-
* @param code the status code
247-
* @return <code>true</code> if the status code is a server error, <code>false</code> otherwise
248-
* @since 2.0.0
249-
*/
250-
public static boolean isServerError(int code) {
251-
return code >= 500 && code < 600;
252-
}
253-
254264
/**
255265
* Checks if the status code is a (<code>OK</code>) success.
256266
*
@@ -278,14 +288,4 @@ public boolean isSuccessful() {
278288
public boolean isValid() {
279289
return isValid(code);
280290
}
281-
282-
/**
283-
* Checks if the status code is valid.
284-
*
285-
* @param code the status code
286-
* @return <code>true</code> if the status code is valid, <code>false</code> otherwise
287-
*/
288-
public static boolean isValid(int code) {
289-
return code == 783 || (code >= 100 && code < 600);
290-
}
291291
}

src/main/java/net/thauvin/erik/httpstatus/StatusCodeClass.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* StatusCodeClass.java
33
*
4-
* Copyright 2015-2025 Erik C. Thauvin (erik@thauvin.net)
4+
* Copyright 2015-2026 Erik C. Thauvin (erik@thauvin.net)
55
* All rights reserved.
66
*
77
* Redistribution and use in source and binary forms, with or without

0 commit comments

Comments
 (0)