View Javadoc

1   /*
2    * $Id: QueueConfiguration.java 22174 2011-06-14 08:01:42Z 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 org.mule.api.MuleContext;
14  import org.mule.api.store.ListableObjectStore;
15  
16  import java.io.Serializable;
17  
18  public class QueueConfiguration
19  {
20      protected final int capacity;
21      protected final ListableObjectStore<Serializable> objectStore;
22  
23      public QueueConfiguration(MuleContext context, int capacity, ListableObjectStore<Serializable> objectStore)
24      {
25          this.capacity = capacity;
26          this.objectStore = objectStore;
27      }
28  
29      public QueueConfiguration(int capacity, ListableObjectStore<Serializable> objectStore)
30      {
31          this.capacity = capacity;
32          this.objectStore = objectStore;
33      }
34  
35      @Override
36      public int hashCode()
37      {
38          final int prime = 31;
39          int result = 1;
40          result = prime * result + capacity;
41          result = prime * result + objectStore.hashCode();
42          return result;
43      }
44  
45      @Override
46      public boolean equals(Object obj)
47      {
48          if (this == obj)
49          {
50              return true;
51          }
52          if (obj == null)
53          {
54              return false;
55          }
56          if (getClass() != obj.getClass())
57          {
58              return false;
59          }
60          QueueConfiguration other = (QueueConfiguration) obj;
61          if (capacity != other.capacity)
62          {
63              return false;
64          }
65          if (!objectStore.equals(objectStore))
66          {
67              return false;
68          }
69          return true;
70      }
71  
72      public boolean isPersistent()
73      {
74          return objectStore.isPersistent();
75      }
76  }