打包组织和项目结构设计

I am trying to create a textsearcher library in java, that will have an interface TextSearcher and 3 classes implementing it: RegexPatternSearcher, SingleTokenSearcher and MultiTokenSearcher

I then created a TextSearcherFacade class that exposes static methods like:

  1. static findEmailAddresses(String input) - uses RegexPatternSearcher
  2. static findPhoneNumbers(String input) - uses RegexPatternSearcher
  3. static findDisallowedWords(String input, Set<String> disAllowedWords) - uses SingleTokenSearcher

I want users of the library to have these (i.e. methods from TextSearcherFacade) simple methods exposed for ease of use.

However, I don't like the idea of a single TextSearcherFacade class with methods that configure and create the RegexPatternSearcher, SingleTokenSearcher and MultiTokenSearcher because these methods depend on different classes and seem logically different.

我正在尝试寻找一种更好和更可扩展的方法来设计此库。任何帮助是极大的赞赏。

评论
yut
yut

You could create a class for each of your find methods. For example, you could have an EmailFinder, PhoneNumberFinder, etc.

Additionally, they could implement an interface with a List<FindResult> find(String input) method, and you could use them by instantiating them and calling the find() method.

点赞
评论