Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: src/com/github/rjeschke/neetutils/collections/Tuple.java

Issue 5697499218051072: Usage of new API, cleanups (reduced) (Closed)
Left Patch Set: Fixed leftover first-batch review issues. Created April 16, 2014, 5:51 p.m.
Right Patch Set: Even more review issues fixed. Created April 28, 2014, 10:18 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/com/github/rjeschke/neetutils/Objects.java ('k') | src/org/adblockplus/ChunkedOutputStream.java » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 /*
2 * Copyright (C) 2012 René Jeschke <rene_jeschke@yahoo.de>
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package com.github.rjeschke.neetutils.collections;
17
18 import com.github.rjeschke.neetutils.Objects;
19
20 /**
21 *
22 * @author René Jeschke (rene_jeschke@yahoo.de)
23 *
24 * @param <A>
25 * @param <B>
26 */
27 public class Tuple<A, B>
28 {
29 public final A a;
30 public final B b;
31
32 public Tuple(final A a, final B b)
33 {
34 this.a = a;
35 this.b = b;
36 }
37
38 public final static <A, B> Tuple<A, B> of(final A a, final B b)
39 {
40 return new Tuple<A, B>(a, b);
41 }
42
43 @Override
44 public int hashCode()
45 {
46 return (this.a == null ? 0 : this.a.hashCode()) * 31 + (this.b == null ? 0 : this.b.hashCode());
47 }
48
49 @Override
50 public boolean equals(final Object obj)
51 {
52 if (obj == this)
53 {
54 return true;
55 }
56
57 if (!(obj instanceof Tuple))
58 {
59 return false;
60 }
61
62 final Tuple<?, ?> p = (Tuple<?, ?>)obj;
63
64 return Objects.equals(this.a, p.a) && Objects.equals(this.b, p.b);
65 }
66
67 @Override
68 public String toString()
69 {
70 return "(" + this.a.toString() + ", " + this.b.toString() + ")";
71 }
72 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld