001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.httppart;
018
019/**
020 * Valid values for the <c>collectionFormat</c> field.
021 *
022 * <h5 class='section'>See Also:</h5><ul>
023 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/HttpPartSerializersParsers">HTTP Part Serializers and Parsers</a>
024 * </ul>
025 */
026public enum HttpPartCollectionFormat {
027
028   /**
029    * Comma-separated values (e.g. <js>"foo,bar"</js>).
030    */
031   CSV,
032
033   /**
034    * Space-separated values (e.g. <js>"foo bar"</js>).
035    */
036   SSV,
037
038   /**
039    * Tab-separated values (e.g. <js>"foo\tbar"</js>).
040    */
041   TSV,
042
043   /**
044    * Pipe-separated values (e.g. <js>"foo|bar"</js>).
045    */
046   PIPES,
047
048   /**
049    * Corresponds to multiple parameter instances instead of multiple values for a single instance (e.g. <js>"foo=bar&amp;foo=baz"</js>).
050    */
051   MULTI,
052
053   /**
054    * UON collection notation (e.g. <js>"@(foo,bar)"</js>).
055    */
056   UONC,
057
058   /**
059    * Not specified.
060    */
061   NO_COLLECTION_FORMAT;
062
063   /**
064    * Create from lowercase string.
065    *
066    * @param value The enum name.
067    * @return The enum.
068    */
069   public static HttpPartCollectionFormat fromString(String value) {
070      if (value == null)
071         return null;
072      if (value.equalsIgnoreCase("UON"))
073         return UONC;
074      return valueOf(value.toUpperCase());
075   }
076
077   @Override /* Object */
078   public String toString() {
079      return name().toLowerCase();
080   }
081}