Coverage Report - org.kuali.rice.kew.api.action.DocumentActionParameters
 
Classes in this File Line Coverage Branch Coverage Complexity
DocumentActionParameters
0%
0/28
N/A
1.16
DocumentActionParameters$1
N/A
N/A
1.16
DocumentActionParameters$Builder
0%
0/26
0%
0/4
1.16
DocumentActionParameters$Constants
0%
0/2
N/A
1.16
DocumentActionParameters$Elements
0%
0/1
N/A
1.16
 
 1  
 /*
 2  
 
 3  
  * Copyright 2011 The Kuali Foundation
 4  
  *
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  * http://www.opensource.org/licenses/ecl1.php
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.rice.kew.api.action;
 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.kew.api.document.DocumentContentUpdate;
 36  
 import org.kuali.rice.kew.api.document.DocumentUpdate;
 37  
 import org.w3c.dom.Element;
 38  
 
 39  
 @XmlRootElement(name = DocumentActionParameters.Constants.ROOT_ELEMENT_NAME)
 40  
 @XmlAccessorType(XmlAccessType.NONE)
 41  
 @XmlType(name = DocumentActionParameters.Constants.TYPE_NAME, propOrder = {
 42  
                 DocumentActionParameters.Elements.DOCUMENT_ID,
 43  
                 DocumentActionParameters.Elements.PRINCIPAL_ID,
 44  
                 DocumentActionParameters.Elements.ANNOTATION,
 45  
                 DocumentActionParameters.Elements.DOCUMENT_UPDATE,
 46  
                 DocumentActionParameters.Elements.DOCUMENT_CONTENT_UPDATE,
 47  
                 CoreConstants.CommonElements.FUTURE_ELEMENTS
 48  
 })
 49  0
 public final class DocumentActionParameters implements Serializable {
 50  
     
 51  
         private static final long serialVersionUID = -7589214734683758734L;
 52  
 
 53  
         @XmlElement(name = Elements.DOCUMENT_ID, required = true)
 54  
     private final String documentId;
 55  
         
 56  
         @XmlElement(name = Elements.PRINCIPAL_ID, required = true)
 57  
         private final String principalId;
 58  
 
 59  
         @XmlElement(name = Elements.ANNOTATION, required = false)
 60  
         private final String annotation;
 61  
         
 62  
         @XmlElement(name = Elements.DOCUMENT_UPDATE, required = false)
 63  
         private final DocumentUpdate documentUpdate;
 64  
         
 65  
         @XmlElement(name = Elements.DOCUMENT_CONTENT_UPDATE, required = false)
 66  
         private final DocumentContentUpdate documentContentUpdate;
 67  
             
 68  0
     @SuppressWarnings("unused")
 69  
     @XmlAnyElement
 70  
     private final Collection<Element> _futureElements = null;
 71  
 
 72  0
     private DocumentActionParameters() {
 73  0
             this.documentId = null;
 74  0
             this.principalId = null;
 75  0
             this.annotation = null;
 76  0
             this.documentUpdate = null;
 77  0
             this.documentContentUpdate = null;
 78  0
     }
 79  
     
 80  0
     private DocumentActionParameters(Builder builder) {
 81  0
             this.documentId = builder.getDocumentId();
 82  0
             this.principalId = builder.getPrincipalId();
 83  0
             this.annotation = builder.getAnnotation();
 84  0
             this.documentUpdate = builder.getDocumentUpdate();
 85  0
             this.documentContentUpdate = builder.getDocumentContentUpdate();
 86  0
     }
 87  
     
 88  
     public static DocumentActionParameters create(String documentId, String principalId) {
 89  0
         return create(documentId, principalId, "");
 90  
     }
 91  
     
 92  
     public static DocumentActionParameters create(String documentId, String principalId, String annotation) {
 93  0
             Builder builder = Builder.create(documentId, principalId);
 94  0
             builder.setAnnotation(annotation);
 95  0
             return builder.build();
 96  
     }
 97  
         
 98  
         public String getDocumentId() {
 99  0
                 return documentId;
 100  
         }
 101  
 
 102  
         public String getPrincipalId() {
 103  0
                 return principalId;
 104  
         }
 105  
 
 106  
         public String getAnnotation() {
 107  0
                 return annotation;
 108  
         }
 109  
 
 110  
         public DocumentUpdate getDocumentUpdate() {
 111  0
                 return documentUpdate;
 112  
         }
 113  
 
 114  
         public DocumentContentUpdate getDocumentContentUpdate() {
 115  0
                 return documentContentUpdate;
 116  
         }
 117  
 
 118  
         @Override
 119  
     public int hashCode() {
 120  0
         return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 121  
     }
 122  
 
 123  
     @Override
 124  
     public boolean equals(Object object) {
 125  0
         return EqualsBuilder.reflectionEquals(object, this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 126  
     }
 127  
 
 128  
     @Override
 129  
     public String toString() {
 130  0
         return ToStringBuilder.reflectionToString(this);
 131  
     }
 132  
     
 133  
     /**
 134  
      * A builder which can be used to construct {@link DocumentActionParameters} instances.
 135  
      * 
 136  
      */
 137  0
     public final static class Builder implements Serializable, ModelBuilder {
 138  
 
 139  
                 private static final long serialVersionUID = -9209748637365086000L;
 140  
 
 141  
                 private String documentId;
 142  
                 private String principalId;
 143  
                 private String annotation;
 144  
                 private DocumentUpdate documentUpdate;
 145  
                 private DocumentContentUpdate documentContentUpdate;
 146  
 
 147  0
         private Builder(String documentId, String principalId) {
 148  0
             setDocumentId(documentId);
 149  0
             setPrincipalId(principalId);
 150  0
         }
 151  
 
 152  
         public static Builder create(String documentId, String principalId) {
 153  0
             return new Builder(documentId, principalId);
 154  
         }
 155  
         
 156  
         public DocumentActionParameters build() {
 157  0
             return new DocumentActionParameters(this);
 158  
         }
 159  
 
 160  
                 public String getDocumentId() {
 161  0
                         return documentId;
 162  
                 }
 163  
 
 164  
                 public void setDocumentId(String documentId) {
 165  0
                         if (StringUtils.isBlank(documentId)) {
 166  0
                                 throw new IllegalArgumentException("documentId was null or blank");
 167  
                         }
 168  0
                         this.documentId = documentId;
 169  0
                 }
 170  
 
 171  
                 public String getPrincipalId() {
 172  0
                         return principalId;
 173  
                 }
 174  
 
 175  
                 public void setPrincipalId(String principalId) {
 176  0
                         if (StringUtils.isBlank(principalId)) {
 177  0
                                 throw new IllegalArgumentException("principalId was null or blank");
 178  
                         }
 179  0
                         this.principalId = principalId;
 180  0
                 }
 181  
 
 182  
                 public String getAnnotation() {
 183  0
                         return annotation;
 184  
                 }
 185  
 
 186  
                 public void setAnnotation(String annotation) {
 187  0
                         this.annotation = annotation;
 188  0
                 }
 189  
 
 190  
                 public DocumentUpdate getDocumentUpdate() {
 191  0
                         return documentUpdate;
 192  
                 }
 193  
 
 194  
                 public void setDocumentUpdate(DocumentUpdate documentUpdate) {
 195  0
                         this.documentUpdate = documentUpdate;
 196  0
                 }
 197  
 
 198  
                 public DocumentContentUpdate getDocumentContentUpdate() {
 199  0
                         return documentContentUpdate;
 200  
                 }
 201  
 
 202  
                 public void setDocumentContentUpdate(DocumentContentUpdate documentContentUpdate) {
 203  0
                         this.documentContentUpdate = documentContentUpdate;
 204  0
                 }
 205  
     
 206  
     }
 207  
     
 208  
     /**
 209  
      * Defines some internal constants used on this class.
 210  
      */
 211  0
     static class Constants {
 212  
         final static String ROOT_ELEMENT_NAME = "documentActionParameters";
 213  
         final static String TYPE_NAME = "DocumentActionParametersType";
 214  0
         final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[] { CoreConstants.CommonElements.FUTURE_ELEMENTS };
 215  
     }
 216  
     
 217  
     /**
 218  
      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
 219  
      */
 220  0
     static class Elements {
 221  
         final static String DOCUMENT_ID = "documentId";
 222  
         final static String PRINCIPAL_ID = "principalId";
 223  
         final static String ANNOTATION = "annotation";
 224  
         final static String DOCUMENT_UPDATE = "documentUpdate";
 225  
         final static String DOCUMENT_CONTENT_UPDATE = "documentContentUpdate";
 226  
     }
 227  
 
 228  
 }