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