Pair of template arguments : Generic Class « Generics « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JDK 6
25.JNDI LDAP
26.JPA
27.JSP
28.JSTL
29.Language Basics
30.Network Protocol
31.PDF RTF
32.Reflection
33.Regular Expressions
34.Scripting
35.Security
36.Servlets
37.Spring
38.Swing Components
39.Swing JFC
40.SWT JFace Eclipse
41.Threads
42.Tiny Application
43.Velocity
44.Web Services SOA
45.XML
Java Tutorial
Java Book
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
SCJP
Java » Generics » Generic ClassScreenshots 
Pair of template arguments
   

/* $Id$
 *
 * Behavior Protocols Tools - Parsers, Transformations
 * Copyright (C) 2006-2007  DSRG, Charles University in Prague
 *                          http://dsrg.mff.cuni.cz/
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301 USA
 *
 */

package org.ow2.dsrg.fm.bptools.util;


/**
 * Keeps pair of values whose type is given by template arguments
 @author thorm
 */
public class Pair<T1, T2> {
    
    /**
     * Creates a new instance of Pair
     @param first first value
     @param second second value
     */
    public Pair(T1 first, T2 second) {
        this.first = first;
        this.second = second;
    }
    
    public boolean equals(Object obj) {
        if (obj instanceof Pair) {
            Pair other = (Pair)obj;
             return (other.first == null this.first == null : other.first.equals(this.first)) && 
                     (other.second == null this.second == null : other.second.equals(this.second));
        }
        else
            return false;
    }

    public String toString(){
        return first.toString() +"::"+second.toString() ;
    }

    
    /**
     * first value
     */
    public T1 first;

    /**
     * second value
     */
    public T2 second;
}

   
    
    
  
Related examples in the same category
1.A simple generic class. A simple generic class.
2.Demonstrate the non generic classDemonstrate the non generic class
3.Stats attempts (unsuccessfully) to create a generic class
4.A simple generic class hierarchy.A simple generic class hierarchy.
5.A nongeneric class can be the superclass of a generic subclass.A nongeneric class can be the superclass of a generic subclass.
6.Use the instanceof operator with a generic class hierarchy. Use the instanceof operator with a generic class hierarchy.
7.Java hierarchy generic classJava hierarchy generic class
8.Custom Generic Object TesterCustom Generic Object Tester
9.Generic pair structure
10.Simple STL Pair Implementation
www___.___j___a_va2__s_.__co_m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.