Simplified printing list of all status codes
This commit is contained in:
parent
1fca084fc9
commit
b0826267b5
1 changed files with 7 additions and 12 deletions
|
@ -34,8 +34,6 @@ package net.thauvin.erik.httpstatus;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import java.util.SortedSet;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -94,16 +92,16 @@ public final class Reasons {
|
||||||
/**
|
/**
|
||||||
* Prints the reason phrase for the given status code(s).
|
* Prints the reason phrase for the given status code(s).
|
||||||
*
|
*
|
||||||
* @param args The status code(s), prints all if none.
|
* @param args The status code(s) or response class(es), prints all if none.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("PMD.SystemPrintln")
|
@SuppressWarnings("PMD.SystemPrintln")
|
||||||
public static void main(final String... args) {
|
public static void main(final String... args) {
|
||||||
if (args.length >= 1) {
|
if (args.length >= 1) {
|
||||||
for (final String key : args) {
|
for (final String key : args) {
|
||||||
if (key.endsWith("xx")) {
|
if (key.endsWith("xx")) {
|
||||||
var cat = key.charAt(0);
|
var responseClass = key.charAt(0);
|
||||||
REASON_PHRASES.forEach((k, v) -> {
|
REASON_PHRASES.forEach((k, v) -> {
|
||||||
if (k.charAt(0) == cat) {
|
if (k.charAt(0) == responseClass) {
|
||||||
System.out.println(k + ": " + v);
|
System.out.println(k + ": " + v);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -115,14 +113,11 @@ public final class Reasons {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final SortedSet<String> keys = new TreeSet<>(REASON_PHRASES.keySet());
|
REASON_PHRASES.forEach((k, v) -> {
|
||||||
for (final String key : keys) {
|
if (v != null) {
|
||||||
final String value = REASON_PHRASES.get(key);
|
System.out.println(k + ": " + v);
|
||||||
if (value != null) {
|
|
||||||
System.out.println(key + ": " + value);
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
System.out.println("Total: " + REASON_PHRASES.size());
|
System.out.println("Total: " + REASON_PHRASES.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue