1 /* 2 * Copyright 2012-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.issue.config; 17 18 import java.util.ArrayList; 19 import java.util.List; 20 21 import de.smartics.util.lang.Arg; 22 23 /** 24 * Provides access to configurations for the Bugzilla plugin. 25 */ 26 public final class Configuration 27 { 28 // ********************************* Fields ********************************* 29 30 // --- constants ------------------------------------------------------------ 31 32 // --- members -------------------------------------------------------------- 33 34 /** 35 * The identifier of the configuration. 36 */ 37 private String id; 38 39 /** 40 * The list of default components to a product stored on a Bugzilla server. 41 */ 42 private final List<Component> defaultComponents = new ArrayList<Component>(); 43 44 // ****************************** Initializer ******************************* 45 46 // ****************************** Constructors ****************************** 47 48 /** 49 * Loader constructor. 50 */ 51 public Configuration() 52 { 53 } 54 55 /** 56 * Default constructor. 57 * 58 * @param id the identifier of the configuration. 59 */ 60 public Configuration(final String id) 61 { 62 this.id = id; 63 } 64 65 // ****************************** Inner Classes ***************************** 66 67 // ********************************* Methods ******************************** 68 69 // --- init ----------------------------------------------------------------- 70 71 // --- factory -------------------------------------------------------------- 72 73 // --- get&set -------------------------------------------------------------- 74 75 /** 76 * Returns the identifier of the configuration. 77 * 78 * @return the identifier of the configuration. 79 */ 80 public String getId() 81 { 82 return id; 83 } 84 85 /** 86 * Returns the list of default components to a product stored on a Bugzilla 87 * server. 88 * 89 * @return the list of default components to a product stored on a Bugzilla 90 * server. 91 */ 92 public List<Component> getDefaultComponents() 93 { 94 return defaultComponents; 95 } 96 97 // --- business ------------------------------------------------------------- 98 99 /** 100 * Adds a default component. 101 * 102 * @param component the component to be added. 103 * @throws NullPointerException if {@code component} is <code>null</code>. 104 */ 105 public void addDefaultComponent(final Component component) 106 throws NullPointerException 107 { 108 Arg.checkNotNull("component", component); 109 110 defaultComponents.add(component); 111 } 112 113 // --- object basics -------------------------------------------------------- 114 115 /** 116 * Returns the string representation of the object. 117 * 118 * @return the string representation of the object. 119 */ 120 @Override 121 public String toString() 122 { 123 final StringBuilder buffer = new StringBuilder(); 124 125 buffer.append(id); 126 for (final Component component : defaultComponents) 127 { 128 buffer.append("\n ").append(component); 129 } 130 131 return buffer.toString(); 132 } 133 134 }