Class HttpMethod

java.lang.Object
org.springframework.http.HttpMethod
All Implemented Interfaces:
Serializable, Comparable<HttpMethod>

public final class HttpMethod extends Object implements Comparable<HttpMethod>, Serializable
Represents an HTTP request method. Intended for use with ClientHttpRequest and RestTemplate.
Since:
3.0
Author:
Arjen Poutsma, Juergen Hoeller
See Also:
  • Field Details

  • Method Details

    • values

      public static HttpMethod[] values()
      Returns an array containing the standard HTTP methods. Specifically, this method returns an array containing GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, and TRACE.

      Note that the returned value does not include any HTTP methods defined in WebDav.

    • valueOf

      public static HttpMethod valueOf(String method)
      Return an HttpMethod object for the given value.
      Parameters:
      method - the method value as a String
      Returns:
      the corresponding HttpMethod
    • resolve

      @Nullable @Deprecated(since="6.0", forRemoval=true) public static HttpMethod resolve(@Nullable String method)
      Deprecated, for removal: This API element is subject to removal in a future version.
      in favor of valueOf(String)
      Resolve the given method value to an HttpMethod.
      Parameters:
      method - the method value as a String
      Returns:
      the corresponding HttpMethod, or null if not found
      Since:
      4.2.4
    • name

      public String name()
      Return the name of this method, e.g. "GET", "POST".
    • matches

      public boolean matches(String method)
      Determine whether this HttpMethod matches the given method value.
      Parameters:
      method - the HTTP method as a String
      Returns:
      true if it matches, false otherwise
      Since:
      4.2.4
    • compareTo

      public int compareTo(HttpMethod other)
      Specified by:
      compareTo in interface Comparable<HttpMethod>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(@Nullable Object other)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object