-
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.
Allows the creation of SearchLocationService.java and LocationService.java to be more controlled. Fixes #13
- Loading branch information
1 parent
fa782ec
commit 15b6480
Showing
10 changed files
with
120 additions
and
76 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
33 changes: 33 additions & 0 deletions
33
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,33 @@ | ||
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(); | ||
|
||
public static LocationServiceBuilder builder() { | ||
return new LocationServiceBuilder(); | ||
} | ||
|
||
private 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
62 changes: 62 additions & 0 deletions
62
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,62 @@ | ||
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(); | ||
|
||
public static SearchLocationServiceBuilder builder() { | ||
return new SearchLocationServiceBuilder(); | ||
} | ||
|
||
private 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