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.rest.httppart;
018
019import java.util.*;
020
021/**
022 * A list of {@link NamedAttribute} objects.
023 *
024 * <h5 class='section'>See Also:</h5><ul>
025 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/HttpParts">HTTP Parts</a>
026 * </ul>
027 */
028public class NamedAttributeMap extends LinkedHashMap<String,NamedAttribute> {
029
030   //-----------------------------------------------------------------------------------------------------------------
031   // Static
032   //-----------------------------------------------------------------------------------------------------------------
033
034   private static final long serialVersionUID = 1L;
035
036   /**
037    * Static creator.
038    *
039    * @return An empty list.
040    */
041   public static NamedAttributeMap create() {
042      return new NamedAttributeMap();
043   }
044
045   /**
046    * Static creator.
047    *
048    * @param values The initial contents of this list.
049    * @return An empty list.
050    */
051   public static NamedAttributeMap of(NamedAttribute...values) {
052      return create().add(values);
053   }
054
055   //-----------------------------------------------------------------------------------------------------------------
056   // Instance
057   //-----------------------------------------------------------------------------------------------------------------
058
059   /**
060    * Constructor.
061    */
062   public NamedAttributeMap() {
063   }
064
065   /**
066    * Copy constructor.
067    *
068    * @param copyFrom The list to copy from.
069    */
070   public NamedAttributeMap(NamedAttributeMap copyFrom) {
071      putAll(copyFrom);
072   }
073
074   /**
075    * Creates a copy of this list.
076    *
077    * @return A new copy of this list.
078    */
079   public NamedAttributeMap copy() {
080      return new NamedAttributeMap(this);
081   }
082
083   //-------------------------------------------------------------------------------------------------------------
084   // Properties
085   //-------------------------------------------------------------------------------------------------------------
086
087   /**
088    * Appends the specified rest matcher classes to the list.
089    *
090    * @param values The values to add.
091    * @return This object.
092    */
093   public NamedAttributeMap add(NamedAttribute...values) {
094      for (NamedAttribute v : values)
095         put(v.getName(), v);
096      return this;
097   }
098}