ok2c commented on a change in pull request #191: Add
org.apache.hc.core5.http.Method.normalizedValueOf(String) for use by
URL:
https://github.com/apache/httpcomponents-core/pull/191#discussion_r372017334
##########
File path: httpcore5/src/main/java/org/apache/hc/core5/http/Method.java
##########
@@ -78,12 +79,22 @@ public static boolean isIdempotent(final String value) {
return false;
}
try {
- return valueOf(value.toUpperCase(Locale.ROOT)).idempotent;
+ return normalizedValueOf(value).idempotent;
} catch (final IllegalArgumentException ex) {
return false;
}
}
+ /**
+ * Returns the Method for a normalized {@code value} of a method name.
+ *
+ * @param method A method name like {@code "delete"}, {@code "DELETE"}, or
any mixed-case variant.
+ * @return the Method for the given method name.
+ */
+ public static Method normalizedValueOf(final String method) {
+ return valueOf(Objects.requireNonNull(method,
"method").toUpperCase(Locale.ROOT));
Review comment:
> Done. But... oh why oh why are we _duplicating_ functionality that's in
the JRE?
Because when Args had been introduced, there was no such functionality in
JRE. And we have already discussed it. Many times. If you want to remove `Args`
and `LangUtils` feel free to do so but do it _consistently_ across the _entire_
code base. Everywhere.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]