1 package org.apache.archiva.metadata.model;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import java.util.Collection;
23 import java.util.Collections;
24 import java.util.HashMap;
28 * Base class for metadata that is contains facets for storing extensions by various plugins.
30 public abstract class FacetedMetadata
33 * The facets to store, keyed by the {@linkplain MetadataFacet#getFacetId() Facet ID} of the metadata.
35 private Map<String, MetadataFacet> facets = new HashMap<String, MetadataFacet>();
38 * Add a new facet to the metadata. If it already exists, it will be replaced.
40 * @param metadataFacet the facet to add
42 public void addFacet( MetadataFacet metadataFacet )
44 this.facets.put( metadataFacet.getFacetId(), metadataFacet );
48 * Get a particular facet of metadata.
50 * @param facetId the facet ID
51 * @return the facet of the metadata.
53 public MetadataFacet getFacet( String facetId )
55 return this.facets.get( facetId );
59 * Get all the facets available on this metadata.
61 * @return the facets of the metadata
63 public Collection<MetadataFacet> getFacetList()
65 return this.facets.values();
69 * Get all the keys of the facets available on this metadata.
71 * @return the collection of facet IDs.
73 public Collection<String> getFacetIds()
75 return this.facets.keySet();
79 * Get all available facets as a Map (typically used by bean rendering, such as in Archiva's JSPs).
81 * @return the map of facets
84 public Map<String, MetadataFacet> getFacets()
86 return Collections.unmodifiableMap( facets );