~cpn-gui/tapaal/bug-fixing3

« back to all changes in this revision

Viewing changes to src/dk/aau/cs/model/tapn/Colored/Pair.java

  • Committer: Mark Glavind
  • Date: 2019-04-02 09:42:28 UTC
  • mfrom: (1021.1.10 loadPNML)
  • Revision ID: mglavi14@student.aau.dk-20190402094228-qb0n0o36m7i51by2
merge from load PNML, feature completed

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package dk.aau.cs.model.tapn.Colored;
 
2
 
 
3
public class Pair<A, B> {
 
4
    private A first;
 
5
    private B second;
 
6
 
 
7
    public Pair(A first, B second) {
 
8
        super();
 
9
        this.first = first;
 
10
        this.second = second;
 
11
    }
 
12
 
 
13
    public int hashCode() {
 
14
        int hashFirst = first != null ? first.hashCode() : 0;
 
15
        int hashSecond = second != null ? second.hashCode() : 0;
 
16
 
 
17
        return (hashFirst + hashSecond) * hashSecond + hashFirst;
 
18
    }
 
19
 
 
20
    public boolean equals(Object other) {
 
21
        if (other instanceof Pair) {
 
22
            Pair otherPair = (Pair) other;
 
23
            return
 
24
                    ((  this.first == otherPair.first ||
 
25
                            ( this.first != null && otherPair.first != null &&
 
26
                                    this.first.equals(otherPair.first))) &&
 
27
                            (  this.second == otherPair.second ||
 
28
                                    ( this.second != null && otherPair.second != null &&
 
29
                                            this.second.equals(otherPair.second))) );
 
30
        }
 
31
 
 
32
        return false;
 
33
    }
 
34
 
 
35
    public String toString()
 
36
    {
 
37
        return "(" + first + ", " + second + ")";
 
38
    }
 
39
 
 
40
    public A getFirst() {
 
41
        return first;
 
42
    }
 
43
 
 
44
    public void setFirst(A first) {
 
45
        this.first = first;
 
46
    }
 
47
 
 
48
    public B getSecond() {
 
49
        return second;
 
50
    }
 
51
 
 
52
    public void setSecond(B second) {
 
53
        this.second = second;
 
54
    }
 
55
}