1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-12-21 23:10:09 -08:00

Merge pull request #43 from DanilaFe/java8-subset

Replace some recent android API features with backwards compatible ones.
This commit is contained in:
Danila Fedorin 2017-09-24 13:04:23 -07:00 committed by GitHub
commit 08e5b69c04
2 changed files with 7 additions and 4 deletions

View File

@ -79,10 +79,10 @@ public class Lexer<T> {
index++;
}
matches.sort((a, b) -> compare.compare(a.getType(), b.getType()));
if (compare != null) {
matches.sort(Comparator.comparingInt(a -> a.getContent().length()));
Collections.sort(matches, (a, b) -> compare.compare(a.getType(), b.getType()));
}
Collections.sort(matches, (o1, o2) -> o1.getContent().length() - o2.getContent().length());
return matches.isEmpty() ? null : matches.get(matches.size() - 1);
}
@ -136,7 +136,10 @@ public class Lexer<T> {
@Override
public int hashCode() {
return Objects.hash(name, id);
return Arrays.hashCode(new Object[] {
this.name,
this.id
});
}
@Override

View File

@ -20,7 +20,7 @@ public class LexerTokenizer implements Tokenizer<Match<TokenType>>, PluginListen
/**
* Comparator used to sort the tokens produced by the lexer.
*/
protected static final Comparator<TokenType> TOKEN_SORTER = Comparator.comparingInt(e -> e.priority);
protected static final Comparator<TokenType> TOKEN_SORTER = (o1, o2) -> o1.priority - o2.priority;
/**
* The lexer instance used to turn strings into matches.