Created
January 27, 2011 21:10
-
-
Save samidalouche/799276 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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