HttpMethodEnum.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */
  20. package org.openspcoop2.utils.service.beans;

  21. import com.fasterxml.jackson.annotation.JsonCreator;
  22. import com.fasterxml.jackson.annotation.JsonValue;
  23. import javax.xml.bind.annotation.XmlType;
  24. import javax.xml.bind.annotation.XmlEnum;
  25. import javax.xml.bind.annotation.XmlEnumValue;

  26. /**
  27.  * Gets or Sets HttpMethodEnum
  28.  */
  29. @XmlType(name="HttpMethodEnum")
  30. @XmlEnum(String.class)
  31. public enum HttpMethodEnum {
  32.   @XmlEnumValue("GET")
  33. GET("GET"),
  34.     @XmlEnumValue("POST")
  35. POST("POST"),
  36.     @XmlEnumValue("PUT")
  37. PUT("PUT"),
  38.     @XmlEnumValue("DELETE")
  39. DELETE("DELETE"),
  40.     @XmlEnumValue("OPTIONS")
  41. OPTIONS("OPTIONS"),
  42.     @XmlEnumValue("HEAD")
  43. HEAD("HEAD"),
  44.     @XmlEnumValue("TRACE")
  45. TRACE("TRACE"),
  46.     @XmlEnumValue("PATCH")
  47. PATCH("PATCH"),
  48.     @XmlEnumValue("LINK")
  49. LINK("LINK"),
  50.     @XmlEnumValue("UNLINK")
  51. UNLINK("UNLINK");

  52.   private String value;

  53.   HttpMethodEnum(String value) {
  54.     this.value = value;
  55.   }

  56.   @Override
  57.   @JsonValue
  58.   public String toString() {
  59.     return String.valueOf(this.value);
  60.   }

  61.   @JsonCreator
  62.   public static HttpMethodEnum fromValue(String text) {
  63.     for (HttpMethodEnum b : HttpMethodEnum.values()) {
  64.       if (String.valueOf(b.value).equals(text)) {
  65.         return b;
  66.       }
  67.     }
  68.     return null;
  69.   }
  70.  
  71. }