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