View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.common.lib.types;
20  
21  import java.io.Serializable;
22  import org.apache.commons.lang3.builder.EqualsBuilder;
23  import org.apache.commons.lang3.builder.HashCodeBuilder;
24  import org.apache.commons.lang3.builder.ToStringBuilder;
25  import org.apache.commons.lang3.builder.ToStringStyle;
26  
27  public class ThreadPoolSettings implements Serializable {
28  
29      private static final long serialVersionUID = -3860071577309258396L;
30  
31      private int corePoolSize = 1;
32  
33      private int maxPoolSize = Integer.MAX_VALUE;
34  
35      private int queueCapacity = Integer.MAX_VALUE;
36  
37      public int getCorePoolSize() {
38          return corePoolSize;
39      }
40  
41      public void setCorePoolSize(final int corePoolSize) {
42          this.corePoolSize = corePoolSize;
43      }
44  
45      public int getMaxPoolSize() {
46          return maxPoolSize;
47      }
48  
49      public void setMaxPoolSize(final int maxPoolSize) {
50          this.maxPoolSize = maxPoolSize;
51      }
52  
53      public int getQueueCapacity() {
54          return queueCapacity;
55      }
56  
57      public void setQueueCapacity(final int queueCapacity) {
58          this.queueCapacity = queueCapacity;
59      }
60  
61      @Override
62      public int hashCode() {
63          return new HashCodeBuilder().
64                  append(corePoolSize).
65                  append(maxPoolSize).
66                  append(queueCapacity).
67                  build();
68      }
69  
70      @Override
71      public boolean equals(final Object obj) {
72          if (this == obj) {
73              return true;
74          }
75          if (obj == null) {
76              return false;
77          }
78          if (getClass() != obj.getClass()) {
79              return false;
80          }
81          final ThreadPoolSettings other = (ThreadPoolSettings) obj;
82          return new EqualsBuilder().
83                  append(corePoolSize, other.corePoolSize).
84                  append(maxPoolSize, other.maxPoolSize).
85                  append(queueCapacity, other.queueCapacity).
86                  build();
87      }
88  
89      @Override
90      public String toString() {
91          return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE).
92                  append(corePoolSize).
93                  append(maxPoolSize).
94                  append(queueCapacity).
95                  build();
96      }
97  }