Line | Hits | Source |
---|---|---|
1 | /* | |
2 | * Copyright (C) 2006 TopCoder Inc., All Rights Reserved. | |
3 | */ | |
4 | package com.topcoder.testframework; | |
5 | ||
6 | import org.apache.tools.ant.BuildException; | |
7 | ||
8 | import java.util.Map; | |
9 | ||
10 | ||
11 | /** | |
12 | * A CredentialProperty represents nested element of the <tt>credentials</tt> element. This nested element represents | |
13 | * single property from the property map. The name of nested element represents the property key, the <tt>value</tt> | |
14 | * attribute - property value. | |
15 | * <p/> | |
16 | * This class is mutable, i.e. not thread-safe. | |
17 | * | |
18 | * @author real_vg, TCSDEVELOPER | |
19 | * @version 1.0 | |
20 | */ | |
21 | public class CredentialProperty { | |
22 | ||
23 | /** | |
24 | * This field is the name of property, represented by this element. It is initialized in the constructor. | |
25 | */ | |
26 | private final String name; | |
27 | ||
28 | /** | |
29 | * This field holds the property map this property belongs to. It is initialized in the constructor. | |
30 | */ | |
31 | private final Map propertyMap; | |
32 | ||
33 | /** | |
34 | * Creates a CredentialProperty instance. The name of property and the property map the property should belong to | |
35 | * are specified. | |
36 | * | |
37 | * @param name the name of the property | |
38 | * @param propertyMap the property map the property should belong to | |
39 | * | |
40 | * @throws IllegalArgumentException if name or propertyMap is <tt>null</tt> or name is empty (trim'd) string | |
41 | */ | |
42 | 12 | public CredentialProperty(final String name, final Map propertyMap) { |
43 | 12 | if (name == null) { |
44 | 1 | throw new IllegalArgumentException("The parameter named [name] was null."); |
45 | } | |
46 | 11 | if (propertyMap == null) { |
47 | 1 | throw new IllegalArgumentException("The parameter named [propertyMap] was null."); |
48 | } | |
49 | 10 | if (name.trim().length() == 0) { |
50 | 1 | throw new IllegalArgumentException("The parameter named [name] was an empty String."); |
51 | } | |
52 | ||
53 | 9 | this.name = name; |
54 | 9 | this.propertyMap = propertyMap; |
55 | 9 | } |
56 | ||
57 | /** | |
58 | * This method sets the value of the <tt>value</tt> attribute, which represents the value of the property. This | |
59 | * method adds property to the property map. | |
60 | * | |
61 | * @param value the value of the property to be set | |
62 | * | |
63 | * @throws BuildException in case a property with the same name has already been specified before | |
64 | */ | |
65 | public void setValue(final String value) { | |
66 | 4 | if (propertyMap.containsKey(name)) { |
67 | 1 | throw new BuildException( |
68 | "Duplicate name: The credentials property with the name [" + name + "] existed more than once."); | |
69 | } | |
70 | ||
71 | // as of https://software.topcoder.com/forum/c_forum_message.jsp?f=20015788&r=21577871 | |
72 | // empty string is a valid value | |
73 | 3 | propertyMap.put(name, value); |
74 | 3 | } |
75 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |