+++ /dev/null
-/*--------------------------------------------------------------------------\r
- * Copyright 2004 Taro L. Saito\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *--------------------------------------------------------------------------*/\r
-//--------------------------------------\r
-// XerialJ\r
-//\r
-// Pair.java\r
-// Since: 2004/12/27\r
-//\r
-// $URL: http://www.xerial.org/svn/project/XerialJ/trunk/xerial-core/src/main/java/org/xerial/util/Pair.java $ \r
-// $Author: leo $\r
-//--------------------------------------\r
-package org.xerial.util;\r
-\r
-/**\r
- * Pair of two objects\r
- * \r
- * @author leo\r
- * \r
- */\r
-public class Pair<X, Y>\r
-{\r
- private final X first;\r
- private final Y second;\r
-\r
- /**\r
- * \r
- */\r
- public Pair(X x, Y y)\r
- {\r
- if (x == null || y == null)\r
- throw new NullPointerException();\r
-\r
- this.first = x;\r
- this.second = y;\r
- }\r
-\r
- public X getFirst()\r
- {\r
- return first;\r
- }\r
-\r
- public Y getSecond()\r
- {\r
- return second;\r
- }\r
-\r
- public static <X, Y> Pair<X, Y> newPair(X x, Y y)\r
- {\r
- return new Pair<X, Y>(x, y);\r
- }\r
-\r
- @Override\r
- public String toString()\r
- {\r
- return String.format("(%s, %s)", first, second);\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- @Override\r
- public boolean equals(Object obj)\r
- {\r
- if (obj instanceof Pair)\r
- {\r
- Pair other = (Pair) obj;\r
- return first.equals(other.first) && second.equals(other.second);\r
- }\r
- return false;\r
- }\r
-\r
- @Override\r
- public int hashCode()\r
- {\r
- return (first.hashCode() * 127 + second.hashCode() * 127) % 1987;\r
- }\r
-}\r