-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from tomaytotomato/13-add-builder-classes
Add Builder classes
- Loading branch information
Showing
11 changed files
with
119 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
location4j/src/main/java/com/tomaytotomato/LocationServiceBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.tomaytotomato; | ||
|
||
import com.tomaytotomato.loader.CountriesDataLoader; | ||
import com.tomaytotomato.loader.DefaultCountriesDataLoaderImpl; | ||
import com.tomaytotomato.text.normaliser.DefaultTextNormaliser; | ||
import com.tomaytotomato.text.normaliser.TextNormaliser; | ||
|
||
public final class LocationServiceBuilder { | ||
|
||
private TextNormaliser textNormaliser = new DefaultTextNormaliser(); | ||
private CountriesDataLoader countriesDataLoader = new DefaultCountriesDataLoaderImpl(); | ||
|
||
LocationServiceBuilder() { | ||
} | ||
|
||
public LocationServiceBuilder withCountriesDataLoader(CountriesDataLoader countriesDataLoader) { | ||
this.countriesDataLoader = countriesDataLoader; | ||
return this; | ||
} | ||
|
||
public LocationServiceBuilder withTextNormaliser(TextNormaliser textNormaliser) { | ||
this.textNormaliser = textNormaliser; | ||
return this; | ||
} | ||
|
||
public LocationService build() { | ||
return new LocationService(textNormaliser, countriesDataLoader); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
location4j/src/main/java/com/tomaytotomato/SearchLocationServiceBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.tomaytotomato; | ||
|
||
import com.tomaytotomato.aliases.DefaultLocationAliases; | ||
import com.tomaytotomato.aliases.LocationAliases; | ||
import com.tomaytotomato.loader.CountriesDataLoader; | ||
import com.tomaytotomato.loader.DefaultCountriesDataLoaderImpl; | ||
import com.tomaytotomato.mapper.DefaultLocationMapper; | ||
import com.tomaytotomato.mapper.LocationMapper; | ||
import com.tomaytotomato.text.normaliser.DefaultTextNormaliser; | ||
import com.tomaytotomato.text.normaliser.TextNormaliser; | ||
import com.tomaytotomato.text.tokeniser.DefaultTextTokeniser; | ||
import com.tomaytotomato.text.tokeniser.TextTokeniser; | ||
|
||
/** | ||
* Allows the customisation and creation of the {@link SearchLocationService} | ||
*/ | ||
public final class SearchLocationServiceBuilder { | ||
|
||
private TextTokeniser textTokeniser = new DefaultTextTokeniser(); | ||
private TextNormaliser textNormaliser = new DefaultTextNormaliser(); | ||
private LocationMapper locationMapper = new DefaultLocationMapper(); | ||
private LocationAliases locationAliases = new DefaultLocationAliases(); | ||
private CountriesDataLoader countriesDataLoader = new DefaultCountriesDataLoaderImpl(); | ||
|
||
SearchLocationServiceBuilder() { | ||
} | ||
|
||
public SearchLocationServiceBuilder withTextTokeniser(TextTokeniser textTokeniser) { | ||
this.textTokeniser = textTokeniser; | ||
return this; | ||
} | ||
|
||
public SearchLocationServiceBuilder withTextNormaliser(TextNormaliser textNormaliser) { | ||
this.textNormaliser = textNormaliser; | ||
return this; | ||
} | ||
|
||
public SearchLocationServiceBuilder withLocationMapper(LocationMapper locationMapper) { | ||
this.locationMapper = locationMapper; | ||
return this; | ||
} | ||
|
||
public SearchLocationServiceBuilder withLocationAliases(LocationAliases locationAliases) { | ||
this.locationAliases = locationAliases; | ||
return this; | ||
} | ||
|
||
public SearchLocationServiceBuilder withCountriesDataLoader(CountriesDataLoader countriesDataLoader) { | ||
this.countriesDataLoader = countriesDataLoader; | ||
return this; | ||
} | ||
|
||
public SearchLocationService build() { | ||
return new SearchLocationService(textTokeniser, textNormaliser, locationMapper, | ||
countriesDataLoader, | ||
locationAliases); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters