Update Trie.java (#70)
* Update Trie.java fix firstMatch NullPointerException * Update Trie.java change for shorter code
This commit is contained in:
parent
3ab8990aae
commit
413d63675b
@ -75,8 +75,8 @@ public class Trie {
|
|||||||
* @return null if no matches found.
|
* @return null if no matches found.
|
||||||
*/
|
*/
|
||||||
public Emit firstMatch(final CharSequence text) {
|
public Emit firstMatch(final CharSequence text) {
|
||||||
PayloadEmit<String> firstMatch = this.payloadTrie.firstMatch(text);
|
final PayloadEmit<String> payload = this.payloadTrie.firstMatch(text);
|
||||||
return new Emit(firstMatch.getStart(), firstMatch.getEnd(), firstMatch.getKeyword());
|
return payload == null ? null : new Emit(payload.getStart(), payload.getEnd(), payload.getKeyword());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user