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:
static findEmailAddresses(String input)
- usesRegexPatternSearcher
static findPhoneNumbers(String input)
- usesRegexPatternSearcher
static findDisallowedWords(String input, Set<String> disAllowedWords)
- usesSingleTokenSearcher
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.
我正在尝试寻找一种更好和更可扩展的方法来设计此库。任何帮助是极大的赞赏。
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 aList<FindResult> find(String input)
method, and you could use them by instantiating them and calling thefind()
method.