TextLengthAnalyzer implements Analyzer<TextLengthStatistics> { @Override public boolean analyze(String... record) { if (record == null) { return true; } textStatistics.resize(record.length); for (int i = 0; i < record.length; i++) { TextLengthStatistics freqStats = textStatistics.get(i); freqStats.add(record[i]); } return true; }  @Override void init(); @Override boolean analyze(String... record); @Override void end(); @Override List<TextLengthStatistics> getResult(); @Override void close();  }
@Test public void testAnalyze() { String[] data = new String[] { "Brayan", "Ava", " ", "" }; for (String value : data) { analyzer.analyze(value); } TextLengthStatistics stats = analyzer.getResult().get(0); Assert.assertEquals(0, stats.getMinTextLength(), 0); Assert.assertEquals(3, stats.getMinTextLengthIgnoreBlank(), 0); Assert.assertEquals(6, stats.getMaxTextLength(), 0); Assert.assertEquals(6, stats.getMaxTextLengthIgnoreBlank(), 0); Assert.assertEquals(2.5, stats.getAvgTextLength(), 0); Assert.assertEquals(4.5, stats.getAvgTextLengthIgnoreBlank(), 0); }