Reputation: 991
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)
- uses RegexPatternSearcher
static findPhoneNumbers(String input)
- uses RegexPatternSearcher
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.
I am trying to look for a better and more extensible way to design this library. Any help is greatly appreciated.
Upvotes: 0
Views: 49
Reputation: 63442
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.
Upvotes: 1