Coverage Report - org.kuali.rice.core.api.parameter.ParameterKey
 
Classes in this File Line Coverage Branch Coverage Complexity
ParameterKey
84%
22/26
100%
8/8
2.143
ParameterKey$Constants
0%
0/1
N/A
2.143
ParameterKey$Elements
0%
0/1
N/A
2.143
 
 1  
 /*
 2  
  * Copyright 2006-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
 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  
 
 17  
 package org.kuali.rice.core.api.parameter;
 18  
 
 19  
 import org.apache.commons.lang.StringUtils;
 20  
 import org.kuali.rice.core.api.CoreConstants;
 21  
 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
 22  
 import org.w3c.dom.Element;
 23  
 
 24  
 import javax.xml.bind.annotation.XmlAccessType;
 25  
 import javax.xml.bind.annotation.XmlAccessorType;
 26  
 import javax.xml.bind.annotation.XmlAnyElement;
 27  
 import javax.xml.bind.annotation.XmlElement;
 28  
 import javax.xml.bind.annotation.XmlRootElement;
 29  
 import javax.xml.bind.annotation.XmlType;
 30  
 import java.util.Collection;
 31  
 
 32  
 /**
 33  
 *  This class represents the 4-part key which uniquely identifies a parameter.
 34  
 *  
 35  
 *  @see ParameterContract
 36  
 *  @see Parameter
 37  
 */
 38  
 @XmlRootElement(name = ParameterKey.Constants.ROOT_ELEMENT_NAME)
 39  
 @XmlAccessorType(XmlAccessType.NONE)
 40  
 @XmlType(name = ParameterKey.Constants.TYPE_NAME, propOrder = {
 41  
     ParameterKey.Elements.APPLICATION_ID,
 42  
     ParameterKey.Elements.NAMESPACE_CODE,
 43  
     ParameterKey.Elements.COMPONENT_CODE,
 44  
     ParameterKey.Elements.NAME,
 45  
     CoreConstants.CommonElements.FUTURE_ELEMENTS
 46  
 })
 47  
 public final class ParameterKey extends AbstractDataTransferObject {
 48  
 
 49  
         private static final long serialVersionUID = -4405355319548951283L;
 50  
 
 51  
         @XmlElement(name = Elements.APPLICATION_ID, required=true)
 52  
         private final String applicationId;
 53  
 
 54  
         @XmlElement(name = Elements.NAMESPACE_CODE, required=true)
 55  
         private final String namespaceCode;
 56  
 
 57  
         @XmlElement(name = Elements.COMPONENT_CODE, required=true)
 58  
         private final String componentCode;
 59  
         
 60  
     @XmlElement(name = Elements.NAME, required=true)
 61  
     private final String name;
 62  
 
 63  17
     @SuppressWarnings("unused")
 64  
         @XmlAnyElement
 65  
     private final Collection<Element> _futureElements = null;
 66  
 
 67  
     /** 
 68  
      * This constructor should never be called except during JAXB unmarshalling. 
 69  
      */
 70  2
     private ParameterKey() {
 71  2
             this.applicationId = null;
 72  2
             this.namespaceCode = null;
 73  2
             this.componentCode = null;
 74  2
             this.name = null;
 75  2
     }
 76  
 
 77  
         /**
 78  
          * Constructs a ParameterKey from the given values.
 79  
          */
 80  15
     private ParameterKey(String applicationId, String namespaceCode, String componentCode, String name) {
 81  15
         if (StringUtils.isBlank(applicationId)) {
 82  4
             throw new IllegalArgumentException("applicationId is blank");
 83  
         }
 84  11
         if (StringUtils.isBlank(namespaceCode)) {
 85  3
             throw new IllegalArgumentException("namespaceCode is blank");
 86  
         }
 87  8
         if (StringUtils.isBlank(componentCode)) {
 88  3
             throw new IllegalArgumentException("componentCode is blank");
 89  
         }
 90  5
                 if (StringUtils.isBlank(name)) {
 91  3
                         throw new IllegalArgumentException("name is blank");
 92  
                 }
 93  2
         this.applicationId = applicationId;
 94  2
         this.namespaceCode = namespaceCode;
 95  2
         this.componentCode = componentCode;
 96  2
                 this.name = name;
 97  2
     }
 98  
 
 99  
     /**
 100  
      * Creates a ParameterKey from the given required values.
 101  
      * 
 102  
      * @param applicationId the application id, cannot be null or blank
 103  
      * @param namespaceCode the namespace code, cannot be null or blank
 104  
      * @param componentCode the component code, cannot be null or blank
 105  
          * @param name the parameter name, cannot be null or blank
 106  
      * @return the fully-constructed ParameterKey
 107  
      * @throws IllegalArgumentException if any arguments are null or blank
 108  
      */
 109  
     public static ParameterKey create(String applicationId, String namespaceCode, String componentCode, String name) {
 110  15
         return new ParameterKey(applicationId, namespaceCode, componentCode, name);
 111  
     }
 112  
         
 113  
     public String getApplicationId() {
 114  0
                 return applicationId;
 115  
         }
 116  
 
 117  
         public String getNamespaceCode() {
 118  0
                 return namespaceCode;
 119  
         }
 120  
 
 121  
         public String getComponentCode() {
 122  0
                 return componentCode;
 123  
         }
 124  
 
 125  
         public String getName() {
 126  0
                 return name;
 127  
         }
 128  
     
 129  
         /**
 130  
          * Defines some internal constants used on this class.
 131  
          */
 132  0
         static class Constants {
 133  
                 final static String ROOT_ELEMENT_NAME = "parameterKey";
 134  
                 final static String TYPE_NAME = "ParameterKeyType";
 135  
         }
 136  
   
 137  
         /**
 138  
          * A private class which exposes constants which define the XML element names to use
 139  
          * when this object is marshalled to XML.
 140  
          */
 141  0
         static class Elements {
 142  
                 final static String APPLICATION_ID = "applicationId";
 143  
                 final static String NAMESPACE_CODE = "namespaceCode";
 144  
                 final static String COMPONENT_CODE = "componentCode";
 145  
                 final static String NAME = "name";
 146  
         }
 147  
   
 148  
 }