Coverage Report - org.kuali.rice.kew.api.repository.type.KewAttributeDefinition
 
Classes in this File Line Coverage Branch Coverage Complexity
KewAttributeDefinition
0%
0/30
N/A
1.281
KewAttributeDefinition$1
N/A
N/A
1.281
KewAttributeDefinition$Builder
0%
0/52
0%
0/10
1.281
KewAttributeDefinition$Constants
0%
0/1
N/A
1.281
KewAttributeDefinition$Elements
0%
0/1
N/A
1.281
 
 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.kew.api.repository.type;
 17  
 
 18  
 import java.io.Serializable;
 19  
 import java.util.Collection;
 20  
 
 21  
 import javax.xml.bind.annotation.XmlAccessType;
 22  
 import javax.xml.bind.annotation.XmlAccessorType;
 23  
 import javax.xml.bind.annotation.XmlAnyElement;
 24  
 import javax.xml.bind.annotation.XmlElement;
 25  
 import javax.xml.bind.annotation.XmlRootElement;
 26  
 import javax.xml.bind.annotation.XmlType;
 27  
 
 28  
 import org.apache.commons.lang.StringUtils;
 29  
 import org.kuali.rice.core.api.CoreConstants;
 30  
 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
 31  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 32  
 
 33  
 /**
 34  
  * Concrete model object implementation of KEW KewAttributeDefinition. 
 35  
  * immutable. 
 36  
  * Instances of KewAttributeDefinition can be (un)marshalled to and from XML.
 37  
  *
 38  
  * @see KewAttributeDefinitionContract
 39  
  */
 40  
 @XmlRootElement(name = KewAttributeDefinition.Constants.ROOT_ELEMENT_NAME)
 41  
 @XmlAccessorType(XmlAccessType.NONE)
 42  
 @XmlType(name = KewAttributeDefinition.Constants.TYPE_NAME, propOrder = {
 43  
                 KewAttributeDefinition.Elements.ID,
 44  
                 KewAttributeDefinition.Elements.NAME,
 45  
                 KewAttributeDefinition.Elements.NAMESPACE,
 46  
         KewAttributeDefinition.Elements.LABEL,
 47  
         KewAttributeDefinition.Elements.DESCRIPTION,
 48  
                 KewAttributeDefinition.Elements.ACTIVE,
 49  
                 KewAttributeDefinition.Elements.COMPONENT_NAME,
 50  
         CoreConstants.CommonElements.VERSION_NUMBER,
 51  
                 CoreConstants.CommonElements.FUTURE_ELEMENTS
 52  
 })
 53  0
 public final class KewAttributeDefinition extends AbstractDataTransferObject implements KewAttributeDefinitionContract {
 54  
         private static final long serialVersionUID = -6356968810972165031L;
 55  
         
 56  
         @XmlElement(name = Elements.ID, required=true)
 57  
         private final String id;
 58  
         @XmlElement(name = Elements.NAME, required=true)
 59  
         private final String name;
 60  
         @XmlElement(name = Elements.NAMESPACE, required=true)
 61  
         private final String namespace;
 62  
     @XmlElement(name = Elements.LABEL, required=false)
 63  
     private final String label;
 64  
     @XmlElement(name = Elements.DESCRIPTION, required=false)
 65  
     private final String description;
 66  
         @XmlElement(name = Elements.ACTIVE, required=false)
 67  
         private final boolean active;
 68  
         @XmlElement(name = Elements.COMPONENT_NAME, required=false)
 69  
         private final String componentName;
 70  
     @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
 71  
     private final Long versionNumber;
 72  
         
 73  0
         @SuppressWarnings("unused")
 74  
     @XmlAnyElement
 75  
     private final Collection<org.w3c.dom.Element> _futureElements = null;
 76  
         
 77  
          /** 
 78  
      * This constructor should never be called.  It is only present for use during JAXB unmarshalling. 
 79  
      */
 80  0
     private KewAttributeDefinition() {
 81  0
             this.id = null;
 82  0
             this.name = null;
 83  0
             this.namespace = null;
 84  0
             this.label = null;
 85  0
         this.description = null;
 86  0
             this.active = false;
 87  0
             this.componentName = null;
 88  0
         this.versionNumber = null;
 89  0
     }
 90  
     
 91  
     /**
 92  
          * Constructs a KewAttributeDefinition from the given builder.  This constructor is private and should only
 93  
          * ever be invoked from the builder.
 94  
          * 
 95  
          * @param builder the Builder from which to construct the KewAttributeDefinition
 96  
          */
 97  0
     private KewAttributeDefinition(Builder builder) {
 98  0
         this.id = builder.getId();
 99  0
         this.name = builder.getName();
 100  0
         this.namespace = builder.getNamespace();
 101  0
         this.label = builder.getLabel();
 102  0
         this.description = builder.getDescription();
 103  0
         this.active = builder.isActive();
 104  0
         this.componentName = builder.getComponentName();
 105  0
         this.versionNumber = builder.getVersionNumber();
 106  0
     }
 107  
     
 108  
         public String getId() {
 109  0
                 return this.id;
 110  
         }
 111  
         
 112  
         public String getName() {
 113  0
                 return this.name;
 114  
         }
 115  
 
 116  
         public String getNamespace() {
 117  0
                 return this.namespace;
 118  
         }
 119  
 
 120  
         public String getLabel() {
 121  0
                 return this.label;
 122  
         }
 123  
 
 124  
     public String getDescription() {
 125  0
         return description;
 126  
     }
 127  
 
 128  
     public boolean isActive() {
 129  0
                 return this.active; 
 130  
         }
 131  
 
 132  
         public String getComponentName() {
 133  0
                 return this.componentName;
 134  
         }
 135  
         
 136  
     @Override
 137  
     public Long getVersionNumber() {
 138  0
         return versionNumber;
 139  
     }
 140  
         
 141  
         /**
 142  
      * This builder is used to construct instances of KewAttributeDefinition.  It enforces the constraints of the {@link KewAttributeDefinitionContract}.
 143  
      */
 144  0
     public static class Builder implements KewAttributeDefinitionContract, ModelBuilder, Serializable {                
 145  
                 private static final long serialVersionUID = -2110564370088779631L;
 146  
                 
 147  
                 private String id;
 148  
         private String name;
 149  
         private String namespace;
 150  
         private String label;
 151  
         private String description;
 152  
         private boolean active;
 153  
         private String componentName;
 154  
         private Long versionNumber;
 155  
 
 156  
                 /**
 157  
                  * Private constructor for creating a builder with all of it's required attributes.
 158  
                  */
 159  0
         private Builder(String id, String name, String namespace) {
 160  0
             setId(id);
 161  0
             setName(name);
 162  0
             setNamespace(namespace);
 163  0
                         setActive(true);
 164  0
         }
 165  
 
 166  
         public Builder label(String label){
 167  0
                 setLabel(label);
 168  0
                 return this;
 169  
         }
 170  
         public Builder componentName(String componentName){
 171  0
                 setComponentName(componentName);
 172  0
                 return this;
 173  
         }
 174  
         /**
 175  
          * Creates a builder from the given parameters.
 176  
          * 
 177  
          * @param id the KewAttributeDefinition id
 178  
          * @param name the KewAttributeDefinition name
 179  
          * @param namespace the KewAttributeDefinition namespace
 180  
          * @return an instance of the builder with the fields already populated
 181  
          * @throws IllegalArgumentException if the either the id, name or namespace is null or blank
 182  
          */
 183  
         public static Builder create(String id, String name, String namespace) {
 184  0
             return new Builder(id, name, namespace);
 185  
         }
 186  
 
 187  
         /**
 188  
          * Creates a builder by populating it with data from the given {@link KewAttributeDefinitionContract}.
 189  
          * 
 190  
          * @param contract the contract from which to populate this builder
 191  
          * @return an instance of the builder populated with data from the contract
 192  
          */
 193  
         public static Builder create(KewAttributeDefinitionContract contract) {
 194  0
                 if (contract == null) {
 195  0
                 throw new IllegalArgumentException("contract is null");
 196  
             }
 197  0
             Builder builder =  new Builder(contract.getId(), contract.getName(), contract.getNamespace());
 198  0
             builder.setActive(contract.isActive());
 199  0
             builder.setLabel(contract.getLabel());
 200  0
             builder.setDescription(contract.getDescription());
 201  0
             builder.setComponentName(contract.getComponentName());
 202  0
             builder.setVersionNumber(contract.getVersionNumber());
 203  0
             return builder;
 204  
         }
 205  
 
 206  
                 /**
 207  
                  * Sets the value of the id on this builder to the given value.
 208  
                  * 
 209  
                  * @param id the id value to set, must be null or non-blank
 210  
                  * @throws IllegalArgumentException if the id is non-null and blank
 211  
                  */
 212  
         public void setId(String id) {
 213  0
             if (null != id && StringUtils.isBlank(id)) {
 214  0
                 throw new IllegalArgumentException("id must be null or non-blank");
 215  
             }
 216  0
             this.id = id;
 217  0
         }
 218  
 
 219  
                 public void setName(String name) {
 220  0
             if (StringUtils.isBlank(name)) {
 221  0
                 throw new IllegalArgumentException("name is blank");
 222  
             }
 223  0
                         this.name = name;
 224  0
                 }
 225  
 
 226  
                 public void setNamespace(String namespace) {
 227  0
             if (StringUtils.isBlank(namespace)) {
 228  0
                 throw new IllegalArgumentException("namespace is blank");
 229  
             }
 230  0
                         this.namespace = namespace;
 231  0
                 }
 232  
                 
 233  
                 public void setLabel(String label) {
 234  0
                         this.label = label;
 235  0
                 }
 236  
 
 237  
         public void setDescription(String description) {
 238  0
             this.description = description;
 239  0
         }
 240  
 
 241  
 
 242  
                 public void setComponentName(String componentName) {
 243  0
                         this.componentName = componentName;
 244  0
                 }
 245  
                 
 246  
                 public void setActive(boolean active) {
 247  0
                         this.active = active;
 248  0
                 }
 249  
 
 250  
         public void setVersionNumber(Long versionNumber){
 251  0
             this.versionNumber = versionNumber;
 252  0
         }
 253  
         
 254  
                 @Override
 255  
                 public String getId() {
 256  0
                         return id;
 257  
                 }
 258  
 
 259  
                 @Override
 260  
                 public String getName() {
 261  0
                         return name;
 262  
                 }
 263  
 
 264  
                 @Override
 265  
                 public String getNamespace() {
 266  0
                         return namespace;
 267  
                 }
 268  
 
 269  
                 @Override
 270  
                 public String getComponentName() {
 271  0
                         return componentName;
 272  
                 }
 273  
 
 274  
                 @Override
 275  
                 public String getLabel() {
 276  0
                         return label;
 277  
                 }
 278  
 
 279  
         @Override
 280  
         public String getDescription() {
 281  0
             return description;
 282  
         }
 283  
 
 284  
         @Override
 285  
                 public boolean isActive() {
 286  0
                         return active;
 287  
                 }
 288  
 
 289  
         @Override
 290  
         public Long getVersionNumber() {
 291  0
             return versionNumber;
 292  
         }
 293  
 
 294  
                 /**
 295  
                  * Builds an instance of a CampusType based on the current state of the builder.
 296  
                  * 
 297  
                  * @return the fully-constructed CampusType
 298  
                  */
 299  
         @Override
 300  
         public KewAttributeDefinition build() {
 301  0
             return new KewAttributeDefinition(this);
 302  
         }
 303  
                 
 304  
     }
 305  
 
 306  
         /**
 307  
          * Defines some internal constants used on this class.
 308  
          */
 309  0
         static class Constants {
 310  
                 final static String ROOT_ELEMENT_NAME = "KewAttributeDefinition";
 311  
                 final static String TYPE_NAME = "KewAttributionDefinitionType";
 312  
         }
 313  
         
 314  
         /**
 315  
          * A private class which exposes constants which define the XML element names to use
 316  
          * when this object is marshalled to XML.
 317  
          */
 318  0
         public static class Elements {
 319  
                 final static String ID = "id";
 320  
                 final static String NAME = "name";
 321  
                 final static String NAMESPACE = "namespace";
 322  
                 final static String LABEL = "label";
 323  
         final static String DESCRIPTION = "description";
 324  
                 final static String COMPONENT_NAME = "componentName";
 325  
                 final static String ACTIVE = "active";
 326  
     }
 327  
 }