View Javadoc

1   /*
2    * $Id: XmppNotFilter.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.transport.xmpp.filters;
12  
13  import org.mule.util.ClassUtils;
14  
15  import org.jivesoftware.smack.filter.NotFilter;
16  import org.jivesoftware.smack.filter.PacketFilter;
17  
18  /**
19   * <code>XmppNotFilter</code> an Xmpp NOT filter
20   */
21  public class XmppNotFilter extends AbstractXmppFilter
22  {
23      private volatile PacketFilter filter;
24  
25      public XmppNotFilter()
26      {
27          super();
28      }
29  
30      public XmppNotFilter(PacketFilter filter)
31      {
32          this.filter = filter;
33      }
34  
35      public void setFilter(PacketFilter filter)
36      {
37          this.filter = filter;
38      }
39  
40      public PacketFilter getFilter()
41      {
42          return filter;
43      }
44  
45      @Override
46      protected PacketFilter createFilter()
47      {
48          return new NotFilter(filter);
49      }
50  
51      @Override
52      public boolean equals(Object obj)
53      {
54          if (this == obj) return true;
55          if (obj == null || getClass() != obj.getClass()) return false;
56  
57          final XmppNotFilter other = (XmppNotFilter) obj;
58          return ClassUtils.equal(filter, other.filter);
59      }
60  
61      @Override
62      public int hashCode()
63      {
64          return ClassUtils.hash(new Object[]{this.getClass(), filter});
65      }
66  }