public static final class DatabaseReader.Builder extends Object
Constructs a Builder for the DatabaseReader. The file passed to
it must be a valid GeoIP2 database file.
Builder creates instances of DatabaseReader
from values set by the methods.
Only the values set in the Builder constructor are required.
| Modifier and Type | Field and Description |
|---|---|
(package private) NodeCache |
cache |
(package private) File |
database |
(package private) List<String> |
locales |
(package private) Reader.FileMode |
mode |
(package private) InputStream |
stream |
| Constructor and Description |
|---|
Builder(File database) |
Builder(InputStream stream) |
| Modifier and Type | Method and Description |
|---|---|
DatabaseReader |
build() |
DatabaseReader.Builder |
fileMode(Reader.FileMode val) |
DatabaseReader.Builder |
locales(List<String> val) |
DatabaseReader.Builder |
withCache(NodeCache cache) |
final File database
final InputStream stream
Reader.FileMode mode
NodeCache cache
public Builder(InputStream stream)
stream - the stream containing the GeoIP2 database to use.public Builder(File database)
database - the GeoIP2 database file to use.public DatabaseReader.Builder locales(List<String> val)
val - List of locale codes to use in name property from most
preferred to least preferred.public DatabaseReader.Builder withCache(NodeCache cache)
cache - backing cache instancepublic DatabaseReader.Builder fileMode(Reader.FileMode val)
val - The file mode used to open the GeoIP2 databaseIllegalArgumentException - if you initialized the Builder with a URL, which uses
Reader.FileMode.MEMORY, but you provided a different
FileMode to this method.public DatabaseReader build() throws IOException
DatabaseReader created from the
fields set on this builder.IOException - if there is an error reading the database