- «val fieldName = augmentField.name»
- if («fieldName» == null) {
- if (other.«fieldName» != null) {
+ if (getClass() == obj.getClass()) {
+ // Simple case: we are comparing against self
+ «type.name»«IMPL» otherImpl = («type.name»«IMPL») obj;
+ «val fieldName = augmentField.name»
+ if («fieldName» == null) {
+ if (otherImpl.«fieldName» != null) {
+ return false;
+ }
+ } else if(!«fieldName».equals(otherImpl.«fieldName»)) {
+ return false;
+ }
+ } else {
+ // Hard case: compare our augments with presence there...
+ for («Map.importedName».Entry<«Class.importedName»<? extends «augmentField.returnType.importedName»>, «augmentField.returnType.importedName»> e : «augmentField.name».entrySet()) {
+ if (!e.getValue().equals(other.getAugmentation(e.getKey()))) {
+ return false;
+ }
+ }
+ // .. and give the other one the chance to do the same
+ if (!obj.equals(this)) {