Skip to content

Instantly share code, notes, and snippets.

@yanhua365
Created November 25, 2013 08:05
Show Gist options
  • Save yanhua365/7637974 to your computer and use it in GitHub Desktop.
Save yanhua365/7637974 to your computer and use it in GitHub Desktop.
用IntelliJ IDEA生成的equals和hashCode方法
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UpdateConfig that = (UpdateConfig) o;
if (!fromVersion.equals(that.fromVersion)) return false;
if (!targetVersion.equals(that.targetVersion)) return false;
return true;
}
@Override
public int hashCode() {
int result = targetVersion.hashCode();
result = 31 * result + fromVersion.hashCode();
return result;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UpdateConfig that = (UpdateConfig) o;
if (fromVersion != null ? !fromVersion.equals(that.fromVersion) : that.fromVersion != null) return false;
if (targetVersion != null ? !targetVersion.equals(that.targetVersion) : that.targetVersion != null)
return false;
return true;
}
@Override
public int hashCode() {
int result = targetVersion != null ? targetVersion.hashCode() : 0;
result = 31 * result + (fromVersion != null ? fromVersion.hashCode() : 0);
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment