Skip to content

Commit

Permalink
refactor: DefaultWordTokenizer
Browse files Browse the repository at this point in the history
 - use isEmpty for size zero comparison
 - make private fields final
 - unused arguments in private method
  • Loading branch information
miurahr committed May 17, 2024
1 parent 7271d10 commit 110c9b8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/main/java/org/dts/spell/tokenizer/DefaultWordTokenizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
*/
public class DefaultWordTokenizer extends AbstractWordTokenizer
{
private BreakIterator wordIterator ;
private final BreakIterator wordIterator ;

private CharIteratorAdapter wordSequence = new CharIteratorAdapter() ;
private final CharIteratorAdapter wordSequence = new CharIteratorAdapter() ;

public DefaultWordTokenizer()
{
Expand All @@ -38,7 +38,7 @@ protected Word scanBefore(CharSequence sequence, int index)

String text = sequence.subSequence(start, end).toString().trim() ;

if (!text.equals(""))
if (!text.isEmpty())
return new Word(text, start, isStartOfSentence(sequence, start)) ;
else
return null ;
Expand All @@ -54,7 +54,7 @@ protected Word scanAfter(CharSequence sequence, int index)

String text = sequence.subSequence(start, end).toString().trim() ;

if (!text.equals(""))
if (!text.isEmpty())
return new Word(text, start, isStartOfSentence(sequence, start)) ;
else
return null ;
Expand Down Expand Up @@ -95,12 +95,12 @@ private void onChangeSequence()
wordIterator.setText(wordSequence) ;
}

private void onInsertChars(int start, int end)
private void onInsertChars()
{
onChangeSequence() ;
}

private void onDeleteChars(int start, int end)
private void onDeleteChars()
{
onChangeSequence() ;
}
Expand All @@ -114,11 +114,11 @@ public void updateCharSequence(int start, int end, int cause)
break ;

case INSERT_CHARS:
onInsertChars(start, end) ;
onInsertChars() ;
break ;

case DELETE_CHARS:
onDeleteChars(start, end) ;
onDeleteChars() ;
break ;
}
}
Expand Down

0 comments on commit 110c9b8

Please sign in to comment.