Coverage details for com.topcoder.testframework.CredentialProperty

LineHitsSource
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      */
4212    public CredentialProperty(final String name, final Map propertyMap) {
4312        if (name == null) {
441            throw new IllegalArgumentException("The parameter named [name] was null.");
45         }
4611        if (propertyMap == null) {
471            throw new IllegalArgumentException("The parameter named [propertyMap] was null.");
48         }
4910        if (name.trim().length() == 0) {
501            throw new IllegalArgumentException("The parameter named [name] was an empty String.");
51         }
52  
539        this.name = name;
549        this.propertyMap = propertyMap;
559    }
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) {
664        if (propertyMap.containsKey(name)) {
671            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
733        propertyMap.put(name, value);
743    }
75 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.