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.utils; 014 015import static org.apache.juneau.internal.ObjectUtils.*; 016 017import org.apache.juneau.internal.*; 018 019/** 020 * Represents a simple tuple of 5 objects. 021 * 022 * @param <A> Object 1 type. 023 * @param <B> Object 2 type. 024 * @param <C> Object 3 type. 025 * @param <D> Object 4 type. 026 * @param <E> Object 5 type. 027 */ 028public class Tuple5<A,B,C,D,E> { 029 030 /** 031 * Creator. 032 * 033 * @param <A> Object 1 type. 034 * @param <B> Object 2 type. 035 * @param <C> Object 3 type. 036 * @param <D> Object 4 type. 037 * @param <E> Object 5 type. 038 * @param a Object 1. 039 * @param b Object 2. 040 * @param c Object 3. 041 * @param d Object 4. 042 * @param e Object 5. 043 * @return A new tuple object. 044 */ 045 public static <A,B,C,D,E> Tuple5<A,B,C,D,E> of(A a, B b, C c, D d, E e) { 046 return new Tuple5<>(a,b,c,d, e); 047 } 048 049 private final A a; 050 private final B b; 051 private final C c; 052 private final D d; 053 private final E e; 054 055 /** 056 * Constructor. 057 * 058 * @param a Object 1. 059 * @param b Object 2. 060 * @param c Object 3. 061 * @param d Object 4. 062 * @param e Object 5. 063 */ 064 public Tuple5(A a, B b, C c, D d, E e) { 065 this.a = a; 066 this.b = b; 067 this.c = c; 068 this.d = d; 069 this.e = e; 070 } 071 072 /** 073 * Returns the first object in this tuple. 074 * 075 * @return The first object in this tuple. 076 */ 077 public A getA() { 078 return a; 079 } 080 081 /** 082 * Returns the second object in this tuple. 083 * 084 * @return The second object in this tuple. 085 */ 086 public B getB() { 087 return b; 088 } 089 090 /** 091 * Returns the third object in this tuple. 092 * 093 * @return The third object in this tuple. 094 */ 095 public C getC() { 096 return c; 097 } 098 099 /** 100 * Returns the fourth object in this tuple. 101 * 102 * @return The fourth object in this tuple. 103 */ 104 public D getD() { 105 return d; 106 } 107 108 /** 109 * Returns the fifth object in this tuple. 110 * 111 * @return The fifth object in this tuple. 112 */ 113 public E getE() { 114 return e; 115 } 116 117 @Override /* Object */ 118 public int hashCode() { 119 return HashCode.of(a,b,c,d,e); 120 } 121 122 @Override /* Object */ 123 public boolean equals(Object o) { 124 return o instanceof Tuple5 && eq(this, (Tuple5<?,?,?,?,?>)o, (x,y)->eq(x.a,y.a) && eq(x.b,y.b) && eq(x.c,y.c) && eq(x.d,y.d) && eq(x.e,y.e)); 125 } 126}