Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Pair.java
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 package com.cloudera.impala.common;
16 
20 public class Pair<F, S> {
21  public F first;
22  public S second;
23 
24  public Pair(F first, S second) {
25  this.first = first;
26  this.second = second;
27  }
28 
29  @Override
33  public boolean equals(Object o) {
34  if (o instanceof Pair) {
35  Pair<F,S> other = (Pair<F,S>) o;
36  return this.first.equals(other.first) && this.second.equals(other.second);
37  }
38  return false;
39  }
40 
41  @Override
42  public int hashCode() {
43  int hashFirst = first != null ? first.hashCode() : 0;
44  int hashSecond = second != null ? second.hashCode() : 0;
45 
46  return (hashFirst + hashSecond) * hashSecond + hashFirst;
47  }
48 
49  static public <F, S> Pair<F, S> create(F first, S second) {
50  return new Pair<F, S>(first, second);
51  }
52 }
static public< F, S > Pair< F, S > create(F first, S second)
Definition: Pair.java:49