Merge pull request #96 from bzz/add-unknown-lang

Java bindings: add some convenience
This commit is contained in:
Alfredo Beaumont 2017-08-11 17:42:49 +02:00 committed by GitHub
commit 554c9254ae
3 changed files with 31 additions and 0 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ benchmarks/output
.ci
Makefile.main
.shared
.idea

View File

@ -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;
/**

View File

@ -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;
}
}