001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.client;
019
020import org.apache.yetus.audience.InterfaceAudience;
021
022@InterfaceAudience.Private
023public final class RegionStatesCount {
024
025  private int openRegions;
026  private int splitRegions;
027  private int closedRegions;
028  private int regionsInTransition;
029  private int totalRegions;
030
031  private RegionStatesCount() {
032  }
033
034  public int getClosedRegions() {
035    return closedRegions;
036  }
037
038  public int getOpenRegions() {
039    return openRegions;
040  }
041
042  public int getSplitRegions() {
043    return splitRegions;
044  }
045
046  public int getRegionsInTransition() {
047    return regionsInTransition;
048  }
049
050  public int getTotalRegions() {
051    return totalRegions;
052  }
053
054  private void setClosedRegions(int closedRegions) {
055    this.closedRegions = closedRegions;
056  }
057
058  private void setOpenRegions(int openRegions) {
059    this.openRegions = openRegions;
060  }
061
062  private void setSplitRegions(int splitRegions) {
063    this.splitRegions = splitRegions;
064  }
065
066  private void setRegionsInTransition(int regionsInTransition) {
067    this.regionsInTransition = regionsInTransition;
068  }
069
070  private void setTotalRegions(int totalRegions) {
071    this.totalRegions = totalRegions;
072  }
073
074  public static class RegionStatesCountBuilder {
075    private int openRegions;
076    private int splitRegions;
077    private int closedRegions;
078    private int regionsInTransition;
079    private int totalRegions;
080
081    public RegionStatesCountBuilder setOpenRegions(int openRegions) {
082      this.openRegions = openRegions;
083      return this;
084    }
085
086    public RegionStatesCountBuilder setSplitRegions(int splitRegions) {
087      this.splitRegions = splitRegions;
088      return this;
089    }
090
091    public RegionStatesCountBuilder setClosedRegions(int closedRegions) {
092      this.closedRegions = closedRegions;
093      return this;
094    }
095
096    public RegionStatesCountBuilder setRegionsInTransition(int regionsInTransition) {
097      this.regionsInTransition = regionsInTransition;
098      return this;
099    }
100
101    public RegionStatesCountBuilder setTotalRegions(int totalRegions) {
102      this.totalRegions = totalRegions;
103      return this;
104    }
105
106    public RegionStatesCount build() {
107      RegionStatesCount regionStatesCount = new RegionStatesCount();
108      regionStatesCount.setOpenRegions(openRegions);
109      regionStatesCount.setClosedRegions(closedRegions);
110      regionStatesCount.setRegionsInTransition(regionsInTransition);
111      regionStatesCount.setSplitRegions(splitRegions);
112      regionStatesCount.setTotalRegions(totalRegions);
113      return regionStatesCount;
114    }
115  }
116
117  @Override
118  public String toString() {
119    final StringBuilder sb = new StringBuilder("RegionStatesCount{");
120    sb.append("openRegions=").append(openRegions);
121    sb.append(", splitRegions=").append(splitRegions);
122    sb.append(", closedRegions=").append(closedRegions);
123    sb.append(", regionsInTransition=").append(regionsInTransition);
124    sb.append(", totalRegions=").append(totalRegions);
125    sb.append('}');
126    return sb.toString();
127  }
128
129  @Override
130  public boolean equals(Object o) {
131    if (this == o) {
132      return true;
133    }
134    if (o == null || getClass() != o.getClass()) {
135      return false;
136    }
137
138    RegionStatesCount that = (RegionStatesCount) o;
139
140    if (openRegions != that.openRegions) {
141      return false;
142    }
143    if (splitRegions != that.splitRegions) {
144      return false;
145    }
146    if (closedRegions != that.closedRegions) {
147      return false;
148    }
149    if (regionsInTransition != that.regionsInTransition) {
150      return false;
151    }
152    return totalRegions == that.totalRegions;
153  }
154
155  @Override
156  public int hashCode() {
157    int result = openRegions;
158    result = 31 * result + splitRegions;
159    result = 31 * result + closedRegions;
160    result = 31 * result + regionsInTransition;
161    result = 31 * result + totalRegions;
162    return result;
163  }
164
165}