From a5b2fa543450a6547a6f5c202b49f88e718273f5 Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Mon, 20 Jan 2020 10:40:07 +0100 Subject: [PATCH] Add HttpMethod.values() returning an un-modifiable list of HTTP methods known by the declaring interface --- .../java/io/vertx/core/http/HttpMethod.java | 10 +++++ .../vertx/core/http/impl/HttpMethodImpl.java | 37 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/main/java/io/vertx/core/http/HttpMethod.java b/src/main/java/io/vertx/core/http/HttpMethod.java index 44f037127..e9db3003b 100644 --- a/src/main/java/io/vertx/core/http/HttpMethod.java +++ b/src/main/java/io/vertx/core/http/HttpMethod.java @@ -14,6 +14,7 @@ package io.vertx.core.http; import io.vertx.codegen.annotations.VertxGen; import io.vertx.core.http.impl.HttpMethodImpl; +import java.util.List; import java.util.Objects; /** @@ -180,6 +181,8 @@ public interface HttpMethod { */ HttpMethod SEARCH = new HttpMethodImpl(io.netty.handler.codec.http.HttpMethod.valueOf("SEARCH")); + + /** * @return the method name */ @@ -272,4 +275,11 @@ public interface HttpMethod { return new HttpMethodImpl(io.netty.handler.codec.http.HttpMethod.valueOf(value)); } } + + /** + * @return an un-modifiable list of known HTTP methods + */ + static List values() { + return HttpMethodImpl.ALL; + } } diff --git a/src/main/java/io/vertx/core/http/impl/HttpMethodImpl.java b/src/main/java/io/vertx/core/http/impl/HttpMethodImpl.java index 920d26c89..47c3baaf5 100644 --- a/src/main/java/io/vertx/core/http/impl/HttpMethodImpl.java +++ b/src/main/java/io/vertx/core/http/impl/HttpMethodImpl.java @@ -12,10 +12,47 @@ package io.vertx.core.http.impl; import io.vertx.core.http.HttpMethod; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import java.util.Objects; public class HttpMethodImpl implements HttpMethod { + public static final List ALL = Collections.unmodifiableList(Arrays.asList( + HttpMethod.OPTIONS, + HttpMethod.GET, + HttpMethod.HEAD, + HttpMethod.POST, + HttpMethod.PUT, + HttpMethod.DELETE, + HttpMethod.TRACE, + HttpMethod.CONNECT, + HttpMethod.PATCH, + HttpMethod.PROPFIND, + HttpMethod.PROPPATCH, + HttpMethod.MKCOL, + HttpMethod.COPY, + HttpMethod.MOVE, + HttpMethod.LOCK, + HttpMethod.UNLOCK, + HttpMethod.MKCALENDAR, + HttpMethod.VERSION_CONTROL, + HttpMethod.REPORT, + HttpMethod.CHECKIN, + HttpMethod.CHECKOUT, + HttpMethod.UNCHECKOUT, + HttpMethod.MKWORKSPACE, + HttpMethod.UPDATE, + HttpMethod.LABEL, + HttpMethod.MERGE, + HttpMethod.BASELINE_CONTROL, + HttpMethod.MKACTIVITY, + HttpMethod.ORDERPATCH, + HttpMethod.ACL, + HttpMethod.SEARCH + )); + public static io.netty.handler.codec.http.HttpMethod toNetty(HttpMethod method) { if (method instanceof HttpMethodImpl) { return ((HttpMethodImpl) method).nettyMethod;