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.core.persistence.jpa.entity;
20  
21  import java.io.Serializable;
22  import javax.persistence.Embeddable;
23  import org.apache.commons.lang3.builder.EqualsBuilder;
24  import org.apache.commons.lang3.builder.HashCodeBuilder;
25  import org.apache.commons.lang3.builder.ToStringBuilder;
26  import org.apache.syncope.core.persistence.api.entity.ConnPoolConf;
27  
28  @Embeddable
29  public class JPAConnPoolConf implements ConnPoolConf, Serializable {
30  
31      private static final long serialVersionUID = -34259572059178970L;
32  
33      private Integer maxObjects;
34  
35      private Integer minIdle;
36  
37      private Integer maxIdle;
38  
39      private Long maxWait;
40  
41      private Long minEvictableIdleTimeMillis;
42  
43      @Override
44      public Integer getMaxObjects() {
45          return maxObjects;
46      }
47  
48      @Override
49      public void setMaxObjects(final Integer maxObjects) {
50          this.maxObjects = maxObjects;
51      }
52  
53      @Override
54      public Integer getMinIdle() {
55          return minIdle;
56      }
57  
58      @Override
59      public void setMinIdle(final Integer minIdle) {
60          this.minIdle = minIdle;
61      }
62  
63      @Override
64      public Integer getMaxIdle() {
65          return maxIdle;
66      }
67  
68      @Override
69      public void setMaxIdle(final Integer maxIdle) {
70          this.maxIdle = maxIdle;
71      }
72  
73      @Override
74      public Long getMaxWait() {
75          return maxWait;
76      }
77  
78      @Override
79      public void setMaxWait(final Long maxWait) {
80          this.maxWait = maxWait;
81      }
82  
83      @Override
84      public Long getMinEvictableIdleTimeMillis() {
85          return minEvictableIdleTimeMillis;
86      }
87  
88      @Override
89      public void setMinEvictableIdleTimeMillis(final Long minEvictableIdleTimeMillis) {
90          this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
91      }
92  
93      @Override
94      public int hashCode() {
95          return new HashCodeBuilder().
96                  append(maxObjects).
97                  append(minIdle).
98                  append(maxIdle).
99                  append(maxWait).
100                 append(minEvictableIdleTimeMillis).
101                 build();
102     }
103 
104     @Override
105     public boolean equals(final Object obj) {
106         if (this == obj) {
107             return true;
108         }
109         if (obj == null) {
110             return false;
111         }
112         if (getClass() != obj.getClass()) {
113             return false;
114         }
115         final JPAConnPoolConf other = (JPAConnPoolConf) obj;
116         return new EqualsBuilder().
117                 append(maxObjects, other.maxObjects).
118                 append(minIdle, other.minIdle).
119                 append(maxIdle, other.maxIdle).
120                 append(maxWait, other.maxWait).
121                 append(minEvictableIdleTimeMillis, other.minEvictableIdleTimeMillis).
122                 build();
123     }
124 
125     @Override
126     public String toString() {
127         return new ToStringBuilder(this).
128                 append(maxObjects).
129                 append(minIdle).
130                 append(maxIdle).
131                 append(maxWait).
132                 append(minEvictableIdleTimeMillis).
133                 build();
134     }
135 }