All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ibm.icu.impl.Pair Maven / Gradle / Ivy

Go to download

International Component for Unicode for Java (ICU4J) is a mature, widely used Java library providing Unicode and Globalization support

There is a newer version: 76.1
Show newest version
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
 *******************************************************************************
 * Copyright (C) 2014, International Business Machines Corporation and
 * others. All Rights Reserved.
 *******************************************************************************
 */
package com.ibm.icu.impl;

/**
 * A pair of objects: first and second.
 *
 * @param  first object type
 * @param  second object type
 */
public class Pair {
    public final F first;
    public final S second;
    
    protected Pair(F first, S second) {
        this.first = first;
        this.second = second;
    }
      
    /**
     * Creates a pair object
     * @param first must be non-null
     * @param second must be non-null
     * @return The pair object.
     */
    public static  Pair of(F first, S second) {
        if (first == null || second == null) {
            throw new IllegalArgumentException("Pair.of requires non null values.");
        }
        return new Pair(first, second);
    }
        
    @Override
    public boolean equals(Object other) {
        if (other == this) {
            return true;
        }
        if (!(other instanceof Pair)) {
            return false;
        }
        Pair rhs = (Pair) other;
        return first.equals(rhs.first) && second.equals(rhs.second);
    }
        
    @Override
    public int hashCode() {
        return first.hashCode() * 37 + second.hashCode();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy