Skip to content

Commit 2cc0f3e

Browse files
authored
Merge pull request #654 from maxmind/greg/eng-3756-update-gradle-instructions-in-readmemd-files
Update README.md Gradle and Java version instructions
2 parents b81dce3 + c6245fb commit 2cc0f3e

File tree

2 files changed

+119
-121
lines changed

2 files changed

+119
-121
lines changed

README.md

Lines changed: 119 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ repositories {
3030
mavenCentral()
3131
}
3232
dependencies {
33-
compile 'com.maxmind.geoip2:geoip2:5.0.2'
33+
implementation 'com.maxmind.geoip2:geoip2:5.0.2'
3434
}
3535
```
3636

@@ -97,10 +97,10 @@ InetAddress ipAddress = InetAddress.getByName("128.101.101.101");
9797
// Do the lookup
9898
CountryResponse response = client.country(ipAddress);
9999

100-
Country country = response.getCountry();
101-
System.out.println(country.getIsoCode()); // 'US'
102-
System.out.println(country.getName()); // 'United States'
103-
System.out.println(country.getNames().get("zh-CN")); // '美国'
100+
Country country = response.country();
101+
System.out.println(country.isoCode()); // 'US'
102+
System.out.println(country.name()); // 'United States'
103+
System.out.println(country.names().get("zh-CN")); // '美国'
104104
```
105105

106106
### City Plus Service ###
@@ -126,24 +126,24 @@ InetAddress ipAddress = InetAddress.getByName("128.101.101.101");
126126
// Do the lookup
127127
CityResponse response = client.city(ipAddress);
128128

129-
Country country = response.getCountry();
130-
System.out.println(country.getIsoCode()); // 'US'
131-
System.out.println(country.getName()); // 'United States'
132-
System.out.println(country.getNames().get("zh-CN")); // '美国'
129+
Country country = response.country();
130+
System.out.println(country.isoCode()); // 'US'
131+
System.out.println(country.name()); // 'United States'
132+
System.out.println(country.names().get("zh-CN")); // '美国'
133133

134-
Subdivision subdivision = response.getMostSpecificSubdivision();
135-
System.out.println(subdivision.getName()); // 'Minnesota'
136-
System.out.println(subdivision.getIsoCode()); // 'MN'
134+
Subdivision subdivision = response.mostSpecificSubdivision();
135+
System.out.println(subdivision.name()); // 'Minnesota'
136+
System.out.println(subdivision.isoCode()); // 'MN'
137137

138-
City city = response.getCity();
139-
System.out.println(city.getName()); // 'Minneapolis'
138+
City city = response.city();
139+
System.out.println(city.name()); // 'Minneapolis'
140140

141-
Postal postal = response.getPostal();
142-
System.out.println(postal.getCode()); // '55455'
141+
Postal postal = response.postal();
142+
System.out.println(postal.code()); // '55455'
143143

