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