2 * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.genius.idmanager;
10 public class IdLocalPool {
12 private final String poolName;
13 private volatile IdHolder availableIds; // List of available IDs
14 private volatile IdHolder releasedIds; // List of released IDs
16 public IdLocalPool(IdUtils idUtils, String poolName, long low, long high) {
17 this.poolName = poolName;
18 availableIds = new AvailableIdHolder(idUtils, low, high);
19 releasedIds = new ReleasedIdHolder(idUtils, IdUtils.DEFAULT_DELAY_TIME);
22 public IdLocalPool(IdUtils idUtils, String poolName) {
23 this.poolName = poolName;
24 releasedIds = new ReleasedIdHolder(idUtils, IdUtils.DEFAULT_DELAY_TIME);
28 public int hashCode() {
31 result = prime * result + (availableIds == null ? 0 : availableIds.hashCode());
32 result = prime * result + (poolName == null ? 0 : poolName.hashCode());
33 result = prime * result + (releasedIds == null ? 0 : releasedIds.hashCode());
38 public String toString() {
39 return "IdLocalPool [poolName=" + poolName + ", availableIds="
40 + availableIds + ", releasedIds=" + releasedIds + "]";
44 public boolean equals(Object obj) {
51 if (getClass() != obj.getClass()) {
54 IdLocalPool other = (IdLocalPool) obj;
55 if (availableIds == null) {
56 if (other.availableIds != null) {
59 } else if (!availableIds.equals(other.availableIds)) {
62 if (poolName == null) {
63 if (other.poolName != null) {
66 } else if (!poolName.equals(other.poolName)) {
69 if (releasedIds == null) {
70 if (other.releasedIds != null) {
73 } else if (!releasedIds.equals(other.releasedIds)) {
79 public String getPoolName() {
83 public IdHolder getAvailableIds() {
87 public void setAvailableIds(IdHolder availableIds) {
88 this.availableIds = availableIds;
91 public IdHolder getReleasedIds() {
95 public void setReleasedIds(IdHolder releasedIds) {
96 this.releasedIds = releasedIds;