1 /* 2 * Copyright 2008-2013 smartics, Kronseder & Reiner GmbH 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package de.smartics.maven.issues.factory; 17 18 import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin; 19 20 import de.smartics.maven.issues.IssueManagementConfig; 21 import de.smartics.maven.issues.RepositoryFacade; 22 import de.smartics.maven.issues.RepositoryFacadeFactory; 23 import de.smartics.maven.issues.bugzilla.BugzillaRepositoryFacade; 24 25 /** 26 * Creates a repository facade factory. 27 * <p> 28 * A simple hard coded implementation. 29 * </p> 30 * 31 * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a> 32 * @version $Revision:591 $ 33 */ 34 public class DefaultRepositoryFacadeFactory implements RepositoryFacadeFactory 35 { 36 // ********************************* Fields ********************************* 37 38 // --- constants ------------------------------------------------------------ 39 40 // --- members -------------------------------------------------------------- 41 42 // ****************************** Initializer ******************************* 43 44 // ****************************** Constructors ****************************** 45 46 /** 47 * Default constructor. 48 */ 49 public DefaultRepositoryFacadeFactory() 50 { 51 } 52 53 // ****************************** Inner Classes ***************************** 54 55 // ********************************* Methods ******************************** 56 57 // --- init ----------------------------------------------------------------- 58 59 // --- get&set -------------------------------------------------------------- 60 61 // --- business ------------------------------------------------------------- 62 63 /** 64 * Creates a facade for the given configuration. 65 * 66 * @param config the configuration to create the facade. 67 * @return the facade matching the requirements given in the configuration. 68 * @throws IllegalArgumentException if no facade can be created that matches 69 * the requirements of the given configuration. 70 */ 71 public RepositoryFacade create(final IssueManagementConfig config) 72 throws IllegalArgumentException 73 { 74 final String issueManagementId = config.getIssueManagementId(); 75 76 if (BugzillaCorePlugin.CONNECTOR_KIND.equalsIgnoreCase(issueManagementId)) 77 { 78 return BugzillaRepositoryFacade.create(config); 79 } 80 else 81 { 82 throw new IllegalArgumentException("No factory for issue management '" 83 + issueManagementId + "'."); 84 } 85 } 86 87 /** 88 * {@inheritDoc} 89 * 90 * @see de.smartics.maven.issues.RepositoryFacadeFactory#supports(java.lang.String) 91 */ 92 public boolean supports(final String issueManagementId) 93 { 94 return BugzillaCorePlugin.CONNECTOR_KIND 95 .equalsIgnoreCase(issueManagementId); 96 } 97 98 // --- object basics -------------------------------------------------------- 99 100 }