Fixed containsKey() before get().
This commit is contained in:
parent
4a701e1ee0
commit
9d21dd76c0
1 changed files with 9 additions and 8 deletions
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Reasons.java
|
* Reasons.java
|
||||||
*
|
*
|
||||||
* Copyright (c) 2015-2016, Erik C. Thauvin (erik@thauvin.net)
|
* Copyright (c) 2015-2020, Erik C. Thauvin (erik@thauvin.net)
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -32,8 +32,6 @@
|
||||||
|
|
||||||
package net.thauvin.erik.httpstatus;
|
package net.thauvin.erik.httpstatus;
|
||||||
|
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
@ -100,18 +98,21 @@ public final class Reasons {
|
||||||
* @param args The status code(s), prints all if none.
|
* @param args The status code(s), prints all if none.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("PMD.SystemPrintln")
|
@SuppressWarnings("PMD.SystemPrintln")
|
||||||
@SuppressFBWarnings("MUI_CONTAINSKEY_BEFORE_GET")
|
|
||||||
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 (REASON_PHRASES.containsKey(key)) {
|
final String value = REASON_PHRASES.get(key);
|
||||||
System.out.println(key + ": " + REASON_PHRASES.get(key));
|
if (value != null) {
|
||||||
|
System.out.println(key + ": " + value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final SortedSet<String> keys = new TreeSet<>(REASON_PHRASES.keySet());
|
final SortedSet<String> keys = new TreeSet<>(REASON_PHRASES.keySet());
|
||||||
for (final String key : keys) {
|
for (final String key : keys) {
|
||||||
System.out.println(key + ": " + REASON_PHRASES.get(key));
|
final String value = REASON_PHRASES.get(key);
|
||||||
|
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