1 18 19 package org.sablecc.sablecc.automaton; 20 21 import org.sablecc.sablecc.exception.InternalException; 22 23 27 class GroupPair<T extends Comparable <? super T>> { 28 29 30 private final Group<T> group1; 31 32 33 private final Group<T> group2; 34 35 36 private Integer hashcode; 37 38 42 private String toString; 43 44 54 GroupPair( 55 final Group<T> group1, 56 final Group<T> group2) { 57 58 if (group1 == null) { 59 throw new InternalException("group1 may not be null"); 60 } 61 62 if (group2 == null) { 63 throw new InternalException("group2 may not be null"); 64 } 65 66 this.group1 = group1; 67 this.group2 = group2; 68 } 69 70 75 Group<T> getGroup1() { 76 77 return this.group1; 78 } 79 80 85 Group<T> getGroup2() { 86 87 return this.group2; 88 } 89 90 99 @Override 100 public boolean equals( 101 Object obj) { 102 103 if (this == obj) { 104 return true; 105 } 106 107 if (obj == null) { 108 return false; 109 } 110 111 if (getClass() != obj.getClass()) { 112 return false; 113 } 114 115 GroupPair groupPair = (GroupPair) obj; 116 117 return this.group1.equals(groupPair.group1) 118 && this.group2.equals(groupPair.group2); 119 } 120 121 126 @Override 127 public int hashCode() { 128 129 if (this.hashcode == null) { 130 this.hashcode = this.group1.hashCode() + 29 131 * this.group2.hashCode(); 132 } 133 134 return this.hashcode; 135 } 136 137 142 @Override 143 public String toString() { 144 145 if (this.toString == null) { 146 this.toString = "(" + this.group1 + "," + this.group2 + ")"; 147 } 148 149 return this.toString; 150 } 151 } 152 | Popular Tags |