Coverage Report - org.kuali.rice.kew.api.doctype.RoutePath
 
Classes in this File Line Coverage Branch Coverage Complexity
RoutePath
0%
0/19
0%
0/8
1.615
RoutePath$1
N/A
N/A
1.615
RoutePath$Builder
0%
0/17
0%
0/4
1.615
RoutePath$Constants
0%
0/2
N/A
1.615
RoutePath$Elements
0%
0/1
N/A
1.615
 
 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.builder.EqualsBuilder;
 17  
 import org.apache.commons.lang.builder.HashCodeBuilder;
 18  
 import org.apache.commons.lang.builder.ToStringBuilder;
 19  
 import org.kuali.rice.core.api.CoreConstants;
 20  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 21  
 import org.kuali.rice.core.api.mo.ModelObjectComplete;
 22  
 import org.kuali.rice.core.util.CollectionUtils;
 23  
 import org.w3c.dom.Element;
 24  
 
 25  
 @XmlRootElement(name = RoutePath.Constants.ROOT_ELEMENT_NAME)
 26  
 @XmlAccessorType(XmlAccessType.NONE)
 27  
 @XmlType(name = RoutePath.Constants.TYPE_NAME, propOrder = {
 28  
         RoutePath.Elements.PROCESSES,
 29  
         CoreConstants.CommonElements.FUTURE_ELEMENTS
 30  
 })
 31  0
 public final class RoutePath implements ModelObjectComplete, RoutePathContract {
 32  
 
 33  
     private static final long serialVersionUID = -7177305375323986864L;
 34  
 
 35  
     @XmlElementWrapper(name = Elements.PROCESSES, required = false)
 36  
     @XmlElement(name = Elements.PROCESS, required = false)
 37  
     private final List<Process> processes;
 38  
 
 39  0
     @SuppressWarnings("unused")
 40  
     @XmlAnyElement
 41  
     private final Collection<Element> _futureElements = null;
 42  
 
 43  
     /**
 44  
      * Private constructor used only by JAXB.
 45  
      */
 46  0
     private RoutePath() {
 47  0
         this.processes = null;
 48  0
     }
 49  
 
 50  0
     private RoutePath(Builder builder) {
 51  0
         this.processes = new ArrayList<Process>();
 52  0
         if (builder.getProcesses() != null) {
 53  0
             for (Process.Builder processBuilder : builder.getProcesses()) {
 54  0
                 this.processes.add(processBuilder.build());
 55  
             }
 56  
         }
 57  0
     }
 58  
     
 59  
     public Process getPrimaryProcess() {
 60  0
         for (Process process : processes) {
 61  0
             if (process.isInitial()) {
 62  0
                 return process;
 63  
             }
 64  
         }        
 65  0
         return null;
 66  
     }
 67  
 
 68  
     @Override
 69  
     public List<Process> getProcesses() {
 70  0
         return CollectionUtils.unmodifiableListNullSafe(this.processes);
 71  
     }
 72  
 
 73  
     @Override
 74  
     public int hashCode() {
 75  0
         return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 76  
     }
 77  
 
 78  
     @Override
 79  
     public boolean equals(Object object) {
 80  0
         return EqualsBuilder.reflectionEquals(object, this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 81  
     }
 82  
 
 83  
     @Override
 84  
     public String toString() {
 85  0
         return ToStringBuilder.reflectionToString(this);
 86  
     }
 87  
 
 88  
     /**
 89  
      * A builder which can be used to construct {@link RoutePath} instances. Enforces the
 90  
      * constraints of the {@link RoutePathContract}.
 91  
      */
 92  0
     public final static class Builder implements Serializable, ModelBuilder, RoutePathContract {
 93  
 
 94  
         private static final long serialVersionUID = -6916424305298043710L;
 95  
 
 96  
         private List<Process.Builder> processes;
 97  
 
 98  0
         private Builder() {}
 99  
 
 100  
         public static Builder create() {
 101  0
             Builder builder = new Builder();
 102  0
             builder.setProcesses(new ArrayList<Process.Builder>());
 103  0
             return builder;
 104  
         }
 105  
 
 106  
         public static Builder create(RoutePathContract contract) {
 107  0
             if (contract == null) {
 108  0
                 throw new IllegalArgumentException("contract was null");
 109  
             }
 110  0
             Builder builder = create();
 111  0
             List<Process.Builder> processBuilders = new ArrayList<Process.Builder>();
 112  0
             for (ProcessContract process : contract.getProcesses()) {
 113  0
                 processBuilders.add(Process.Builder.create(process));
 114  
             }
 115  0
             builder.setProcesses(processBuilders);
 116  0
             return builder;
 117  
         }
 118  
 
 119  
         public RoutePath build() {
 120  0
             return new RoutePath(this);
 121  
         }
 122  
 
 123  
         @Override
 124  
         public List<Process.Builder> getProcesses() {
 125  0
             return this.processes;
 126  
         }
 127  
 
 128  
         public void setProcesses(List<Process.Builder> processes) {
 129  0
             this.processes = processes;
 130  0
         }
 131  
 
 132  
     }
 133  
 
 134  
     /**
 135  
      * Defines some internal constants used on this class.
 136  
      */
 137  0
     static class Constants {
 138  
         final static String ROOT_ELEMENT_NAME = "routePath";
 139  
         final static String TYPE_NAME = "RoutePathType";
 140  0
         final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[]{CoreConstants.CommonElements.FUTURE_ELEMENTS};
 141  
     }
 142  
 
 143  
     /**
 144  
      * A private class which exposes constants which define the XML element names to use when this
 145  
      * object is marshalled to XML.
 146  
      */
 147  0
     static class Elements {
 148  
         final static String PROCESSES = "processes";
 149  
         final static String PROCESS = "process";
 150  
     }
 151  
 
 152  
 }