Last change
on this file since 193 was
193,
checked in by Maciej Komosinski, 10 years ago
|
Set svn:eol-style native for all textual files
|
-
Property svn:eol-style set to
native
|
File size:
809 bytes
|
Rev | Line | |
---|
[84] | 1 | package com.framsticks.util.lang; |
---|
| 2 | |
---|
| 3 | /** |
---|
| 4 | * @author Piotr Sniegowski |
---|
| 5 | */ |
---|
| 6 | public class Pair<T1, T2> { |
---|
| 7 | public final T1 first; |
---|
| 8 | public final T2 second; |
---|
| 9 | |
---|
| 10 | public Pair(T1 first, T2 second) { |
---|
| 11 | this.first = first; |
---|
| 12 | this.second = second; |
---|
| 13 | } |
---|
| 14 | |
---|
| 15 | @Override |
---|
| 16 | public String toString() { |
---|
[86] | 17 | return Strings.toStringNullProof(first) + " : " + Strings.toStringNullProof(second); |
---|
[84] | 18 | } |
---|
| 19 | |
---|
[87] | 20 | @Override |
---|
| 21 | public boolean equals(Object obj) { |
---|
| 22 | if (!(obj instanceof Pair)) { |
---|
| 23 | return false; |
---|
| 24 | } |
---|
| 25 | Pair<?, ?> p = (Pair<?, ?>) obj; |
---|
| 26 | return first.equals(p.first) && second.equals(p.second); |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | @Override |
---|
| 30 | public int hashCode() { |
---|
| 31 | return (first != null ? first.hashCode() : 0) ^ (second != null ? second.hashCode() : 0); |
---|
| 32 | } |
---|
| 33 | |
---|
[96] | 34 | public static <U1, U2> Pair<U1, U2> make(U1 first, U2 second) { |
---|
| 35 | return new Pair<U1, U2>(first, second); |
---|
| 36 | } |
---|
| 37 | |
---|
[84] | 38 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.