Coverage Report - org.kuali.rice.shareddata.api.country.Country
 
Classes in this File Line Coverage Branch Coverage Complexity
Country
0%
0/27
N/A
1.074
Country$1
N/A
N/A
1.074
Country$Builder
0%
0/33
0%
0/2
1.074
Country$Constants
0%
0/2
N/A
1.074
Country$Elements
0%
0/1
N/A
1.074
 
 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.shareddata.api.country;
 18  
 
 19  
 import java.io.Serializable;
 20  
 import java.util.Collection;
 21  
 
 22  
 import javax.xml.bind.annotation.XmlAccessType;
 23  
 import javax.xml.bind.annotation.XmlAccessorType;
 24  
 import javax.xml.bind.annotation.XmlAnyElement;
 25  
 import javax.xml.bind.annotation.XmlElement;
 26  
 import javax.xml.bind.annotation.XmlRootElement;
 27  
 import javax.xml.bind.annotation.XmlType;
 28  
 
 29  
 import org.apache.commons.lang.StringUtils;
 30  
 import org.apache.commons.lang.builder.EqualsBuilder;
 31  
 import org.apache.commons.lang.builder.HashCodeBuilder;
 32  
 import org.apache.commons.lang.builder.ToStringBuilder;
 33  
 import org.kuali.rice.core.api.CoreConstants;
 34  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 35  
 import org.kuali.rice.core.api.mo.ModelObjectComplete;
 36  
 import org.w3c.dom.Element;
 37  
 
 38  
 /**
 39  
  * POJO implementation of CountryContract that is immutable. Instances of Country can be (un)marshalled to and from XML.
 40  
  *
 41  
  * @see CountryContract
 42  
  */
 43  
 @XmlRootElement(name = Country.Constants.ROOT_ELEMENT_NAME)
 44  
 @XmlAccessorType(XmlAccessType.NONE)
 45  
 @XmlType(name = Country.Constants.TYPE_NAME, propOrder = {
 46  
         Country.Elements.CODE,
 47  
         Country.Elements.ALTERNATE_CODE,
 48  
         Country.Elements.NAME,
 49  
         Country.Elements.RESTRICTED,
 50  
         Country.Elements.ACTIVE,
 51  
         CoreConstants.CommonElements.VERSION_NUMBER,
 52  
         CoreConstants.CommonElements.FUTURE_ELEMENTS
 53  
 })
 54  0
 public final class Country implements CountryContract, ModelObjectComplete {
 55  
     private static final long serialVersionUID = -8975392777320033940L;
 56  
 
 57  
     @XmlElement(name = Elements.CODE, required = true)
 58  
     private final String code;
 59  
 
 60  
     @XmlElement(name = Elements.ALTERNATE_CODE, required = false)
 61  
     private final String alternateCode;
 62  
 
 63  
     @XmlElement(name = Elements.NAME, required = false)
 64  
     private final String name;
 65  
 
 66  
     @XmlElement(name = Elements.RESTRICTED, required = true)
 67  
     private final boolean restricted;
 68  
 
 69  
     @XmlElement(name = Elements.ACTIVE, required = true)
 70  
     private final boolean active;
 71  
 
 72  
     @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
 73  
     private final Long versionNumber;
 74  
 
 75  0
     @SuppressWarnings("unused")
 76  
     @XmlAnyElement
 77  
     private final Collection<Element> _futureElements = null;
 78  
 
 79  
     /**
 80  
      * This constructor should never be called except during JAXB unmarshalling.
 81  
      */
 82  
     @SuppressWarnings("unused")
 83  0
     private Country() {
 84  0
         this.code = null;
 85  0
         this.alternateCode = null;
 86  0
         this.name = null;
 87  0
         this.restricted = false;
 88  0
         this.active = false;
 89  0
         this.versionNumber = null;
 90  0
     }
 91  
 
 92  0
     private Country(Builder builder) {
 93  0
         this.code = builder.getCode();
 94  0
         this.alternateCode = builder.getAlternateCode();
 95  0
         this.name = builder.getName();
 96  0
         this.restricted = builder.isRestricted();
 97  0
         this.active = builder.isActive();
 98  0
         this.versionNumber = builder.getVersionNumber();
 99  0
     }
 100  
 
 101  
     @Override
 102  
     public String getCode() {
 103  0
         return this.code;
 104  
     }
 105  
 
 106  
     @Override
 107  
     public String getAlternateCode() {
 108  0
         return this.alternateCode;
 109  
     }
 110  
 
 111  
     @Override
 112  
     public String getName() {
 113  0
         return this.name;
 114  
     }
 115  
 
 116  
     @Override
 117  
     public boolean isActive() {
 118  0
         return this.active;
 119  
     }
 120  
 
 121  
     @Override
 122  
     public boolean isRestricted() {
 123  0
         return this.restricted;
 124  
     }
 125  
 
 126  
     @Override
 127  
     public Long getVersionNumber() {
 128  0
         return this.versionNumber;
 129  
     }
 130  
 
 131  
     @Override
 132  
     public int hashCode() {
 133  0
         return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 134  
     }
 135  
 
 136  
     @Override
 137  
     public boolean equals(Object obj) {
 138  0
         return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 139  
     }
 140  
 
 141  
     @Override
 142  
     public String toString() {
 143  0
         return ToStringBuilder.reflectionToString(this);
 144  
     }
 145  
 
 146  
     /**
 147  
      * Builder for immutable Country objects.
 148  
      */
 149  0
     public static class Builder implements CountryContract, ModelBuilder, Serializable {
 150  
         private static final long serialVersionUID = -4786917485397379322L;
 151  
 
 152  
         private String code;
 153  
         private String alternateCode;
 154  
         private String name;
 155  
         private boolean restricted;
 156  
         private boolean active;
 157  
         private Long versionNumber;
 158  
 
 159  
         private Builder(String code, String alternateCode, String name,
 160  0
                         boolean restricted, boolean active) {
 161  0
             this.setCode(code);
 162  0
             this.setAlternateCode(alternateCode);
 163  0
             this.setName(name);
 164  0
             this.setRestricted(restricted);
 165  0
             this.setActive(active);
 166  0
         }
 167  
 
 168  
         public static Builder create(String code, String alternatePostalCode, String name,
 169  
                                      boolean restricted, boolean active) {
 170  0
             return new Builder(code, alternatePostalCode, name, restricted, active);
 171  
         }
 172  
 
 173  
         public static Builder create(CountryContract cc) {
 174  0
             Builder builder = new Builder(cc.getCode(), cc.getAlternateCode(),
 175  
                     cc.getName(), cc.isRestricted(), cc.isActive());
 176  0
             builder.setVersionNumber(cc.getVersionNumber());
 177  0
             return builder;
 178  
         }
 179  
 
 180  
         @Override
 181  
         public Country build() {
 182  0
             return new Country(this);
 183  
         }
 184  
 
 185  
         /**
 186  
          * Sets code property.
 187  
          *
 188  
          * @param code required to be not null and not empty.
 189  
          */
 190  
         public void setCode(String code) {
 191  0
             if (StringUtils.isBlank(code)) {
 192  0
                 throw new IllegalArgumentException("code cannot be blank or null");
 193  
             }
 194  0
             this.code = code;
 195  0
         }
 196  
 
 197  
         @Override
 198  
         public String getCode() {
 199  0
             return this.code;
 200  
         }
 201  
 
 202  
         /**
 203  
          * Sets the optional alternatePostalCode property
 204  
          *
 205  
          * @param alternatePostalCode
 206  
          */
 207  
         public void setAlternateCode(String alternatePostalCode) {
 208  0
             this.alternateCode = alternatePostalCode;
 209  0
         }
 210  
 
 211  
         @Override
 212  
         public String getAlternateCode() {
 213  0
             return this.alternateCode;
 214  
         }
 215  
 
 216  
         /**
 217  
          * Sets the optional name property.
 218  
          *
 219  
          * @param name
 220  
          */
 221  
         public void setName(String name) {
 222  0
             this.name = name;
 223  0
         }
 224  
 
 225  
         @Override
 226  
         public String getName() {
 227  0
             return this.name;
 228  
         }
 229  
 
 230  
         /**
 231  
          * Sets the active property.
 232  
          *
 233  
          * @param active
 234  
          */
 235  
         public void setActive(boolean active) {
 236  0
             this.active = active;
 237  0
         }
 238  
 
 239  
         @Override
 240  
         public boolean isActive() {
 241  0
             return this.active;
 242  
         }
 243  
 
 244  
         /**
 245  
          * Sets the versionNumber property.
 246  
          *
 247  
          * @param versionNumber
 248  
          */
 249  
         public void setVersionNumber(Long versionNumber) {
 250  0
             this.versionNumber = versionNumber;
 251  0
         }
 252  
 
 253  
         @Override
 254  
         public Long getVersionNumber() {
 255  0
             return this.versionNumber;
 256  
         }
 257  
 
 258  
         /**
 259  
          * Sets the restrictedProperty
 260  
          *
 261  
          * @param restricted
 262  
          */
 263  
         public void setRestricted(boolean restricted) {
 264  0
             this.restricted = restricted;
 265  0
         }
 266  
 
 267  
         @Override
 268  
         public boolean isRestricted() {
 269  0
             return this.restricted;
 270  
         }
 271  
     }
 272  
 
 273  
     /**
 274  
      * A private class which exposes constants which define the XML element names to use
 275  
      * when this object is marshalled to XML.
 276  
      */
 277  0
     static class Elements {
 278  
         final static String CODE = "code";
 279  
         final static String ALTERNATE_CODE = "alternateCode";
 280  
         final static String NAME = "name";
 281  
         final static String RESTRICTED = "restricted";
 282  
         final static String ACTIVE = "active";
 283  
     }
 284  
 
 285  
     /**
 286  
      * Defines some internal constants used on this class.
 287  
      */
 288  0
     static class Constants {
 289  
         final static String ROOT_ELEMENT_NAME = "country";
 290  
         final static String TYPE_NAME = "CountryType";
 291  0
         final static String[] HASH_CODE_EQUALS_EXCLUDE = {CoreConstants.CommonElements.FUTURE_ELEMENTS};
 292  
     }
 293  
 }