|  1 |     | 
   package org.kuali.rice.kim.api.entity.citizenship;  | 
  |  2 |     | 
     | 
  |  3 |     | 
   import org.apache.commons.lang.StringUtils;  | 
  |  4 |     | 
   import org.apache.commons.lang.builder.EqualsBuilder;  | 
  |  5 |     | 
   import org.apache.commons.lang.builder.HashCodeBuilder;  | 
  |  6 |     | 
   import org.apache.commons.lang.builder.ToStringBuilder;  | 
  |  7 |     | 
   import org.kuali.rice.core.api.CoreConstants;  | 
  |  8 |     | 
   import org.kuali.rice.core.api.mo.ModelBuilder;  | 
  |  9 |     | 
   import org.kuali.rice.core.api.mo.ModelObjectComplete;  | 
  |  10 |     | 
   import org.kuali.rice.core.util.jaxb.SqlTimestampAdapter;  | 
  |  11 |     | 
   import org.kuali.rice.kim.api.entity.Type;  | 
  |  12 |     | 
   import org.w3c.dom.Element;  | 
  |  13 |     | 
     | 
  |  14 |     | 
   import javax.xml.bind.annotation.XmlAccessType;  | 
  |  15 |     | 
   import javax.xml.bind.annotation.XmlAccessorType;  | 
  |  16 |     | 
   import javax.xml.bind.annotation.XmlAnyElement;  | 
  |  17 |     | 
   import javax.xml.bind.annotation.XmlElement;  | 
  |  18 |     | 
   import javax.xml.bind.annotation.XmlRootElement;  | 
  |  19 |     | 
   import javax.xml.bind.annotation.XmlType;  | 
  |  20 |     | 
   import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;  | 
  |  21 |     | 
   import java.io.Serializable;  | 
  |  22 |     | 
   import java.sql.Timestamp;  | 
  |  23 |     | 
   import java.util.Collection;  | 
  |  24 |     | 
     | 
  |  25 |    1 |    @XmlRootElement(name = EntityCitizenship.Constants.ROOT_ELEMENT_NAME)  | 
  |  26 |     | 
   @XmlAccessorType(XmlAccessType.NONE)  | 
  |  27 |     | 
   @XmlType(name = EntityCitizenship.Constants.TYPE_NAME, propOrder = { | 
  |  28 |     | 
       EntityCitizenship.Elements.ID,  | 
  |  29 |     | 
       EntityCitizenship.Elements.ENTITY_ID,  | 
  |  30 |     | 
       EntityCitizenship.Elements.STATUS,  | 
  |  31 |     | 
       EntityCitizenship.Elements.COUNTRY_CODE,  | 
  |  32 |     | 
       EntityCitizenship.Elements.START_DATE,  | 
  |  33 |     | 
       EntityCitizenship.Elements.END_DATE,  | 
  |  34 |     | 
       CoreConstants.CommonElements.VERSION_NUMBER,  | 
  |  35 |     | 
       CoreConstants.CommonElements.OBJECT_ID,  | 
  |  36 |     | 
       EntityCitizenship.Elements.ACTIVE,  | 
  |  37 |     | 
       CoreConstants.CommonElements.FUTURE_ELEMENTS  | 
  |  38 |     | 
   })  | 
  |  39 |    3 |    public final class EntityCitizenship  | 
  |  40 |     | 
       implements ModelObjectComplete, EntityCitizenshipContract  | 
  |  41 |     | 
   { | 
  |  42 |     | 
       @XmlElement(name = Elements.ID, required = false)  | 
  |  43 |     | 
       private final String id;  | 
  |  44 |     | 
       @XmlElement(name = Elements.ENTITY_ID, required = false)  | 
  |  45 |     | 
       private final String entityId;  | 
  |  46 |     | 
       @XmlElement(name = Elements.STATUS, required = false)  | 
  |  47 |     | 
       private final Type status;  | 
  |  48 |     | 
       @XmlElement(name = Elements.COUNTRY_CODE, required = false)  | 
  |  49 |     | 
       private final String countryCode;  | 
  |  50 |     | 
       @XmlJavaTypeAdapter(SqlTimestampAdapter.class)  | 
  |  51 |     | 
       @XmlElement(name = Elements.START_DATE, required = false)  | 
  |  52 |     | 
       private final Timestamp startDate;  | 
  |  53 |     | 
       @XmlJavaTypeAdapter(SqlTimestampAdapter.class)  | 
  |  54 |     | 
       @XmlElement(name = Elements.END_DATE, required = false)  | 
  |  55 |     | 
       private final Timestamp endDate;  | 
  |  56 |     | 
       @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)  | 
  |  57 |     | 
       private final Long versionNumber;  | 
  |  58 |     | 
       @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)  | 
  |  59 |     | 
       private final String objectId;  | 
  |  60 |     | 
       @XmlElement(name = Elements.ACTIVE, required = false)  | 
  |  61 |     | 
       private final boolean active;  | 
  |  62 |    5 |        @SuppressWarnings("unused") | 
  |  63 |     | 
       @XmlAnyElement  | 
  |  64 |     | 
       private final Collection<Element> _futureElements = null;  | 
  |  65 |     | 
     | 
  |  66 |     | 
         | 
  |  67 |     | 
     | 
  |  68 |     | 
     | 
  |  69 |     | 
     | 
  |  70 |    2 |        private EntityCitizenship() { | 
  |  71 |    2 |            this.status = null;  | 
  |  72 |    2 |            this.countryCode = null;  | 
  |  73 |    2 |            this.startDate = null;  | 
  |  74 |    2 |            this.endDate = null;  | 
  |  75 |    2 |            this.versionNumber = null;  | 
  |  76 |    2 |            this.objectId = null;  | 
  |  77 |    2 |            this.active = false;  | 
  |  78 |    2 |            this.id = null;  | 
  |  79 |    2 |            this.entityId = null;  | 
  |  80 |    2 |        }  | 
  |  81 |     | 
     | 
  |  82 |    3 |        private EntityCitizenship(Builder builder) { | 
  |  83 |    3 |            this.status = builder.getStatus() != null ? builder.getStatus().build() : null;  | 
  |  84 |    3 |            this.countryCode = builder.getCountryCode();  | 
  |  85 |    3 |            this.startDate = builder.getStartDate();  | 
  |  86 |    3 |            this.endDate = builder.getEndDate();  | 
  |  87 |    3 |            this.versionNumber = builder.getVersionNumber();  | 
  |  88 |    3 |            this.objectId = builder.getObjectId();  | 
  |  89 |    3 |            this.active = builder.isActive();  | 
  |  90 |    3 |            this.id = builder.getId();  | 
  |  91 |    3 |            this.entityId = builder.getEntityId();  | 
  |  92 |    3 |        }  | 
  |  93 |     | 
     | 
  |  94 |     | 
       @Override  | 
  |  95 |     | 
       public String getEntityId() { | 
  |  96 |    1 |            return this.entityId;  | 
  |  97 |     | 
       }  | 
  |  98 |     | 
     | 
  |  99 |     | 
       @Override  | 
  |  100 |     | 
       public Type getStatus() { | 
  |  101 |    1 |            return this.status;  | 
  |  102 |     | 
       }  | 
  |  103 |     | 
     | 
  |  104 |     | 
       @Override  | 
  |  105 |     | 
       public String getCountryCode() { | 
  |  106 |    1 |            return this.countryCode;  | 
  |  107 |     | 
       }  | 
  |  108 |     | 
     | 
  |  109 |     | 
       @Override  | 
  |  110 |     | 
       public Timestamp getStartDate() { | 
  |  111 |    1 |            return this.startDate;  | 
  |  112 |     | 
       }  | 
  |  113 |     | 
     | 
  |  114 |     | 
       @Override  | 
  |  115 |     | 
       public Timestamp getEndDate() { | 
  |  116 |    1 |            return this.endDate;  | 
  |  117 |     | 
       }  | 
  |  118 |     | 
     | 
  |  119 |     | 
       @Override  | 
  |  120 |     | 
       public Long getVersionNumber() { | 
  |  121 |    1 |            return this.versionNumber;  | 
  |  122 |     | 
       }  | 
  |  123 |     | 
     | 
  |  124 |     | 
       @Override  | 
  |  125 |     | 
       public String getObjectId() { | 
  |  126 |    1 |            return this.objectId;  | 
  |  127 |     | 
       }  | 
  |  128 |     | 
     | 
  |  129 |     | 
       @Override  | 
  |  130 |     | 
       public boolean isActive() { | 
  |  131 |    1 |            return this.active;  | 
  |  132 |     | 
       }  | 
  |  133 |     | 
     | 
  |  134 |     | 
       @Override  | 
  |  135 |     | 
       public String getId() { | 
  |  136 |    1 |            return this.id;  | 
  |  137 |     | 
       }  | 
  |  138 |     | 
     | 
  |  139 |     | 
       @Override  | 
  |  140 |     | 
       public int hashCode() { | 
  |  141 |    0 |            return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE);  | 
  |  142 |     | 
       }  | 
  |  143 |     | 
     | 
  |  144 |     | 
       @Override  | 
  |  145 |     | 
       public boolean equals(Object object) { | 
  |  146 |    3 |            return EqualsBuilder.reflectionEquals(object, this, Constants.HASH_CODE_EQUALS_EXCLUDE);  | 
  |  147 |     | 
       }  | 
  |  148 |     | 
     | 
  |  149 |     | 
       @Override  | 
  |  150 |     | 
       public String toString() { | 
  |  151 |    0 |            return ToStringBuilder.reflectionToString(this);  | 
  |  152 |     | 
       }  | 
  |  153 |     | 
     | 
  |  154 |     | 
     | 
  |  155 |     | 
         | 
  |  156 |     | 
     | 
  |  157 |     | 
     | 
  |  158 |     | 
     | 
  |  159 |    3 |        public final static class Builder  | 
  |  160 |     | 
           implements Serializable, ModelBuilder, EntityCitizenshipContract  | 
  |  161 |     | 
       { | 
  |  162 |     | 
           private String entityId;  | 
  |  163 |     | 
           private Type.Builder status;  | 
  |  164 |     | 
           private String countryCode;  | 
  |  165 |     | 
           private Timestamp startDate;  | 
  |  166 |     | 
           private Timestamp endDate;  | 
  |  167 |     | 
           private Long versionNumber;  | 
  |  168 |     | 
           private String objectId;  | 
  |  169 |     | 
           private boolean active;  | 
  |  170 |     | 
           private String id;  | 
  |  171 |     | 
     | 
  |  172 |    5 |            private Builder() { | 
  |  173 |    5 |            }  | 
  |  174 |     | 
     | 
  |  175 |     | 
           public static Builder create() { | 
  |  176 |    5 |                return new Builder();  | 
  |  177 |     | 
           }  | 
  |  178 |     | 
     | 
  |  179 |     | 
           public static Builder create(EntityCitizenshipContract contract) { | 
  |  180 |    2 |                if (contract == null) { | 
  |  181 |    0 |                    throw new IllegalArgumentException("contract was null"); | 
  |  182 |     | 
               }  | 
  |  183 |    2 |                Builder builder = create();  | 
  |  184 |    2 |                builder.setEntityId(contract.getEntityId());  | 
  |  185 |    2 |                if (contract.getStatus() != null) { | 
  |  186 |    1 |                    builder.setStatus(Type.Builder.create(contract.getStatus()));  | 
  |  187 |     | 
               }  | 
  |  188 |    2 |                builder.setCountryCode(contract.getCountryCode());  | 
  |  189 |    2 |                builder.setStartDate(contract.getStartDate());  | 
  |  190 |    2 |                builder.setEndDate(contract.getEndDate());  | 
  |  191 |    2 |                builder.setVersionNumber(contract.getVersionNumber());  | 
  |  192 |    2 |                builder.setObjectId(contract.getObjectId());  | 
  |  193 |    2 |                builder.setActive(contract.isActive());  | 
  |  194 |    2 |                builder.setId(contract.getId());  | 
  |  195 |    2 |                return builder;  | 
  |  196 |     | 
           }  | 
  |  197 |     | 
     | 
  |  198 |     | 
           public EntityCitizenship build() { | 
  |  199 |    3 |                return new EntityCitizenship(this);  | 
  |  200 |     | 
           }  | 
  |  201 |     | 
     | 
  |  202 |     | 
           @Override  | 
  |  203 |     | 
           public String getEntityId() { | 
  |  204 |    3 |                return this.entityId;  | 
  |  205 |     | 
           }  | 
  |  206 |     | 
     | 
  |  207 |     | 
           @Override  | 
  |  208 |     | 
           public Type.Builder getStatus() { | 
  |  209 |    4 |                return this.status;  | 
  |  210 |     | 
           }  | 
  |  211 |     | 
     | 
  |  212 |     | 
           @Override  | 
  |  213 |     | 
           public String getCountryCode() { | 
  |  214 |    3 |                return this.countryCode;  | 
  |  215 |     | 
           }  | 
  |  216 |     | 
     | 
  |  217 |     | 
           @Override  | 
  |  218 |     | 
           public Timestamp getStartDate() { | 
  |  219 |    3 |                return this.startDate;  | 
  |  220 |     | 
           }  | 
  |  221 |     | 
     | 
  |  222 |     | 
           @Override  | 
  |  223 |     | 
           public Timestamp getEndDate() { | 
  |  224 |    3 |                return this.endDate;  | 
  |  225 |     | 
           }  | 
  |  226 |     | 
     | 
  |  227 |     | 
           @Override  | 
  |  228 |     | 
           public Long getVersionNumber() { | 
  |  229 |    3 |                return this.versionNumber;  | 
  |  230 |     | 
           }  | 
  |  231 |     | 
     | 
  |  232 |     | 
           @Override  | 
  |  233 |     | 
           public String getObjectId() { | 
  |  234 |    3 |                return this.objectId;  | 
  |  235 |     | 
           }  | 
  |  236 |     | 
     | 
  |  237 |     | 
           @Override  | 
  |  238 |     | 
           public boolean isActive() { | 
  |  239 |    3 |                return this.active;  | 
  |  240 |     | 
           }  | 
  |  241 |     | 
     | 
  |  242 |     | 
           @Override  | 
  |  243 |     | 
           public String getId() { | 
  |  244 |    3 |                return this.id;  | 
  |  245 |     | 
           }  | 
  |  246 |     | 
     | 
  |  247 |     | 
           public void setEntityId(String entityId) { | 
  |  248 |    2 |                this.entityId = entityId;  | 
  |  249 |    2 |            }  | 
  |  250 |     | 
           public void setStatus(Type.Builder status) { | 
  |  251 |    1 |                this.status = status;  | 
  |  252 |    1 |            }  | 
  |  253 |     | 
     | 
  |  254 |     | 
           public void setCountryCode(String countryCode) { | 
  |  255 |    2 |                this.countryCode = countryCode;  | 
  |  256 |    2 |            }  | 
  |  257 |     | 
     | 
  |  258 |     | 
           public void setStartDate(Timestamp startDate) { | 
  |  259 |    2 |                this.startDate = startDate;  | 
  |  260 |    2 |            }  | 
  |  261 |     | 
     | 
  |  262 |     | 
           public void setEndDate(Timestamp endDate) { | 
  |  263 |    2 |                this.endDate = endDate;  | 
  |  264 |    2 |            }  | 
  |  265 |     | 
     | 
  |  266 |     | 
           public void setVersionNumber(Long versionNumber) { | 
  |  267 |    2 |                this.versionNumber = versionNumber;  | 
  |  268 |    2 |            }  | 
  |  269 |     | 
     | 
  |  270 |     | 
           public void setObjectId(String objectId) { | 
  |  271 |    2 |                this.objectId = objectId;  | 
  |  272 |    2 |            }  | 
  |  273 |     | 
     | 
  |  274 |     | 
           public void setActive(boolean active) { | 
  |  275 |    2 |                this.active = active;  | 
  |  276 |    2 |            }  | 
  |  277 |     | 
     | 
  |  278 |     | 
           public void setId(String id) { | 
  |  279 |    3 |                if (StringUtils.isWhitespace(id)) { | 
  |  280 |    1 |                    throw new IllegalArgumentException("id is blank"); | 
  |  281 |     | 
               }  | 
  |  282 |    2 |                this.id = id;  | 
  |  283 |    2 |            }  | 
  |  284 |     | 
     | 
  |  285 |     | 
       }  | 
  |  286 |     | 
     | 
  |  287 |     | 
     | 
  |  288 |     | 
         | 
  |  289 |     | 
     | 
  |  290 |     | 
     | 
  |  291 |     | 
     | 
  |  292 |    0 |        static class Constants { | 
  |  293 |     | 
     | 
  |  294 |     | 
           final static String ROOT_ELEMENT_NAME = "entityCitizenship";  | 
  |  295 |     | 
           final static String TYPE_NAME = "EntityCitizenshipType";  | 
  |  296 |    1 |            final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[] {CoreConstants.CommonElements.FUTURE_ELEMENTS }; | 
  |  297 |     | 
     | 
  |  298 |     | 
       }  | 
  |  299 |     | 
     | 
  |  300 |     | 
     | 
  |  301 |     | 
         | 
  |  302 |     | 
     | 
  |  303 |     | 
     | 
  |  304 |     | 
     | 
  |  305 |    0 |        static class Elements { | 
  |  306 |     | 
           final static String ENTITY_ID = "entityId";  | 
  |  307 |     | 
           final static String STATUS = "status";  | 
  |  308 |     | 
           final static String COUNTRY_CODE = "countryCode";  | 
  |  309 |     | 
           final static String START_DATE = "startDate";  | 
  |  310 |     | 
           final static String END_DATE = "endDate";  | 
  |  311 |     | 
           final static String ACTIVE = "active";  | 
  |  312 |     | 
           final static String ID = "id";  | 
  |  313 |     | 
     | 
  |  314 |     | 
       }  | 
  |  315 |     | 
     | 
  |  316 |     | 
   }  |