144-
Location location = response.getLocation();
145-
System.out.println(location.getLatitude()); // 44.9733
146-
System.out.println(location.getLongitude()); // -93.2323
144+
Location location = response.location();
145+
System.out.println(location.latitude()); // 44.9733
146+
System.out.println(location.longitude()); // -93.2323
147147
```
148148

149149
### Insights Service ###
@@ -167,32 +167,32 @@ InetAddress ipAddress = InetAddress.getByName("128.101.101.101");
167167
// Do the lookup
168168
InsightsResponse response = client.insights(ipAddress);
169169

170-
Country country = response.getCountry();
171-
System.out.println(country.getIsoCode()); // 'US'
172-
System.out.println(country.getName()); // 'United States'
173-
System.out.println(country.getNames().get("zh-CN")); // '美国'
174-
System.out.println(country.getConfidence()); // 99
170+
Country country = response.country();
171+
System.out.println(country.isoCode()); // 'US'
172+
System.out.println(country.name()); // 'United States'
173+
System.out.println(country.names().get("zh-CN")); // '美国'
174+
System.out.println(country.confidence()); // 99
175175

176-
Subdivision subdivision = response.getMostSpecificSubdivision();
177-
System.out.println(subdivision.getName()); // 'Minnesota'
178-
System.out.println(subdivision.getIsoCode()); // 'MN'
179-
System.out.println(subdivision.getConfidence()); // 90
176+
Subdivision subdivision = response.mostSpecificSubdivision();
177+
System.out.println(subdivision.name()); // 'Minnesota'
178+
System.out.println(subdivision.isoCode()); // 'MN'
179+
System.out.println(subdivision.confidence()); // 90
180180

181-
City city = response.getCity();
182-
System.out.println(city.getName()); // 'Minneapolis'
183-
System.out.println(city.getConfidence()); // 50
181+
City city = response.city();
182+
System.out.println(city.name()); // 'Minneapolis'
183+
System.out.println(city.confidence()); // 50
184184

185-
Postal postal = response.getPostal();
186-
System.out.println(postal.getCode()); // '55455'
187-
System.out.println(postal.getConfidence()); // 40
185+
Postal postal = response.postal();
186+
System.out.println(postal.code()); // '55455'
187+
System.out.println(postal.confidence()); // 40
188188

189-
Location location = response.getLocation();
190-
System.out.println(location.getLatitude()); // 44.9733
191-
System.out.println(location.getLongitude()); // -93.2323
192-
System.out.println(location.getAccuracyRadius()); // 3
193-
System.out.println(location.getTimeZone()); // 'America/Chicago'
189+
Location location = response.location();
190+
System.out.println(location.latitude()); // 44.9733
191+
System.out.println(location.longitude()); // -93.2323
192+
System.out.println(location.accuracyRadius()); // 3
193+
System.out.println(location.timeZone()); // 'America/Chicago'
194194

195-
System.out.println(response.getTraits().getUserType()); // 'college'
195+
System.out.println(response.traits().userType()); // 'college'
196196
```
197197

198198
## Database Usage ##
@@ -256,32 +256,32 @@ File database = new File("/path/to/GeoIP2-City.mmdb");
256256

257257
// This creates the DatabaseReader object. To improve performance, reuse
258258
// the object across lookups. The object is thread-safe.
259-
DatabaseReader reader = new DatabaseReader.Builder(database).build();
260-
261-
InetAddress ipAddress = InetAddress.getByName("128.101.101.101");
259+
try (DatabaseReader reader = new DatabaseReader.Builder(database).build()) {
260+
InetAddress ipAddress = InetAddress.getByName("128.101.101.101");
262261

263-
// Replace "city" with the appropriate method for your database, e.g.,
264-
// "country".
265-
CityResponse response = reader.city(ipAddress);
262+
// Replace "city" with the appropriate method for your database, e.g.,
263+
// "country".
264+
CityResponse response = reader.city(ipAddress);
266265

267-
Country country = response.getCountry();
268-
System.out.println(country.getIsoCode()); // 'US'
269-
System.out.println(country.getName()); // 'United States'
270-
System.out.println(country.getNames().get("zh-CN")); // '美国'
266+
Country country = response.country();
267+
System.out.println(country.isoCode()); // 'US'
268+
System.out.println(country.name()); // 'United States'
269+
System.out.println(country.names().get("zh-CN")); // '美国'
271270

272-
Subdivision subdivision = response.getMostSpecificSubdivision();
273-
System.out.println(subdivision.getName()); // 'Minnesota'
274-
System.out.println(subdivision.getIsoCode()); // 'MN'
271+
Subdivision subdivision = response.mostSpecificSubdivision();
272+
System.out.println(subdivision.name()); // 'Minnesota'
273+
System.out.println(subdivision.isoCode()); // 'MN'
275274

276-
City city = response.getCity();
277-
System.out.println(city.getName()); // 'Minneapolis'
275+
City city = response.city();
276+
System.out.println(city.name()); // 'Minneapolis'
278277

279-
Postal postal = response.getPostal();
280-
System.out.println(postal.getCode()); // '55455'
278+
Postal postal = response.postal();
279+
System.out.println(postal.code()); // '55455'
281280

282-
Location location = response.getLocation();
283-
System.out.println(location.getLatitude()); // 44.9733
284-
System.out.println(location.getLongitude()); // -93.2323
281+
Location location = response.location();
282+
System.out.println(location.latitude()); // 44.9733
283+
System.out.println(location.longitude()); // -93.2323
284+
}
285285
```
286286

287287
### Anonymous IP ###
@@ -302,7 +302,7 @@ try (DatabaseReader reader = new DatabaseReader.Builder(database).build()) {
302302
System.out.println(response.isHostingProvider()); // false
303303
System.out.println(response.isPublicProxy()); // false
304304
System.out.println(response.isResidentialProxy()); // false
305-
System.out.println(response.isTorExitNode()); //true
305+
System.out.println(response.isTorExitNode()); // true
306306
}
307307
```
308308

