Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
DefaultSiteModuleManager |
|
| 3.0;3 |
1 | package org.apache.maven.doxia.module.site.manager; | |
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.Collection; | |
23 | import java.util.LinkedHashMap; | |
24 | import java.util.Map; | |
25 | ||
26 | import org.apache.maven.doxia.module.site.SiteModule; | |
27 | ||
28 | /** | |
29 | * Simple implementation of the SiteModuleManager interface. | |
30 | * | |
31 | * @author Jason van Zyl | |
32 | * @version $Id: DefaultSiteModuleManager.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
33 | * @since 1.0 | |
34 | * @plexus.component | |
35 | */ | |
36 | 0 | public class DefaultSiteModuleManager |
37 | implements SiteModuleManager | |
38 | { | |
39 | /** | |
40 | * @plexus.requirement role="org.apache.maven.doxia.module.site.SiteModule" | |
41 | */ | |
42 | private Map<String, SiteModule> siteModules; | |
43 | ||
44 | private Collection<SiteModule> siteModulesValues; | |
45 | ||
46 | /** {@inheritDoc} */ | |
47 | public Collection<SiteModule> getSiteModules() | |
48 | { | |
49 | 0 | if ( siteModulesValues == null ) |
50 | { | |
51 | 0 | Map<Class<?>, SiteModule> siteModulesTmp = new LinkedHashMap<Class<?>, SiteModule>(); |
52 | 0 | for ( SiteModule module : siteModules.values() ) |
53 | { | |
54 | 0 | siteModulesTmp.put( module.getClass(), module ); |
55 | } | |
56 | 0 | siteModulesValues = siteModulesTmp.values(); |
57 | } | |
58 | ||
59 | 0 | return siteModulesValues; |
60 | } | |
61 | ||
62 | /** {@inheritDoc} */ | |
63 | public SiteModule getSiteModule( String id ) | |
64 | throws SiteModuleNotFoundException | |
65 | { | |
66 | 0 | SiteModule siteModule = siteModules.get( id ); |
67 | ||
68 | 0 | if ( siteModule == null ) |
69 | { | |
70 | 0 | throw new SiteModuleNotFoundException( "Cannot find site module id = " + id ); |
71 | } | |
72 | ||
73 | 0 | return siteModule; |
74 | } | |
75 | } |