View Javadoc
1   package org.eclipse.aether.util.artifact;
2   
3   /*
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
11   * 
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   * 
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
19   * under the License.
20   */
21  
22  import java.util.HashMap;
23  import java.util.Map;
24  
25  import org.eclipse.aether.artifact.ArtifactType;
26  import org.eclipse.aether.artifact.ArtifactTypeRegistry;
27  
28  /**
29   * A simple map-based artifact type registry.
30   */
31  class SimpleArtifactTypeRegistry
32      implements ArtifactTypeRegistry
33  {
34  
35      private final Map<String, ArtifactType> types;
36  
37      /**
38       * Creates a new artifact type registry with initally no registered artifact types. Use {@link #add(ArtifactType)}
39       * to populate the registry.
40       */
41      SimpleArtifactTypeRegistry()
42      {
43          types = new HashMap<>();
44      }
45  
46      /**
47       * Adds the specified artifact type to the registry.
48       * 
49       * @param type The artifact type to add, must not be {@code null}.
50       * @return This registry for chaining, never {@code null}.
51       */
52      public SimpleArtifactTypeRegistry add( ArtifactType type )
53      {
54          types.put( type.getId(), type );
55          return this;
56      }
57  
58      public ArtifactType get( String typeId )
59      {
60          return types.get( typeId );
61      }
62  
63      @Override
64      public String toString()
65      {
66          return types.toString();
67      }
68  
69  }