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