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.MuleMessage;
10  import org.mule.api.routing.filter.Filter;
11  
12  import java.util.List;
13  
14  /**
15   * <code>AndFilter</code> accepts only if all the filters
16   * accept.
17   */
18  public class AndFilter extends AbstractFilterCollection
19  {
20  
21      public AndFilter()
22      {
23          super();
24      }
25  
26      public AndFilter(Filter... filters)
27      {
28          super(filters);
29      }
30  
31      public AndFilter(List<Filter> filters)
32      {
33          super(filters);
34      }
35  
36      public boolean accept(MuleMessage message)
37      {
38          if (getFilters().size() == 0)
39          {
40              return false;
41          }
42          for (Filter filter : getFilters())
43          {
44              if (!filter.accept(message))
45              {
46                  return false;
47              }
48          }
49  
50          return true;
51      }
52  }