View Javadoc

1   /*
2    * $Id: QueueKey.java 21657 2011-04-03 06:00:22Z dirk.olmes $
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.util.queue;
12  
13  import java.io.Serializable;
14  
15  public class QueueKey implements Serializable
16  {
17      // hashCode() and equals() are autogenerated by Eclipse. If you add iVars to this class make
18      // sure to re-generate
19      public final String queueName;
20      public final Serializable id;
21  
22      public QueueKey(String queueName, Serializable id)
23      {
24          super();
25          this.queueName = queueName;
26          this.id = id;
27      }
28  
29      @Override
30      public String toString()
31      {
32          StringBuilder buf = new StringBuilder(128);
33          buf.append(getClass().getSimpleName());
34          buf.append("@");
35          buf.append(System.identityHashCode(this));
36          buf.append(" queueName=");
37          buf.append(queueName);
38          buf.append(" id=");
39          buf.append(id);
40          return buf.toString();
41      }
42  
43      @Override
44      public int hashCode()
45      {
46          final int prime = 31;
47          int result = 1;
48          result = prime * result + ((id == null) ? 0 : id.hashCode());
49          result = prime * result + ((queueName == null) ? 0 : queueName.hashCode());
50          return result;
51      }
52  
53      @Override
54      public boolean equals(Object obj)
55      {
56          if (this == obj) return true;
57          if (obj == null) return false;
58          if (getClass() != obj.getClass()) return false;
59          QueueKey other = (QueueKey)obj;
60          if (id == null)
61          {
62              if (other.id != null) return false;
63          }
64          else if (!id.equals(other.id)) return false;
65          if (queueName == null)
66          {
67              if (other.queueName != null) return false;
68          }
69          else if (!queueName.equals(other.queueName)) return false;
70          return true;
71      }
72  }