001
002 /*****************************************************************************
003
004 jBudget.
005 Copyright (C) 2006 Dmitri Petrov
006
007 This program is free software: you can redistribute it and/or modify
008 it under the terms of the GNU General Public License as published by
009 the Free Software Foundation, either version 3 of the License, or
010 (at your option) any later version.
011
012 This program is distributed in the hope that it will be useful,
013 but WITHOUT ANY WARRANTY; without even the implied warranty of
014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015 GNU General Public License for more details.
016
017 You should have received a copy of the GNU General Public License
018 along with this program. If not, see <http://www.gnu.org/licenses/>.
019
020 /*****************************************************************************
021
022 /*
023 * Pair.java
024 *
025 * Created on May 12, 2006, 6:12 PM
026 */
027
028 package org.jbudget.util;
029
030 /**
031 * A generic class that contains references to two objects of different
032 * types.
033 * @author petrov
034 */
035 public class Triplet<T,U,V> extends Pair<T,U>
036 {
037 private final V thirdElement;
038
039 /** Creates a new instance of Pair */
040 public Triplet(T first, U second, V third){
041 super(first, second);
042 thirdElement = third;
043 }
044
045 public V third(){return thirdElement;}
046
047 public boolean equals (Object o){
048
049 if (!super.equals(o))
050 return false;
051
052 if (!(o instanceof Triplet))
053 return false;
054
055 Triplet other = (Triplet)o;
056 return thirdElement.equals(other.thirdElement);
057 }
058
059 public String toString(){
060 return super.toString() + ":" + thirdElement.toString();
061 }
062
063 }