mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-05-23 08:30:07 -03:00
Convenience: Enry.unknownLanguage and Guess.toString/.equals/.hashCode
This commit is contained in:
parent
2c6a48ef9e
commit
0a6ed07591
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ benchmarks/output
|
||||
.ci
|
||||
Makefile.main
|
||||
.shared
|
||||
.idea
|
||||
|
@ -5,6 +5,8 @@ import tech.sourced.enry.nativelib.*;
|
||||
import static tech.sourced.enry.GoUtils.*;
|
||||
|
||||
public class Enry {
|
||||
public static final Guess unknownLanguage = new Guess("", false);
|
||||
|
||||
private static final EnryLibrary nativeLib = EnryLibrary.INSTANCE;
|
||||
|
||||
/**
|
||||
|
@ -20,4 +20,32 @@ public class Guess {
|
||||
this.language = language;
|
||||
this.safe = safe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Guess{" +
|
||||
"language='" + language + '\'' + ", safe=" + safe +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) return true;
|
||||
if (object == null || getClass() != object.getClass()) return false;
|
||||
if (!super.equals(object)) return false;
|
||||
|
||||
Guess guess = (Guess) object;
|
||||
|
||||
if (safe != guess.safe) return false;
|
||||
if (language != null ? !language.equals(guess.language) : guess.language != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 23 * result + (language != null ? language.hashCode() : 0);
|
||||
result = 23 * result + (safe ? 1 : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user