]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/tuple/Tuple2.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.scl.runtime / src / org / simantics / scl / runtime / tuple / Tuple2.java
1 /**
2  * This code is generated in org.simantics.scl.runtime.generation.GenerateTuples.
3  * Do not edit manually!
4  */
5 package org.simantics.scl.runtime.tuple;
6
7 public class Tuple2 implements Tuple {
8     public final Object c0;
9     public final Object c1;
10
11     public Tuple2(Object c0, Object c1) {
12         this.c0 = c0;
13         this.c1 = c1;
14     }
15
16     public int length() {
17         return 2;
18     }
19
20     public Object get(int id) {
21         switch(id) {
22         case 0: return c0;
23         case 1: return c1;
24         default: throw new IndexOutOfBoundsException();
25         }
26     }
27
28     public Object[] toArray() {
29         return new Object[] { c0, c1 };
30     }
31
32     @Override
33     public boolean equals(Object obj) {
34         if(obj == this)
35             return true;
36         if(obj == null || obj.getClass() != getClass())
37             return false;
38         Tuple2 tuple = (Tuple2)obj;
39         if(c0 == null) {
40             if(tuple.c0 != null)
41                 return false;
42         }
43         else if(!c0.equals(tuple.c0))
44             return false;
45         if(c1 == null) {
46             if(tuple.c1 != null)
47                 return false;
48         }
49         else if(!c1.equals(tuple.c1))
50             return false;
51         return true;
52     }
53
54     @Override
55     public int hashCode() {
56         int result = c0 == null ? 0 : c0.hashCode();
57         result *= 31;
58         if(c1 != null)
59             result += c1.hashCode();
60         return result;
61     }
62
63     @Override
64     public String toString() {
65         StringBuilder b = new StringBuilder();
66         b.append('(');
67         b.append(c0);
68         b.append(',');
69         b.append(c1);
70         b.append(')');
71         return b.toString();
72     }
73 }