View Javadoc

1   /**
2    * Copyright 2011 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  package org.kuali.mobility.events.util;
16  
17  import org.apache.commons.collections.Predicate;
18  import org.kuali.mobility.events.entity.Category;
19  
20  public final class CategoryPredicate implements Predicate {
21  
22      private String campus;
23      private String category;
24      
25      public CategoryPredicate( final String campus, final String category )
26      {
27          this.setCampus( campus );
28          this.setCategory( category );
29      }
30      
31      @Override
32      public boolean evaluate(Object obj) {
33          boolean campusMatch = false;
34          boolean categoryMatch = false;
35          
36          if( obj instanceof Category )
37          {
38              if( getCampus() == null )
39              {
40                  campusMatch = true;
41              }
42              if( getCampus() != null && getCampus().equalsIgnoreCase( ((Category)obj).getCampus() ))
43              {
44                  campusMatch = true;
45              }
46              if( getCategory() == null )
47              {
48                  categoryMatch = true;
49              }
50              if( getCategory() != null && getCategory().equalsIgnoreCase( ((Category)obj).getCategoryId() ) )
51              {
52                  categoryMatch = true;
53              }
54          }
55          
56          return campusMatch && categoryMatch;
57      }
58  
59      /**
60       * @return the category
61       */
62      public String getCategory() {
63          return category;
64      }
65  
66      /**
67       * @param category the category to set
68       */
69      public void setCategory(String category) {
70          this.category = category;
71      }
72  
73      /**
74       * @return the campus
75       */
76      public String getCampus() {
77          return campus;
78      }
79  
80      /**
81       * @param campus the campus to set
82       */
83      public void setCampus(String campus) {
84          this.campus = campus;
85      }
86      
87  }