View Javadoc

1   /*
2    * Copyright 2009 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.student.contract.model.test.source;
17  
18  import java.io.Serializable;
19  import java.util.ArrayList;
20  import java.util.Collections;
21  import java.util.List;
22  
23  import javax.xml.bind.annotation.XmlAccessType;
24  import javax.xml.bind.annotation.XmlAccessorType;
25  import javax.xml.bind.annotation.XmlAnyElement;
26  import javax.xml.bind.annotation.XmlElement;
27  import javax.xml.bind.annotation.XmlElementWrapper;
28  import javax.xml.bind.annotation.XmlType;
29  
30  import org.kuali.student.contract.model.test.source.Comparison;
31  import org.kuali.student.contract.model.test.source.Criteria;
32  import org.kuali.student.contract.model.test.source.ModelBuilder;
33  import org.w3c.dom.Element;
34  
35  /**
36   * Query to return some information regarding LUI to person relationships.
37   *
38   * @Author KSContractMojo
39   * @Author Kamal
40   * @Since Tue Mar 01 15:54:06 PST 2011
41   * @See <a href="https://wiki.kuali.org/display/KULSTU/luiPersonRelationCriteria+Structure">LuiPersonRelationCriteria</a>
42   */
43  @XmlAccessorType(XmlAccessType.FIELD)
44  @XmlType(name = "CriteriaInfo", propOrder = {"comparisons", "maxResults", "_futureElements"})
45  public class CriteriaInfo implements Criteria, Serializable {
46  
47      private static final long serialVersionUID = 1L;
48      
49      @XmlElementWrapper(name="comparisons")
50      @XmlElement(name="comparison")
51      private final List<ComparisonInfo> comparisons;
52      @XmlElement
53      private final Integer maxResults;
54      @XmlAnyElement
55      private final List<Element> _futureElements;
56      
57      private CriteriaInfo() {
58          comparisons = null;
59          maxResults = null;
60          _futureElements = null;
61      }
62  
63      @Override
64      public List<ComparisonInfo> getComparisons() {
65          return this.comparisons;
66      }
67  
68      @Override
69      public Integer getMaxResults() {
70          return this.maxResults;
71      }
72  
73      private CriteriaInfo(Criteria builder) {
74          if (builder.getComparisons() == null) {
75              this.comparisons = null;
76          } else {
77              List<ComparisonInfo> list = new ArrayList(builder.getComparisons().size());
78              for (Comparison infc : builder.getComparisons()) {
79                  list.add(new ComparisonInfo.Builder(infc).build());
80              }
81              this.comparisons = Collections.unmodifiableList(list);
82          }
83          this.maxResults = builder.getMaxResults();
84          this._futureElements = null;
85      }
86  
87      public static class Builder implements ModelBuilder<CriteriaInfo>, Criteria {
88  
89          private List<? extends Comparison> comparisons;
90          private Integer maxResults;
91  
92          public Builder() {
93          }
94  
95          public Builder(Criteria info) {
96              this.comparisons = info.getComparisons();
97              this.maxResults = info.getMaxResults();
98          }
99  
100         public CriteriaInfo build() {
101             return new CriteriaInfo(this);
102         }
103 
104         @Override
105         public List<? extends Comparison> getComparisons() {
106             return this.comparisons;
107         }
108 
109         @Override
110         public Integer getMaxResults() {
111             return this.maxResults;
112         }
113 
114         public void setComparisons(List<? extends Comparison> comparisons) {
115             this.comparisons = comparisons;
116         }
117 
118         public void setMaxResults(Integer maxResults) {
119             this.maxResults = maxResults;
120         }
121     }
122 }