001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.rest.httppart;
014
015/**
016 * Represents the possible parameter types as defined by the Swagger 2.0 specification.
017 *
018 * <h5 class='section'>See Also:</h5><ul>
019 *    <li class='link'><a class="doclink" href="../../../../../index.html#jrs.Swagger">Swagger</a>
020 * </ul>
021 */
022public enum RestPartType {
023
024   /** Path variable */
025   PATH("path"),
026
027   /** Header value */
028   HEADER("header"),
029
030   /** Form data entry */
031   FORM_DATA("formData"),
032
033   /** Query parameter */
034   QUERY("query"),
035
036   /** Request body */
037   BODY("body"),
038
039   //-----------------------------------------------------------------------------------------------------------------
040   // The following are additional parameter types not defined in Swagger
041   //-----------------------------------------------------------------------------------------------------------------
042
043   /** Response value */
044   RESPONSE("response"),
045
046   /** Response value */
047   RESPONSE_BODY("responseBody"),
048
049   /** Response header value */
050   RESPONSE_HEADER("responseHeader"),
051
052   /** Response status value */
053   RESPONSE_CODE("responseCode"),
054
055   /** Not a standard Swagger-defined field */
056   OTHER("other");
057
058   private final String value;
059
060   private RestPartType(String value) {
061      this.value = value;
062   }
063
064   /**
065    * Returns <jk>true</jk> if this type is any in the specified list.
066    *
067    * @param t The list to check against.
068    * @return <jk>true</jk> if this type is any in the specified list.
069    */
070   public boolean isAny(RestPartType...t) {
071      for (RestPartType tt : t)
072         if (this == tt)
073            return true;
074      return false;
075   }
076
077   @Override /* Object */
078   public String toString() {
079      return value;
080   }
081}