Skip to content

Instantly share code, notes, and snippets.

@samidalouche
Created January 27, 2011 21:10
Show Gist options
  • Save samidalouche/799276 to your computer and use it in GitHub Desktop.
Save samidalouche/799276 to your computer and use it in GitHub Desktop.
Conversion to scala from the java code :
@Override
public int hashCode() {
return new HashCodeBuilder()
.append(alpha3Code)
.toHashCode();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Iso639Language other = (Iso639Language) obj;
return new EqualsBuilder()
.append(alpha3Code, other.getAlpha3Code())
.isEquals();
}
Scala code :
override def hashCode(): Int = Objects.hashCode(alpha3Code)
override def equals(other: Any): Boolean = other match {
case that: Language => this.alpha3Code == that.alpha3Code
case _ => false
}
(to be totally fair, Objects.hashCode comes from guava, so it could be used in the java code too)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment