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.commons.httppart;
018
019import static org.apache.juneau.commons.utils.Shorts.*;
020
021/**
022 * Valid values for the <c>collectionFormat</c> field.
023 *
024 * <h5 class='section'>See Also:</h5><ul>
025 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/HttpPartSerializersParsers">HTTP Part Serializers and Parsers</a>
026 * </ul>
027 */
028public enum HttpPartCollectionFormat {
029
030   /**
031    * Comma-separated values (e.g. <js>"foo,bar"</js>).
032    */
033   CSV,
034
035   /**
036    * Space-separated values (e.g. <js>"foo bar"</js>).
037    */
038   SSV,
039
040   /**
041    * Tab-separated values (e.g. <js>"foo\tbar"</js>).
042    */
043   TSV,
044
045   /**
046    * Pipe-separated values (e.g. <js>"foo|bar"</js>).
047    */
048   PIPES,
049
050   /**
051    * Corresponds to multiple parameter instances instead of multiple values for a single instance (e.g. <js>"foo=bar&amp;foo=baz"</js>).
052    */
053   MULTI,
054
055   /**
056    * UON collection notation (e.g. <js>"@(foo,bar)"</js>).
057    */
058   UONC,
059
060   /**
061    * Not specified.
062    */
063   NO_COLLECTION_FORMAT;
064
065   /**
066    * Create from lowercase string.
067    *
068    * @param value The enum name.  Can be <jk>null</jk> (returns <jk>null</jk>).
069    * @return The enum, or <jk>null</jk> if the input was <jk>null</jk>.
070    */
071   public static HttpPartCollectionFormat fromString(String value) {
072      if (value == null)
073         return null;
074      if (eqic(value, "UON"))
075         return UONC;
076      return valueOf(ucr(value));
077   }
078
079   @Override /* Overridden from Object */
080   public String toString() {
081      return lcr(name());
082   }
083}