Skip to content

Commit c0e71ae

Browse files
authored
[ch57098] Deprecate LDCountryCode (#141)
Deprecate LDCountryCode class and LDUser setters that take LDCountryCode as an argument.
1 parent d1af310 commit c0e71ae

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/android/LDCountryCode.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@
9696
*
9797
* @author Takahiko Kawasaki
9898
*/
99+
@SuppressWarnings({"deprecation", "DeprecatedIsStillUsed"})
100+
@Deprecated
99101
public enum LDCountryCode {
100102
/**
101103
* <a href="http://en.wikipedia.org/wiki/Ascension_Island">Ascension Island</a>

launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/android/LDUser.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ public static class Builder {
211211
private String email;
212212
private String name;
213213
private String avatar;
214+
@SuppressWarnings("deprecation")
214215
private LDCountryCode country;
215216

216217
private final Map<String, JsonElement> custom;
@@ -232,6 +233,7 @@ public Builder(String key) {
232233
privateAttributeNames = new HashSet<>();
233234
}
234235

236+
@SuppressWarnings("deprecation")
235237
public Builder(LDUser user) {
236238
this.key = user.getKey();
237239
this.anonymous = user.getAnonymous();
@@ -282,10 +284,12 @@ public Builder privateSecondary(String s) {
282284
}
283285

284286
/**
285-
* Set the country for a user. The country should be a valid <a
287+
* Set the country for a user. In 2.x.x the SDK will attempt to look the country up as a <a
286288
* href="http://en.wikipedia.org/wiki/ISO_3166-1">ISO 3166-1</a> alpha-2 or alpha-3 code. If
287289
* it is not a valid ISO-3166-1 code, an attempt will be made to look up the country by its
288-
* name. If that fails, a warning will be logged, and the country will not be set.
290+
* name. If that fails, a warning will be logged, and the country will not be set. In the
291+
* next major release (3.0.0) the SDK will not attempt attempt this lookup, and instead
292+
* treat the country field as a normal String.
289293
*
290294
* @param s the country for the user
291295
* @return the builder
@@ -296,11 +300,12 @@ public Builder country(String s) {
296300
}
297301

298302
/**
299-
* Set the country for a user. The country should be a valid <a
303+
* Set the country for a user. In 2.x.x the SDK will attempt to look the country up as a <a
300304
* href="http://en.wikipedia.org/wiki/ISO_3166-1">ISO 3166-1</a> alpha-2 or alpha-3 code. If
301305
* it is not a valid ISO-3166-1 code, an attempt will be made to look up the country by its
302-
* name. If that fails, a warning will be logged, and the country will not be set. Private
303-
* attributes are not recorded in events.
306+
* name. If that fails, a warning will be logged, and the country will not be set. In the
307+
* next major release (3.0.0) the SDK will not attempt attempt this lookup, and instead
308+
* treat the country field as a normal String. Private attributes are not recorded in events.
304309
*
305310
* @param s the country for the user
306311
* @return the builder
@@ -310,6 +315,8 @@ public Builder privateCountry(String s) {
310315
return country(s);
311316
}
312317

318+
319+
@SuppressWarnings("deprecation")
313320
private LDCountryCode countryCode(String s) {
314321
LDCountryCode countryCode = LDCountryCode.getByCode(s, false);
315322

@@ -341,7 +348,11 @@ private LDCountryCode countryCode(String s) {
341348
*
342349
* @param country the country for the user
343350
* @return the builder
344-
*/
351+
* @deprecated As of version 2.9.1, in 3.0.0 the SDK will no longer include the
352+
* LDCountryCode class. Applications should use {@link #country(String)} instead.
353+
* */
354+
@Deprecated
355+
@SuppressWarnings("deprecation")
345356
public Builder country(LDCountryCode country) {
346357
this.country = country;
347358
return this;
@@ -352,7 +363,11 @@ public Builder country(LDCountryCode country) {
352363
*
353364
* @param country the country for the user
354365
* @return the builder
366+
* @deprecated As of version 2.9.1, in 3.0.0 the SDK will no longer include the
367+
* LDCountryCode class. Applications should use {@link #privateCountry(String)} instead.
355368
*/
369+
@Deprecated
370+
@SuppressWarnings("deprecation")
356371
public Builder privateCountry(LDCountryCode country) {
357372
privateAttributeNames.add(COUNTRY);
358373
return country(country);

0 commit comments

Comments
 (0)