001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.internal; 014 015/** 016 * Represents a simple object pair. 017 * 018 * @param <F> The first object type. 019 * @param <S> The second object type. 020 */ 021public class Pair<F,S> { 022 private final F first; 023 private final S second; 024 025 /** 026 * Constructor. 027 * 028 * @param first The first object in the pair. 029 * @param second The second object in the pair. 030 */ 031 public Pair(F first, S second) { 032 this.first = first; 033 this.second = second; 034 } 035 036 /** 037 * Returns the first object in the pair. 038 * 039 * @return The first object in the pair. 040 */ 041 public F first() { 042 return first; 043 } 044 045 /** 046 * Returns the second object in the pair. 047 * 048 * @return The second object in the pair. 049 */ 050 public S second() { 051 return second; 052 } 053 054 @Override /* Object */ 055 public boolean equals(Object o) { 056 if (o instanceof Pair) { 057 Pair<?,?> p = (Pair<?,?>)o; 058 return ObjectUtils.equals(first, p.first) && ObjectUtils.equals(second, p.second); 059 } 060 return false; 061 } 062 063 @Override /* Object */ 064 public int hashCode() { 065 return (first == null ? 0 : first.hashCode()) ^ (second == null ? 0 : second.hashCode()); 066 } 067}