protected final void register(boolean isRewrite, LiRhsPart... children) { for (LiRhsPart part : children) { if (part == null) continue; part.setParent(this, isRewrite); } }
public static int structuralHashCode(LiRhsPart a[]) { if (a == null) { return 0; } int result = 1; for (LiRhsPart element : a) { result = 31 * result + (element == null ? 0 : element.structuralHashCode()); } return result; }
protected final void toString(StringBuilder sb, LiRhsPart[] parts, String separator) { boolean first = true; for (LiRhsPart p : parts) { if (first) { first = false; } else { sb.append(separator); } p.toString(sb); } }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; StructuralObject that = (StructuralObject) o; return part.structurallyEquals(that.part); }
protected static boolean structurallyEquals(LiRhsPart[] left, LiRhsPart[] right) { if (left == right) { return true; } if (left == null || right == null) { return false; } int length = left.length; if (right.length != length) { return false; } for (int i = 0; i < length; i++) { LiRhsPart l = left[i]; LiRhsPart r = right[i]; if (l == null ? r != null : !l.structurallyEquals(r)) return false; } return true; }
@Override public int hashCode() { return part.structuralHashCode(); }