@@ -317,17 +317,17 @@ File database = new File("/path/to/GeoIP-Anonymous-Plus.mmdb");
317317
try (DatabaseReader reader = new DatabaseReader.Builder(database).build()) {
318318
InetAddress ipAddress = InetAddress.getByName("85.25.43.84");
319319

320-
AnonymousIpResponse response = reader.anonymousPlus(ipAddress);
320+
AnonymousPlusResponse response = reader.anonymousPlus(ipAddress);
321321

322-
System.out.println(response.getAnonymizerConfidence()); // 30
322+
System.out.println(response.anonymizerConfidence()); // 30
323323
System.out.println(response.isAnonymous()); // true
324324
System.out.println(response.isAnonymousVpn()); // false
325325
System.out.println(response.isHostingProvider()); // false
326326
System.out.println(response.isPublicProxy()); // false
327327
System.out.println(response.isResidentialProxy()); // false
328328
System.out.println(response.isTorExitNode()); // true
329-
System.out.println(response.getNetworkLastSeen()); // "2025-04-14"
330-
System.out.println(response.getProviderName()); // "FooBar VPN"
329+
System.out.println(response.networkLastSeen()); // "2025-04-14"
330+
System.out.println(response.providerName()); // "FooBar VPN"
331331
}
332332
```
333333

@@ -345,8 +345,8 @@ try (DatabaseReader reader = new DatabaseReader.Builder(database).build()) {
345345

346346
AsnResponse response = reader.asn(ipAddress);
347347

348-
System.out.println(response.getAutonomousSystemNumber()); // 217
349-
System.out.println(response.getAutonomousSystemOrganization()); // 'University of Minnesota'
348+
System.out.println(response.autonomousSystemNumber()); // 217
349+
System.out.println(response.autonomousSystemOrganization()); // 'University of Minnesota'
350350
}
351351
```
352352

@@ -358,16 +358,16 @@ File database = new File("/path/to/GeoIP2-Connection-Type.mmdb");
358358

