Coverage Report - org.kuali.rice.kew.api.doctype.RouteNode
 
Classes in this File Line Coverage Branch Coverage Complexity
RouteNode
0%
0/60
0%
0/4
1.263
RouteNode$1
N/A
N/A
1.263
RouteNode$Builder
0%
0/91
0%
0/14
1.263
RouteNode$Constants
0%
0/2
N/A
1.263
RouteNode$Elements
0%
0/1
N/A
1.263
 
 1  
 package org.kuali.rice.kew.api.doctype;
 2  
 
 3  
 import java.io.Serializable;
 4  
 import java.util.ArrayList;
 5  
 import java.util.Collection;
 6  
 import java.util.List;
 7  
 
 8  
 import javax.xml.bind.annotation.XmlAccessType;
 9  
 import javax.xml.bind.annotation.XmlAccessorType;
 10  
 import javax.xml.bind.annotation.XmlAnyElement;
 11  
 import javax.xml.bind.annotation.XmlElement;
 12  
 import javax.xml.bind.annotation.XmlElementWrapper;
 13  
 import javax.xml.bind.annotation.XmlRootElement;
 14  
 import javax.xml.bind.annotation.XmlType;
 15  
 
 16  
 import org.apache.commons.lang.StringUtils;
 17  
 import org.apache.commons.lang.builder.EqualsBuilder;
 18  
 import org.apache.commons.lang.builder.HashCodeBuilder;
 19  
 import org.apache.commons.lang.builder.ToStringBuilder;
 20  
 import org.kuali.rice.core.api.CoreConstants;
 21  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 22  
 import org.kuali.rice.core.api.mo.ModelObjectComplete;
 23  
 import org.kuali.rice.core.util.CollectionUtils;
 24  
 import org.w3c.dom.Element;
 25  
 
 26  
 @XmlRootElement(name = RouteNode.Constants.ROOT_ELEMENT_NAME)
 27  
 @XmlAccessorType(XmlAccessType.NONE)
 28  
 @XmlType(name = RouteNode.Constants.TYPE_NAME, propOrder = {
 29  
         RouteNode.Elements.ID,
 30  
         RouteNode.Elements.DOCUMENT_TYPE_ID,
 31  
         RouteNode.Elements.NAME,
 32  
         RouteNode.Elements.ROUTE_METHOD_NAME,
 33  
         RouteNode.Elements.ROUTE_METHOD_CODE,
 34  
         RouteNode.Elements.FINAL_APPROVAL,
 35  
         RouteNode.Elements.MANDATORY,
 36  
         RouteNode.Elements.ACTIVATION_TYPE,
 37  
         RouteNode.Elements.EXCEPTION_GROUP_ID,
 38  
         RouteNode.Elements.TYPE,
 39  
         RouteNode.Elements.BRANCH_NAME,
 40  
         RouteNode.Elements.NEXT_DOCUMENT_STATUS,
 41  
         RouteNode.Elements.CONFIGURATION_PARAMETERS,
 42  
         RouteNode.Elements.PREVIOUS_NODE_IDS,
 43  
         RouteNode.Elements.NEXT_NODE_IDS,
 44  
         CoreConstants.CommonElements.VERSION_NUMBER,
 45  
         CoreConstants.CommonElements.FUTURE_ELEMENTS
 46  
 })
 47  0
 public final class RouteNode implements ModelObjectComplete, RouteNodeContract {
 48  
 
 49  
     private static final long serialVersionUID = -1756380702013287285L;
 50  
 
 51  
     @XmlElement(name = Elements.ID, required = false)
 52  
     private final String id;
 53  
 
 54  
     @XmlElement(name = Elements.DOCUMENT_TYPE_ID, required = false)
 55  
     private final String documentTypeId;
 56  
 
 57  
     @XmlElement(name = Elements.NAME, required = true)
 58  
     private final String name;
 59  
 
 60  
     @XmlElement(name = Elements.ROUTE_METHOD_NAME, required = false)
 61  
     private final String routeMethodName;
 62  
 
 63  
     @XmlElement(name = Elements.ROUTE_METHOD_CODE, required = false)
 64  
     private final String routeMethodCode;
 65  
 
 66  
     @XmlElement(name = Elements.FINAL_APPROVAL, required = false)
 67  
     private final boolean finalApproval;
 68  
 
 69  
     @XmlElement(name = Elements.MANDATORY, required = false)
 70  
     private final boolean mandatory;
 71  
 
 72  
     @XmlElement(name = Elements.ACTIVATION_TYPE, required = false)
 73  
     private final String activationType;
 74  
 
 75  
     @XmlElement(name = Elements.EXCEPTION_GROUP_ID, required = false)
 76  
     private final String exceptionGroupId;
 77  
 
 78  
     @XmlElement(name = Elements.TYPE, required = true)
 79  
     private final String type;
 80  
 
 81  
     @XmlElement(name = Elements.BRANCH_NAME, required = false)
 82  
     private final String branchName;
 83  
     
 84  
     @XmlElement(name = Elements.NEXT_DOCUMENT_STATUS, required = false)
 85  
     private final String nextDocumentStatus;
 86  
     
 87  
     @XmlElementWrapper(name = Elements.CONFIGURATION_PARAMETERS, required = false)
 88  
     @XmlElement(name = Elements.CONFIGURATION_PARAMETER, required = false)
 89  
     private final List<RouteNodeConfigurationParameter> configurationParameters;
 90  
 
 91  
     @XmlElementWrapper(name = Elements.PREVIOUS_NODE_IDS, required = false)
 92  
     @XmlElement(name = Elements.PREVIOUS_NODE_ID, required = false)
 93  
     private final List<String> previousNodeIds;
 94  
 
 95  
     @XmlElementWrapper(name = Elements.NEXT_NODE_IDS, required = false)
 96  
     @XmlElement(name = Elements.NEXT_NODE_ID, required = false)
 97  
     private final List<String> nextNodeIds;
 98  
     
 99  
     @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
 100  
     private final Long versionNumber;
 101  
 
 102  0
     @SuppressWarnings("unused")
 103  
     @XmlAnyElement
 104  
     private final Collection<Element> _futureElements = null;
 105  
 
 106  
     /**
 107  
      * Private constructor used only by JAXB.
 108  
      */
 109  0
     private RouteNode() {
 110  0
         this.id = null;
 111  0
         this.documentTypeId = null;
 112  0
         this.name = null;
 113  0
         this.routeMethodName = null;
 114  0
         this.routeMethodCode = null;
 115  0
         this.finalApproval = false;
 116  0
         this.mandatory = false;
 117  0
         this.activationType = null;
 118  0
         this.exceptionGroupId = null;
 119  0
         this.type = null;
 120  0
         this.branchName = null;
 121  0
         this.nextDocumentStatus = null;
 122  0
         this.configurationParameters = null;
 123  0
         this.previousNodeIds = null;
 124  0
         this.nextNodeIds = null;
 125  0
         this.versionNumber = null;
 126  0
     }
 127  
 
 128  0
     private RouteNode(Builder builder) {
 129  0
         this.id = builder.getId();
 130  0
         this.documentTypeId = builder.getDocumentTypeId();
 131  0
         this.name = builder.getName();
 132  0
         this.routeMethodName = builder.getRouteMethodName();
 133  0
         this.routeMethodCode = builder.getRouteMethodCode();
 134  0
         this.finalApproval = builder.isFinalApproval();
 135  0
         this.mandatory = builder.isMandatory();
 136  0
         this.activationType = builder.getActivationType();
 137  0
         this.exceptionGroupId = builder.getExceptionGroupId();
 138  0
         this.type = builder.getType();
 139  0
         this.branchName = builder.getBranchName();
 140  0
         this.nextDocumentStatus = builder.getNextDocumentStatus();
 141  0
         this.configurationParameters = new ArrayList<RouteNodeConfigurationParameter>();
 142  0
         if (builder.getConfigurationParameters() != null) {
 143  0
             for (RouteNodeConfigurationParameter.Builder configurationParameter : builder.getConfigurationParameters()) {
 144  0
                 this.configurationParameters.add(configurationParameter.build());
 145  
             }
 146  
         }
 147  0
         this.previousNodeIds = new ArrayList<String>(builder.getPreviousNodeIds());
 148  0
         this.nextNodeIds = new ArrayList<String>(builder.getNextNodeIds());
 149  0
         this.versionNumber = builder.getVersionNumber();
 150  0
     }
 151  
 
 152  
     @Override
 153  
     public String getId() {
 154  0
         return this.id;
 155  
     }
 156  
 
 157  
     @Override
 158  
     public String getName() {
 159  0
         return this.name;
 160  
     }
 161  
 
 162  
     @Override
 163  
     public String getDocumentTypeId() {
 164  0
         return this.documentTypeId;
 165  
     }
 166  
 
 167  
     @Override
 168  
     public String getRouteMethodName() {
 169  0
         return this.routeMethodName;
 170  
     }
 171  
 
 172  
     @Override
 173  
     public String getRouteMethodCode() {
 174  0
         return this.routeMethodCode;
 175  
     }
 176  
 
 177  
     @Override
 178  
     public boolean isFinalApproval() {
 179  0
         return this.finalApproval;
 180  
     }
 181  
 
 182  
     @Override
 183  
     public boolean isMandatory() {
 184  0
         return this.mandatory;
 185  
     }
 186  
 
 187  
     @Override
 188  
     public String getActivationType() {
 189  0
         return this.activationType;
 190  
     }
 191  
 
 192  
     @Override
 193  
     public String getExceptionGroupId() {
 194  0
         return this.exceptionGroupId;
 195  
     }
 196  
 
 197  
     @Override
 198  
     public String getType() {
 199  0
         return this.type;
 200  
     }
 201  
 
 202  
     @Override
 203  
     public String getBranchName() {
 204  0
         return this.branchName;
 205  
     }
 206  
 
 207  
     @Override
 208  
     public String getNextDocumentStatus() {
 209  0
         return this.nextDocumentStatus;
 210  
     }
 211  
 
 212  
     @Override
 213  
     public List<RouteNodeConfigurationParameter> getConfigurationParameters() {
 214  0
         return CollectionUtils.unmodifiableListNullSafe(this.configurationParameters);
 215  
     }
 216  
 
 217  
     @Override
 218  
     public List<String> getPreviousNodeIds() {
 219  0
         return CollectionUtils.unmodifiableListNullSafe(this.previousNodeIds);
 220  
     }
 221  
 
 222  
     @Override
 223  
     public List<String> getNextNodeIds() {
 224  0
         return CollectionUtils.unmodifiableListNullSafe(this.nextNodeIds);
 225  
     }
 226  
 
 227  
     @Override
 228  
     public Long getVersionNumber() {
 229  0
         return this.versionNumber;
 230  
     }
 231  
 
 232  
     @Override
 233  
     public int hashCode() {
 234  0
         return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 235  
     }
 236  
 
 237  
     @Override
 238  
     public boolean equals(Object object) {
 239  0
         return EqualsBuilder.reflectionEquals(object, this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 240  
     }
 241  
 
 242  
     @Override
 243  
     public String toString() {
 244  0
         return ToStringBuilder.reflectionToString(this);
 245  
     }
 246  
 
 247  
     /**
 248  
      * A builder which can be used to construct {@link RouteNode} instances. Enforces the
 249  
      * constraints of the {@link RouteNodeContract}.
 250  
      */
 251  0
     public final static class Builder implements Serializable, ModelBuilder, RouteNodeContract {
 252  
 
 253  
         private static final long serialVersionUID = 7076065049417371344L;
 254  
         private String id;
 255  
         private String documentTypeId;
 256  
         private String name;
 257  
         private String routeMethodName;
 258  
         private String routeMethodCode;
 259  
         private boolean finalApproval;
 260  
         private boolean mandatory;
 261  
         private String activationType;
 262  
         private String exceptionGroupId;
 263  
         private String type;
 264  
         private String branchName;
 265  
         private String nextDocumentStatus;
 266  
         private List<RouteNodeConfigurationParameter.Builder> configurationParameters;
 267  
         private List<String> previousNodeIds;
 268  
         private List<String> nextNodeIds;
 269  
         private Long versionNumber;
 270  
 
 271  0
         private Builder(String name, String type) {
 272  0
             setName(name);
 273  0
             setType(type);
 274  0
             setConfigurationParameters(new ArrayList<RouteNodeConfigurationParameter.Builder>());
 275  0
             setPreviousNodeIds(new ArrayList<String>());
 276  0
             setNextNodeIds(new ArrayList<String>());
 277  0
         }
 278  
 
 279  
         public static Builder create(String name, String type) {
 280  0
             return new Builder(name, type);
 281  
         }
 282  
 
 283  
         public static Builder create(RouteNodeContract contract) {
 284  0
             if (contract == null) {
 285  0
                 throw new IllegalArgumentException("contract was null");
 286  
             }
 287  0
             Builder builder = create(contract.getName(), contract.getType());
 288  0
             builder.setId(contract.getId());
 289  0
             builder.setDocumentTypeId(contract.getDocumentTypeId());
 290  0
             builder.setName(contract.getName());
 291  0
             builder.setRouteMethodName(contract.getRouteMethodName());
 292  0
             builder.setRouteMethodCode(contract.getRouteMethodCode());
 293  0
             builder.setFinalApproval(contract.isFinalApproval());
 294  0
             builder.setMandatory(contract.isMandatory());
 295  0
             builder.setActivationType(contract.getActivationType());
 296  0
             builder.setExceptionGroupId(contract.getExceptionGroupId());
 297  0
             builder.setType(contract.getType());
 298  0
             builder.setBranchName(contract.getBranchName());
 299  0
             builder.setNextDocumentStatus(contract.getNextDocumentStatus());
 300  0
             List<RouteNodeConfigurationParameter.Builder> parameterBuilders = new ArrayList<RouteNodeConfigurationParameter.Builder>();
 301  0
             for (RouteNodeConfigurationParameterContract configurationParameter : contract.getConfigurationParameters()) {
 302  0
                 parameterBuilders.add(RouteNodeConfigurationParameter.Builder.create(configurationParameter));
 303  
             }
 304  0
             builder.setConfigurationParameters(parameterBuilders);
 305  0
             builder.setPreviousNodeIds(contract.getPreviousNodeIds());
 306  0
             builder.setNextNodeIds(contract.getNextNodeIds());
 307  0
             builder.setVersionNumber(contract.getVersionNumber());
 308  
             
 309  0
             return builder;
 310  
         }
 311  
 
 312  
         public RouteNode build() {
 313  0
             return new RouteNode(this);
 314  
         }
 315  
         
 316  
         @Override
 317  
         public String getId() {
 318  0
             return this.id;
 319  
         }
 320  
 
 321  
         @Override
 322  
         public String getDocumentTypeId() {
 323  0
             return this.documentTypeId;
 324  
         }
 325  
 
 326  
         @Override
 327  
         public String getName() {
 328  0
             return this.name;
 329  
         }
 330  
 
 331  
         @Override
 332  
         public String getRouteMethodName() {
 333  0
             return this.routeMethodName;
 334  
         }
 335  
 
 336  
         @Override
 337  
         public String getRouteMethodCode() {
 338  0
             return this.routeMethodCode;
 339  
         }
 340  
 
 341  
         @Override
 342  
         public boolean isFinalApproval() {
 343  0
             return this.finalApproval;
 344  
         }
 345  
 
 346  
         @Override
 347  
         public boolean isMandatory() {
 348  0
             return this.mandatory;
 349  
         }
 350  
 
 351  
         @Override
 352  
         public String getActivationType() {
 353  0
             return this.activationType;
 354  
         }
 355  
 
 356  
         @Override
 357  
         public String getExceptionGroupId() {
 358  0
             return this.exceptionGroupId;
 359  
         }
 360  
 
 361  
         @Override
 362  
         public String getType() {
 363  0
             return this.type;
 364  
         }
 365  
 
 366  
         @Override
 367  
         public String getBranchName() {
 368  0
             return this.branchName;
 369  
         }
 370  
 
 371  
         @Override
 372  
         public String getNextDocumentStatus() {
 373  0
             return this.nextDocumentStatus;
 374  
         }
 375  
 
 376  
         @Override
 377  
         public List<RouteNodeConfigurationParameter.Builder> getConfigurationParameters() {
 378  0
             return this.configurationParameters;
 379  
         }
 380  
 
 381  
         @Override
 382  
         public List<String> getPreviousNodeIds() {
 383  0
             return this.previousNodeIds;
 384  
         }
 385  
 
 386  
         @Override
 387  
         public List<String> getNextNodeIds() {
 388  0
             return this.nextNodeIds;
 389  
         }
 390  
         
 391  
         @Override
 392  
         public Long getVersionNumber() {
 393  0
             return this.versionNumber;
 394  
         }
 395  
         
 396  
         public void setId(String id) {
 397  0
             this.id = id;
 398  0
         }
 399  
 
 400  
         public void setDocumentTypeId(String documentTypeId) {
 401  0
             this.documentTypeId = documentTypeId;
 402  0
         }
 403  
         
 404  
         public void setName(String name) {
 405  0
             if (StringUtils.isBlank(name)) {
 406  0
                 throw new IllegalArgumentException("name was null or blank");
 407  
             }
 408  0
             this.name = name;
 409  0
         }
 410  
 
 411  
         public void setRouteMethodName(String routeMethodName) {
 412  0
             this.routeMethodName = routeMethodName;
 413  0
         }
 414  
 
 415  
         public void setRouteMethodCode(String routeMethodCode) {
 416  0
             this.routeMethodCode = routeMethodCode;
 417  0
         }
 418  
 
 419  
         public void setFinalApproval(boolean finalApproval) {
 420  0
             this.finalApproval = finalApproval;
 421  0
         }
 422  
 
 423  
         public void setMandatory(boolean mandatory) {
 424  0
             this.mandatory = mandatory;
 425  0
         }
 426  
 
 427  
         public void setActivationType(String activationType) {
 428  0
             this.activationType = activationType;
 429  0
         }
 430  
 
 431  
         public void setExceptionGroupId(String exceptionGroupId) {
 432  0
             this.exceptionGroupId = exceptionGroupId;
 433  0
         }
 434  
         
 435  
         public void setType(String type) {
 436  0
             if (StringUtils.isBlank(type)) {
 437  0
                 throw new IllegalArgumentException("type was null or blank");
 438  
             }
 439  0
             this.type = type;
 440  0
         }
 441  
 
 442  
         public void setBranchName(String branchName) {
 443  0
             this.branchName = branchName;
 444  0
         }
 445  
         
 446  
         public void setNextDocumentStatus(String nextDocumentStatus) {
 447  0
             this.nextDocumentStatus = nextDocumentStatus;
 448  0
         }
 449  
         
 450  
         public void setConfigurationParameters(List<RouteNodeConfigurationParameter.Builder> configurationParameters) {
 451  0
             if (configurationParameters == null) {
 452  0
                 throw new IllegalArgumentException("configurationParameters was null");
 453  
             }
 454  0
             this.configurationParameters = configurationParameters;
 455  0
         }
 456  
 
 457  
         public void setPreviousNodeIds(List<String> previousNodeIds) {
 458  0
             if (previousNodeIds == null) {
 459  0
                 throw new IllegalArgumentException("previousNodeIds was null");
 460  
             }
 461  0
             this.previousNodeIds = previousNodeIds;
 462  0
         }
 463  
 
 464  
         public void setNextNodeIds(List<String> nextNodeIds) {
 465  0
             if (nextNodeIds == null) {
 466  0
                 throw new IllegalArgumentException("nextNodeIds was null");
 467  
             }
 468  0
             this.nextNodeIds = nextNodeIds;
 469  0
         }
 470  
         
 471  
         public void setVersionNumber(Long versionNumber) {
 472  0
             this.versionNumber = versionNumber;
 473  0
         }
 474  
 
 475  
     }
 476  
 
 477  
     /**
 478  
      * Defines some internal constants used on this class.
 479  
      */
 480  0
     static class Constants {
 481  
         final static String ROOT_ELEMENT_NAME = "routeNode";
 482  
         final static String TYPE_NAME = "RouteNodeType";
 483  0
         final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[]{CoreConstants.CommonElements.FUTURE_ELEMENTS};
 484  
     }
 485  
 
 486  
     /**
 487  
      * A private class which exposes constants which define the XML element names to use when this
 488  
      * object is marshalled to XML.
 489  
      */
 490  0
     static class Elements {
 491  
         final static String ID = "id";
 492  
         final static String DOCUMENT_TYPE_ID = "documentTypeId";
 493  
         final static String NAME = "name";
 494  
         final static String ROUTE_METHOD_NAME = "routeMethodName";
 495  
         final static String ROUTE_METHOD_CODE = "routeMethodCode";
 496  
         final static String FINAL_APPROVAL = "finalApproval";
 497  
         final static String MANDATORY = "mandatory";
 498  
         final static String ACTIVATION_TYPE = "activationType";
 499  
         final static String EXCEPTION_GROUP_ID = "exceptionGroupId";
 500  
         final static String TYPE = "type";
 501  
         final static String BRANCH_NAME = "branchName";
 502  
         final static String NEXT_DOCUMENT_STATUS = "nextDocumentStatus";
 503  
         final static String CONFIGURATION_PARAMETERS = "configurationParameters";
 504  
         final static String CONFIGURATION_PARAMETER = "configurationParameter";
 505  
         final static String PREVIOUS_NODE_IDS = "previousNodeIds";
 506  
         final static String PREVIOUS_NODE_ID = "previousNodeId";
 507  
         final static String NEXT_NODE_IDS = "nextNodeIds";
 508  
         final static String NEXT_NODE_ID = "nextNodeId";
 509  
     }
 510  
 
 511  
 }