@Test public void testExtractAllNoHashtags() { String content = "Hello there! What's up?"; assertEquals(0, sut.extractAll(content).size()); }
public List<String> extractAll(final String content) { Set<String> hashTagContents = new HashSet<String>(); Substring hashTag; int position = 0; while (null != (hashTag = extract(content, position))) { position = hashTag.getStartIndex() + hashTag.getLength(); hashTagContents.add(hashTag.getContent()); } return new ArrayList<String>(hashTagContents); }
HashTagExtractor { public List<String> extractAll(final String content) { Set<String> hashTagContents = new HashSet<String>(); Substring hashTag; int position = 0; while (null != (hashTag = extract(content, position))) { position = hashTag.getStartIndex() + hashTag.getLength(); hashTagContents.add(hashTag.getContent()); } return new ArrayList<String>(hashTagContents); } }
HashTagExtractor { public List<String> extractAll(final String content) { Set<String> hashTagContents = new HashSet<String>(); Substring hashTag; int position = 0; while (null != (hashTag = extract(content, position))) { position = hashTag.getStartIndex() + hashTag.getLength(); hashTagContents.add(hashTag.getContent()); } return new ArrayList<String>(hashTagContents); }  }
HashTagExtractor { public List<String> extractAll(final String content) { Set<String> hashTagContents = new HashSet<String>(); Substring hashTag; int position = 0; while (null != (hashTag = extract(content, position))) { position = hashTag.getStartIndex() + hashTag.getLength(); hashTagContents.add(hashTag.getContent()); } return new ArrayList<String>(hashTagContents); }  Substring extract(final String content, final int inStartingIndex); List<String> extractAll(final String content); }
HashTagExtractor { public List<String> extractAll(final String content) { Set<String> hashTagContents = new HashSet<String>(); Substring hashTag; int position = 0; while (null != (hashTag = extract(content, position))) { position = hashTag.getStartIndex() + hashTag.getLength(); hashTagContents.add(hashTag.getContent()); } return new ArrayList<String>(hashTagContents); }  Substring extract(final String content, final int inStartingIndex); List<String> extractAll(final String content);  }