View Javadoc

1   /**
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  package org.apache.hadoop.hbase.client;
20  
21  import org.apache.hadoop.classification.InterfaceAudience;
22  
23  /**
24   * A Get, Put or Delete associated with it's region.  Used internally by  
25   * {@link HTable#batch} to associate the action with it's region and maintain
26   * the index from the original request. 
27   */
28  @InterfaceAudience.Private
29  public class Action<R> implements Comparable<R> {
30    // TODO: This class should not be visible outside of the client package.
31    private Row action;
32    private int originalIndex;
33  
34    public Action(Row action, int originalIndex) {
35      super();
36      this.action = action;
37      this.originalIndex = originalIndex;    
38    }
39  
40  
41    public Row getAction() {
42      return action;
43    }
44  
45    public int getOriginalIndex() {
46      return originalIndex;
47    }
48  
49    @SuppressWarnings("rawtypes")
50    @Override
51    public int compareTo(Object o) {
52      return action.compareTo(((Action) o).getAction());
53    }
54  
55    @Override
56    public int hashCode() {
57      return this.action.hashCode();
58    }
59  
60    @Override
61    public boolean equals(Object obj) {
62      if (this == obj) return true;
63      if (obj == null || getClass() != obj.getClass()) return false;
64      Action<?> other = (Action<?>) obj;
65      return compareTo(other) == 0;
66    }
67  }