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.httppart;
014
015/**
016 * Valid values for the <c>collectionFormat</c> field.
017 */
018public enum HttpPartCollectionFormat {
019
020   /**
021    * Comma-separated values (e.g. <js>"foo,bar"</js>).
022    */
023   CSV,
024
025   /**
026    * Space-separated values (e.g. <js>"foo bar"</js>).
027    */
028   SSV,
029
030   /**
031    * Tab-separated values (e.g. <js>"foo\tbar"</js>).
032    */
033   TSV,
034
035   /**
036    * Pipe-separated values (e.g. <js>"foo|bar"</js>).
037    */
038   PIPES,
039
040   /**
041    * Corresponds to multiple parameter instances instead of multiple values for a single instance (e.g. <js>"foo=bar&amp;foo=baz"</js>).
042    */
043   MULTI,
044
045   /**
046    * UON collection notation (e.g. <js>"@(foo,bar)"</js>).
047    */
048   UONC,
049
050   /**
051    * Not specified.
052    */
053   NO_COLLECTION_FORMAT;
054
055   /**
056    * Create from lowercase string.
057    *
058    * @param value The enum name.
059    * @return The enum.
060    */
061   public static HttpPartCollectionFormat fromString(String value) {
062      if (value == null)
063         return null;
064      if (value.equalsIgnoreCase("UON"))
065         return UONC;
066      return valueOf(value.toUpperCase());
067   }
068
069   @Override /* Object */
070   public String toString() {
071      return name().toLowerCase();
072   }
073}