Coverage Report - org.kuali.rice.core.api.criteria.GenericQueryResults
 
Classes in this File Line Coverage Branch Coverage Complexity
GenericQueryResults
0%
0/12
0%
0/2
1.375
GenericQueryResults$1
N/A
N/A
1.375
GenericQueryResults$Builder
0%
0/20
0%
0/6
1.375
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.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/ecl2.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.core.api.criteria;
 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.mo.ModelBuilder;
 22  
 import org.kuali.rice.core.api.mo.ModelObjectComplete;
 23  
 
 24  
 import java.io.Serializable;
 25  
 import java.util.ArrayList;
 26  
 import java.util.Collections;
 27  
 import java.util.List;
 28  
 
 29  0
 public final class GenericQueryResults<T> implements QueryResults<T> {
 30  
 
 31  
         private final List<T> results;
 32  
         private final Integer totalRowCount;
 33  
         private final boolean moreResultsAvailable;
 34  
         
 35  0
         private GenericQueryResults(Builder<T> builder) {
 36  0
                 this.results = builder.getResults() != null ? Collections.unmodifiableList(new ArrayList<T>(builder.getResults())) : Collections.<T>emptyList();
 37  0
                 this.totalRowCount = builder.getTotalRowCount();
 38  0
                 this.moreResultsAvailable = builder.isMoreResultsAvailable();
 39  0
         }
 40  
 
 41  
         @Override
 42  
         public List<T> getResults() {
 43  0
                 return results;
 44  
         }
 45  
         
 46  
         @Override
 47  
         public Integer getTotalRowCount() {
 48  0
                 return totalRowCount;
 49  
         }
 50  
 
 51  
         @Override
 52  
         public boolean isMoreResultsAvailable() {
 53  0
                 return moreResultsAvailable;
 54  
         }
 55  
 
 56  
     @Override
 57  
         public int hashCode() {
 58  0
                 return HashCodeBuilder.reflectionHashCode(this);
 59  
         }
 60  
 
 61  
         @Override
 62  
         public boolean equals(Object obj) {
 63  0
                 return EqualsBuilder.reflectionEquals(obj, this);
 64  
         }
 65  
 
 66  
         @Override
 67  
         public String toString() {
 68  0
                 return ToStringBuilder.reflectionToString(this);
 69  
         }
 70  
 
 71  0
         public static final class Builder<T> implements ModelBuilder, QueryResults<T>, Serializable {
 72  
 
 73  
                 private List<T> results;
 74  
                 private Integer totalRowCount;
 75  
                 private boolean moreResultsAvailable;
 76  
 
 77  
         public static <T> Builder create() {
 78  0
             return new Builder<T>();
 79  
         }
 80  
 
 81  0
                 private Builder() {
 82  0
                         this.results = new ArrayList<T>();
 83  0
                         this.moreResultsAvailable = false;
 84  0
                 }
 85  
 
 86  
         @Override
 87  
                 public GenericQueryResults<T> build() {
 88  0
                         return new GenericQueryResults<T>(this);
 89  
                 }
 90  
 
 91  
                 public List<T> getResults() {
 92  0
                         return this.results;
 93  
                 }
 94  
 
 95  
                 public void setResults(List<T> results) {
 96  0
                         if (results == null) {
 97  0
                 throw new IllegalArgumentException("results is null");
 98  
             }
 99  
 
 100  0
             this.results = Collections.unmodifiableList(new ArrayList<T>(results));
 101  0
                 }
 102  
 
 103  
                 public Integer getTotalRowCount() {
 104  0
                         return this.totalRowCount;
 105  
                 }
 106  
 
 107  
                 public void setTotalRowCount(Integer totalRowCount) {
 108  0
                         if (totalRowCount != null && totalRowCount < 0) {
 109  0
                 throw new IllegalArgumentException("totalRowCount < 0");
 110  
             }
 111  
 
 112  0
             this.totalRowCount = totalRowCount;
 113  0
                 }
 114  
 
 115  
                 public boolean isMoreResultsAvailable() {
 116  0
                         return this.moreResultsAvailable;
 117  
                 }
 118  
 
 119  
                 public void setMoreResultsAvailable(boolean moreResultsAvailable) {
 120  0
                         this.moreResultsAvailable = moreResultsAvailable;
 121  0
                 }
 122  
         }
 123  
 }