View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.routing.filters.logic;
8   
9   import org.mule.api.routing.filter.Filter;
10  import org.mule.util.ClassUtils;
11  
12  import java.util.ArrayList;
13  import java.util.List;
14  
15  /**
16   * Manages a filter collection. Used as the base clas for the Or and AND filters
17   */
18  
19  public abstract class AbstractFilterCollection implements Filter
20  {
21      private List<Filter> filters;
22  
23      public AbstractFilterCollection()
24      {
25          filters = new ArrayList<Filter>();
26      }
27  
28      public AbstractFilterCollection(List<Filter> filters)
29      {
30          this();
31          this.filters = filters;
32      }
33  
34      public AbstractFilterCollection(Filter... filters)
35      {
36          this();
37          for (int i = 0; i < filters.length; i++)
38          {
39              this.filters.add(filters[i]);
40          }
41      }
42  
43      public List<Filter> getFilters()
44      {
45          return filters;
46      }
47  
48      public void setFilters(List<Filter> filters)
49      {
50          this.filters = filters;
51      }
52      
53      public boolean equals(Object obj)
54      {
55          if (this == obj) return true;
56          if (obj == null || getClass() != obj.getClass()) return false;
57  
58          final AbstractFilterCollection other = (AbstractFilterCollection) obj;
59          return ClassUtils.equal(filters, other.filters);
60      }
61  
62      public int hashCode()
63      {
64          return ClassUtils.hash(new Object[]{this.getClass(), filters});
65      }
66  
67  }