Coverage Report - org.kuali.rice.kim.api.group.GroupQueryResults
 
Classes in this File Line Coverage Branch Coverage Complexity
GroupQueryResults
0%
0/22
0%
0/4
1.118
GroupQueryResults$1
N/A
N/A
1.118
GroupQueryResults$Builder
0%
0/16
N/A
1.118
GroupQueryResults$Constants
0%
0/2
N/A
1.118
GroupQueryResults$Elements
0%
0/1
N/A
1.118
 
 1  
 /*
 2  
  * Copyright 2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 1.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl1.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.kim.api.group;
 17  
 
 18  
 import org.apache.commons.lang.builder.EqualsBuilder;
 19  
 import org.apache.commons.lang.builder.HashCodeBuilder;
 20  
 import org.apache.commons.lang.builder.ToStringBuilder;
 21  
 import org.kuali.rice.core.api.CoreConstants;
 22  
 import org.kuali.rice.core.api.criteria.QueryResults;
 23  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 24  
 import org.kuali.rice.core.api.mo.ModelObjectComplete;
 25  
 import org.kuali.rice.kim.api.group.Group;
 26  
 import org.w3c.dom.Element;
 27  
 
 28  
 import javax.xml.bind.annotation.XmlAccessType;
 29  
 import javax.xml.bind.annotation.XmlAccessorType;
 30  
 import javax.xml.bind.annotation.XmlAnyElement;
 31  
 import javax.xml.bind.annotation.XmlElement;
 32  
 import javax.xml.bind.annotation.XmlElementWrapper;
 33  
 import javax.xml.bind.annotation.XmlRootElement;
 34  
 import javax.xml.bind.annotation.XmlType;
 35  
 import java.util.ArrayList;
 36  
 import java.util.Collection;
 37  
 import java.util.Collections;
 38  
 import java.util.List;
 39  
 
 40  
 /**
 41  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 42  
  */
 43  
 @XmlRootElement(name = GroupQueryResults.Constants.ROOT_ELEMENT_NAME)
 44  
 @XmlAccessorType(XmlAccessType.NONE)
 45  
 @XmlType(name = GroupQueryResults.Constants.TYPE_NAME, propOrder = {
 46  
                 GroupQueryResults.Elements.RESULTS,
 47  
                 GroupQueryResults.Elements.TOTAL_ROW_COUNT,
 48  
                 GroupQueryResults.Elements.MORE_RESULTS_AVAILALBE,
 49  
                 CoreConstants.CommonElements.FUTURE_ELEMENTS })
 50  0
 public class GroupQueryResults implements QueryResults<Group>, ModelObjectComplete {
 51  
 
 52  
         @XmlElementWrapper(name = Elements.RESULTS, required = false)
 53  
         @XmlElement(name = Elements.RESULT_ELEM, required = false)
 54  
         private final List<Group> results;
 55  
 
 56  
         @XmlElement(name = Elements.TOTAL_ROW_COUNT, required = false)
 57  
         private final Integer totalRowCount;
 58  
 
 59  
         @XmlElement(name = Elements.MORE_RESULTS_AVAILALBE, required = true)
 60  
         private final boolean moreResultsAvailable;
 61  
 
 62  0
         @SuppressWarnings("unused")
 63  
     @XmlAnyElement
 64  
     private final Collection<Element> _futureElements = null;
 65  
 
 66  0
         private GroupQueryResults() {
 67  0
                 this.results = null;
 68  0
                 this.totalRowCount = null;
 69  0
                 this.moreResultsAvailable = false;
 70  0
         }
 71  
 
 72  0
         private GroupQueryResults(Builder builder) {
 73  0
                 final List<Group> temp = new ArrayList<Group>();
 74  0
         for (Group.Builder b : builder.getResults()) {
 75  0
             if (b != null) {
 76  0
                 temp.add(b.build());
 77  
             }
 78  
         }
 79  
 
 80  0
         this.results = Collections.unmodifiableList(temp);
 81  0
                 this.totalRowCount = builder.getTotalRowCount();
 82  0
                 this.moreResultsAvailable = builder.isMoreResultsAvailable();
 83  0
         }
 84  
 
 85  
         @Override
 86  
         public List<Group> getResults() {
 87  0
                 return results;
 88  
         }
 89  
         
 90  
         @Override
 91  
         public Integer getTotalRowCount() {
 92  0
                 return totalRowCount;
 93  
         }
 94  
 
 95  
         @Override
 96  
         public boolean isMoreResultsAvailable() {
 97  0
                 return moreResultsAvailable;
 98  
         }
 99  
 
 100  
     @Override
 101  
     public int hashCode() {
 102  0
         return HashCodeBuilder.reflectionHashCode(this);
 103  
     }
 104  
 
 105  
     @Override
 106  
     public boolean equals(Object obj) {
 107  0
         return EqualsBuilder.reflectionEquals(obj, this);
 108  
     }
 109  
 
 110  
     @Override
 111  
     public String toString() {
 112  0
         return ToStringBuilder.reflectionToString(this);
 113  
     }
 114  
 
 115  0
         public static class Builder implements ModelBuilder, QueryResults<Group.Builder> {
 116  
 
 117  
                 private List<Group.Builder> results;
 118  
                 private Integer totalRowCount;
 119  
                 private boolean moreResultsAvailable;
 120  
 
 121  
         public static Builder create() {
 122  0
             return new Builder();
 123  
         }
 124  
 
 125  0
                 private Builder() {
 126  0
                         this.results = new ArrayList<Group.Builder>();
 127  0
                         this.moreResultsAvailable = false;
 128  0
                 }
 129  
 
 130  
         @Override
 131  
                 public GroupQueryResults build() {
 132  0
                         return new GroupQueryResults(this);
 133  
                 }
 134  
 
 135  
         @Override
 136  
                 public List<Group.Builder> getResults() {
 137  0
                         return Collections.unmodifiableList(this.results);
 138  
                 }
 139  
 
 140  
                 public void setResults(List<Group.Builder> results) {
 141  0
                         this.results = new ArrayList<Group.Builder>(results);
 142  0
                 }
 143  
 
 144  
         @Override
 145  
                 public Integer getTotalRowCount() {
 146  0
                         return this.totalRowCount;
 147  
                 }
 148  
 
 149  
                 public void setTotalRowCount(Integer totalRowCount) {
 150  0
                         this.totalRowCount = totalRowCount;
 151  0
                 }
 152  
 
 153  
         @Override
 154  
                 public boolean isMoreResultsAvailable() {
 155  0
                         return this.moreResultsAvailable;
 156  
                 }
 157  
 
 158  
                 public void setMoreResultsAvailable(boolean moreResultsAvailable) {
 159  0
                         this.moreResultsAvailable = moreResultsAvailable;
 160  0
                 }
 161  
                 
 162  
         }
 163  
         
 164  
         /**
 165  
          * Defines some internal constants used on this class.
 166  
          */
 167  0
         public static class Constants {
 168  
                 public final static String ROOT_ELEMENT_NAME = "GroupQueryResults";
 169  
                 public final static String TYPE_NAME = "GroupQueryResultsType";
 170  0
                 public final static String[] HASH_CODE_EQUALS_EXCLUDE = { CoreConstants.CommonElements.FUTURE_ELEMENTS };
 171  
         }
 172  
 
 173  
         /**
 174  
          * A private class which exposes constants which define the XML element
 175  
          * names to use when this object is marshaled to XML.
 176  
          */
 177  0
         public static class Elements {
 178  
                 public final static String RESULTS = "results";
 179  
                 public final static String RESULT_ELEM = "Group";
 180  
                 public final static String TOTAL_ROW_COUNT = "totalRowCount";
 181  
                 public final static String MORE_RESULTS_AVAILALBE = "moreResultsAvailable";
 182  
         }
 183  
         
 184  
 }