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