Skip to content

Commit

Permalink
Merge pull request #96 from bzz/add-unknown-lang
Browse files Browse the repository at this point in the history
Java bindings: add some convenience
  • Loading branch information
abeaumont authored Aug 11, 2017
2 parents 2c6a48e + 0a6ed07 commit 554c925
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ benchmarks/output
.ci
Makefile.main
.shared
.idea
2 changes: 2 additions & 0 deletions java/src/main/java/tech/sourced/enry/Enry.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import static tech.sourced.enry.GoUtils.*;

public class Enry {
public static final Guess unknownLanguage = new Guess("", false);

private static final EnryLibrary nativeLib = EnryLibrary.INSTANCE;

/**
Expand Down
28 changes: 28 additions & 0 deletions java/src/main/java/tech/sourced/enry/Guess.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,32 @@ public Guess(String language, boolean safe) {
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;
}
}

0 comments on commit 554c925

Please sign in to comment.