1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-11-17 08:03:09 -08:00

Replace some recent android API features with backwards compatible ones.

This commit is contained in:
Danila Fedorin 2017-09-24 12:58:33 -07:00
parent 378ff946d9
commit 6a0b667c32
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.