359359
// This creates the DatabaseReader object. To improve performance, reuse
360360
// the object across lookups. The object is thread-safe.
361-
DatabaseReader reader = new DatabaseReader.Builder(database).build();
362-
363-
InetAddress ipAddress = InetAddress.getByName("128.101.101.101");
361+
try (DatabaseReader reader = new DatabaseReader.Builder(database).build()) {
362+
InetAddress ipAddress = InetAddress.getByName("128.101.101.101");
364363

365-
ConnectionTypeResponse response = reader.connectionType(ipAddress);
364+
ConnectionTypeResponse response = reader.connectionType(ipAddress);
366365

367-
// getConnectionType() returns a ConnectionType enum
368-
ConnectionType type = response.getConnectionType();
366+
// connectionType() returns a ConnectionType enum
367+
ConnectionType type = response.connectionType();
369368

370-
System.out.println(type); // 'Corporate'
369+
System.out.println(type); // 'Corporate'
370+
}
371371
```
372372

373373
### Domain ###
@@ -378,13 +378,13 @@ File database = new File("/path/to/GeoIP2-Domain.mmdb");
378378

379379
// This creates the DatabaseReader object. To improve performance, reuse
380380
// the object across lookups. The object is thread-safe.
381-
DatabaseReader reader = new DatabaseReader.Builder(database).build();
382-
383-
InetAddress ipAddress = InetAddress.getByName("128.101.101.101");
381+
try (DatabaseReader reader = new DatabaseReader.Builder(database).build()) {
382+
InetAddress ipAddress = InetAddress.getByName("128.101.101.101");
384383

385-
DomainResponse response = reader.domain(ipAddress);
384+
DomainResponse response = reader.domain(ipAddress);
386385

387-
System.out.println(response.getDomain()); // 'umn.edu'
386+
System.out.println(response.domain()); // 'umn.edu'
387+
}
388388
```
389389

390390
### Enterprise ###
@@ -401,29 +401,29 @@ try (DatabaseReader reader = new DatabaseReader.Builder(database).build()) {
401401
// Use the enterprise(ip) method to do a lookup in the Enterprise database
402402
EnterpriseResponse response = reader.enterprise(ipAddress);
403403

404-
Country country = response.getCountry();
405-
System.out.println(country.getIsoCode()); // 'US'
406-
System.out.println(country.getName()); // 'United States'
407-
System.out.println(country.getNames().get("zh-CN")); // '美国'
408-
System.out.println(country.getConfidence()); // 99
409-
410-
Subdivision subdivision = response.getMostSpecificSubdivision();
411-
System.out.println(subdivision.getName()); // 'Minnesota'
412-
System.out.println(subdivision.getIsoCode()); // 'MN'
413-
System.out.println(subdivision.getConfidence()); // 77
414-
415-
City city = response.getCity();
416-
System.out.println(city.getName()); // 'Minneapolis'
417-
System.out.println(city.getConfidence()); // 11
418-
419-
Postal postal = response.getPostal();
420-
System.out.println(postal.getCode()); // '55455'
421-
System.out.println(postal.getConfidence()); // 5
422-
423-
Location location = response.getLocation();
424-
System.out.println(location.getLatitude()); // 44.9733
425-
System.out.println(location.getLongitude()); // -93.2323
426-
System.out.println(location.getAccuracyRadius()); // 50
404+
Country country = response.country();
405+
System.out.println(country.isoCode()); // 'US'
406+
System.out.println(country.name()); // 'United States'
407+
System.out.println(country.names().get("zh-CN")); // '美国'
408+
System.out.println(country.confidence()); // 99
409+
410+
Subdivision subdivision = response.mostSpecificSubdivision();
411+
System.out.println(subdivision.name()); // 'Minnesota'
412+
System.out.println(subdivision.isoCode()); // 'MN'
413+
System.out.println(subdivision.confidence()); // 77
414+
415+
City city = response.city();
416+
System.out.println(city.name()); // 'Minneapolis'
417+
System.out.println(city.confidence()); // 11
418+
419+
Postal postal = response.postal();
420+
System.out.println(postal.code()); // '55455'
421+
System.out.println(postal.confidence()); // 5
422+
423+
Location location = response.location();
424+
System.out.println(location.latitude()); // 44.9733
425+
System.out.println(location.longitude()); // -93.2323
426+
System.out.println(location.accuracyRadius()); // 50
427427
}
428428
```
429429

@@ -435,16 +435,16 @@ File database = new File("/path/to/GeoIP2-ISP.mmdb");
435435

436436
// This creates the DatabaseReader object. To improve performance, reuse
437437
// the object across lookups. The object is thread-safe.
438-
DatabaseReader reader = new DatabaseReader.Builder(database).build();
439-
440-
InetAddress ipAddress = InetAddress.getByName("128.101.101.101");
438+
try (DatabaseReader reader = new DatabaseReader.Builder(database).build()) {
439+
InetAddress ipAddress = InetAddress.getByName("128.101.101.101");
441440

442-
IspResponse response = reader.isp(ipAddress);
441+
IspResponse response = reader.isp(ipAddress);
443442

444-
System.out.println(response.getAutonomousSystemNumber()); // 217
445-
System.out.println(response.getAutonomousSystemOrganization()); // 'University of Minnesota'
446-
System.out.println(response.getIsp()); // 'University of Minnesota'
447-
System.out.println(response.getOrganization()); // 'University of Minnesota'
443+
System.out.println(response.autonomousSystemNumber()); // 217
444+
System.out.println(response.autonomousSystemOrganization()); // 'University of Minnesota'
445+
System.out.println(response.isp()); // 'University of Minnesota'
446+
System.out.println(response.organization()); // 'University of Minnesota'
447+
}
448448
```
449449

