2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com
.intellij
.openapi
.util
;
18 import java
.util
.Arrays
;
24 public class Pair
<A
, B
> {
26 public final B second
;
28 public Pair(A first
, B second
) {
33 public final A
getFirst() {
37 public final B
getSecond() {
41 public static <A
, B
> Pair
<A
, B
> create(A first
, B second
) {
42 return new Pair
<A
,B
>(first
, second
);
45 public final boolean equals(Object o
){
46 return o
instanceof Pair
&& Comparing
.equal(first
, ((Pair
)o
).first
) && Comparing
.equal(second
, ((Pair
)o
).second
);
49 public final int hashCode(){
52 hashCode
+= hashCode(first
);
55 hashCode
+= hashCode(second
);
60 private static int hashCode(final Object o
) {
61 return (o
instanceof Object
[]) ? Arrays
.hashCode((Object
[])o
) : o
.hashCode();
64 public String
toString() {
65 return "<" + first
+ "," + second
+ ">";