sS tok_genEqualsAndHashCode(S className, L> fields) { ret [[public bool equals(O o) { if (!o instanceof ]] + className + [[) false; ]] + className + [[ x = cast o; ret ]] + or2(join(" && ", map(fields, func(Pair p) -> S { // TODO: use == for primitive fields "eq(" + p.b + ", x." + p.b + ")" })), "true") + [[; } public int hashCode() { int h = ]] + hashCode(className) + [[; ]] + concatMap_strings(fields, func(Pair p) { "h = boostHashCombine(h, _hashCode(" + p.b + [[)); ]]}) + [[ret h; } ]]; }