450450
## Exceptions ##
@@ -469,17 +469,17 @@ the above exceptions.
469469

470470
## Values to use for Database or Map Keys ##
471471

472-
**We strongly discourage you from using a value from any `getNames` method as
472+
**We strongly discourage you from using a value from any `names()` method as
473473
a key in a database or map.**
474474

475475
These names may change between releases. Instead we recommend using one of the
476476
following:
477477

478-
* `com.maxmind.geoip2.record.City` - `City.getGeoNameId`
479-
* `com.maxmind.geoip2.record.Continent` - `Continent.getCode` or `Continent.getGeoNameId`
480-
* `com.maxmind.geoip2.record.Country` and `com.maxmind.geoip2.record.RepresentedCountry` - `Country.getIsoCode`
481-
or `Country.getGeoNameId`
482-
* `com.maxmind.geoip2.record.Subdivision` - `Subdivision.getIsoCode` or `Subdivision.getGeoNameId`
478+
* `com.maxmind.geoip2.record.City` - `City.geonameId`
479+
* `com.maxmind.geoip2.record.Continent` - `Continent.code` or `Continent.geonameId`
480+
* `com.maxmind.geoip2.record.Country` and `com.maxmind.geoip2.record.RepresentedCountry` - `Country.isoCode`
481+
or `Country.geonameId`
482+
* `com.maxmind.geoip2.record.Subdivision` - `Subdivision.isoCode` or `Subdivision.geonameId`
483483

484484
## Multi-Threaded Use ##
485485

@@ -501,7 +501,7 @@ documentation](https://dev.maxmind.com/geoip/docs/web-services?lang=en) for
501501
details on what data each web service may return.
502502

503503
The only piece of data which is always returned is the `ip_address`
504-
available at `lookup.getTraits().getIpAddress()`.
504+
available at `lookup.traits().ipAddress()`.
505505

506506
## Integration with GeoNames ##
507507

@@ -511,7 +511,7 @@ populated places. They offer both free and paid premium data. Each
511511
feature is uniquely identified by a `geonameId`, which is an integer.
512512

513513
Many of the records returned by the GeoIP2 web services and databases
514-
include a `getGeoNameId()` method. This is the ID of a geographical
514+
include a `geonameId()` method. This is the ID of a geographical
515515
feature (city, region, country, etc.) in the GeoNames database.
516516

517517
Some of the data that MaxMind provides is also sourced from GeoNames. We
@@ -547,7 +547,7 @@ to the client API, please
547547

548548
## Requirements ##
549549

550-
MaxMind has tested this API with Java 11 and above.
550+
MaxMind has tested this API with Java 17 and above.
551551

552552
## Contributing ##
553553

pom.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,6 @@
212212
<version>3.14.1</version>
213213
<configuration>
214214
<release>17</release>
215-
<source>17</source>
216-
<target>11</target>
217215
</configuration>
218216
</plugin>
219217
<plugin>

0 commit comments

Comments
 (0)