@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof UserModel)) return false; UserModel that = (UserModel) o; return getDelegate() != null ? getDelegate().getId().equals(that.getId()) : false; }
@Override public int hashCode() { return getDelegate().getId().hashCode(); } }
public MongoUserEntity getMongoUserEntity(UserModel user) { if (user instanceof UserAdapter) { UserAdapter adapter = (UserAdapter)user; return adapter.getMongoEntity(); } else if (user instanceof CachedUserModel) { UserModel delegate = ((CachedUserModel)user).getDelegateForUpdate(); return getMongoUserEntity(delegate); } else if (user instanceof UserModelDelegate){ UserModel delegate = ((UserModelDelegate) user).getDelegate(); return getMongoUserEntity(delegate); } else { return getMongoStore().loadEntity(MongoUserEntity.class, user.getId(), invocationContext); } }