wujian
2024-02-22 268beb4ebc1e5b8d4ad715b71cd64a0944073a87
提交 | 用户 | 时间
268beb 1 package com.jcdm.common.enums;
W 2
3 import java.util.HashMap;
4 import java.util.Map;
5 import org.springframework.lang.Nullable;
6
7 /**
8  * 请求方式
9  *
10  * @author jc
11  */
12 public enum HttpMethod
13 {
14     GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;
15
16     private static final Map<String, HttpMethod> mappings = new HashMap<>(16);
17
18     static
19     {
20         for (HttpMethod httpMethod : values())
21         {
22             mappings.put(httpMethod.name(), httpMethod);
23         }
24     }
25
26     @Nullable
27     public static HttpMethod resolve(@Nullable String method)
28     {
29         return (method != null ? mappings.get(method) : null);
30     }
31
32     public boolean matches(String method)
33     {
34         return (this == resolve(method));
35     }
36 }