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 private static final long serialVersionUID = 1L; 030 031 /** 032 * Static creator. 033 * 034 * @return An empty list. 035 */ 036 public static NamedAttributeMap create() { 037 return new NamedAttributeMap(); 038 } 039 040 /** 041 * Static creator. 042 * 043 * @param values The initial contents of this list. 044 * @return An empty list. 045 */ 046 public static NamedAttributeMap of(NamedAttribute...values) { 047 return create().add(values); 048 } 049 050 /** 051 * Constructor. 052 */ 053 public NamedAttributeMap() {} 054 055 /** 056 * Copy constructor. 057 * 058 * @param copyFrom The list to copy from. 059 */ 060 public NamedAttributeMap(NamedAttributeMap copyFrom) { 061 putAll(copyFrom); 062 } 063 064 /** 065 * Appends the specified rest matcher classes to the list. 066 * 067 * @param values The values to add. 068 * @return This object. 069 */ 070 public NamedAttributeMap add(NamedAttribute...values) { 071 for (var v : values) 072 put(v.getName(), v); 073 return this; 074 } 075 076 /** 077 * Creates a copy of this list. 078 * 079 * @return A new copy of this list. 080 */ 081 public NamedAttributeMap copy() { 082 return new NamedAttributeMap(this); 083 } 084}