001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.utils; 018 019import org.apache.juneau.common.utils.*; 020import org.apache.juneau.internal.*; 021 022/** 023 * Represents a simple tuple of 3 objects. 024 * 025 * <h5 class='section'>See Also:</h5><ul> 026 * </ul> 027 * 028 * @param <A> Object 1 type. 029 * @param <B> Object 2 type. 030 * @param <C> Object 3 type. 031 */ 032public class Tuple3<A,B,C> { 033 034 /** 035 * Static creator. 036 * 037 * @param <A> Object 1 type. 038 * @param <B> Object 2 type. 039 * @param <C> Object 3 type. 040 * @param a Object 1. 041 * @param b Object 2. 042 * @param c Object 3. 043 * @return A new tuple object. 044 */ 045 public static <A,B,C> Tuple3<A,B,C> of(A a, B b, C c) { 046 return new Tuple3<>(a,b,c); 047 } 048 049 private final A a; 050 private final B b; 051 private final C c; 052 053 /** 054 * Constructor. 055 * 056 * @param a Object 1. 057 * @param b Object 2. 058 * @param c Object 3. 059 */ 060 public Tuple3(A a, B b, C c) { 061 this.a = a; 062 this.b = b; 063 this.c = c; 064 } 065 066 /** 067 * Returns the first object in this tuple. 068 * 069 * @return The first object in this tuple. 070 */ 071 public A getA() { 072 return a; 073 } 074 075 /** 076 * Returns the second object in this tuple. 077 * 078 * @return The second object in this tuple. 079 */ 080 public B getB() { 081 return b; 082 } 083 084 /** 085 * Returns the third object in this tuple. 086 * 087 * @return The third object in this tuple. 088 */ 089 public C getC() { 090 return c; 091 } 092 093 @Override /* Object */ 094 public int hashCode() { 095 return HashCode.of(a,b,c); 096 } 097 098 @Override /* Object */ 099 public boolean equals(Object o) { 100 return o instanceof Tuple3 && Utils.eq(this, (Tuple3<?,?,?>)o, (x,y)->Utils.eq(x.a,y.a) && Utils.eq(x.b,y.b) && Utils.eq(x.c,y.c)); 101 } 102}