001/* 002 * Copyright 2022-2026 Revetware LLC. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package com.soklet; 018 019import org.jspecify.annotations.NonNull; 020 021import java.util.Arrays; 022import java.util.Set; 023import java.util.stream.Collectors; 024 025/** 026 * Typesafe representation of <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods">HTTP request methods</a>. 027 * 028 * @author <a href="https://www.revetkn.com">Mark Allen</a> 029 */ 030public enum HttpMethod { 031 /** 032 * The HTTP <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET">{@code GET}</a> request method. 033 */ 034 GET, 035 /** 036 * The HTTP <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST">{@code POST}</a> request method. 037 */ 038 POST, 039 /** 040 * The HTTP <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT">{@code PUT}</a> request method. 041 */ 042 PUT, 043 /** 044 * The HTTP <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH">{@code PATCH}</a> request method. 045 */ 046 PATCH, 047 /** 048 * The HTTP <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS">{@code OPTIONS}</a> request method. 049 */ 050 OPTIONS, 051 /** 052 * The HTTP <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD">{@code HEAD}</a> request method. 053 */ 054 HEAD, 055 /** 056 * The HTTP <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE">{@code DELETE}</a> request method. 057 */ 058 DELETE; 059 060 @NonNull 061 private static final Set<@NonNull HttpMethod> VALUES_AS_SET; 062 063 static { 064 VALUES_AS_SET = Arrays.stream(HttpMethod.values()).collect(Collectors.toUnmodifiableSet()); 065 } 066 067 /** 068 * Exposes {@link HttpMethod#values()} as a {@link Set} for convenience. 069 * 070 * @return a {@link Set} representation of this enum's values 071 */ 072 @NonNull 073 public static Set<@NonNull HttpMethod> valuesAsSet() { 074 return VALUES_AS_SET; 075 } 076}