Do now throw exception when activation code is empty

Bug: 169276772
Test: 13352325
Change-Id: Ia8fd0ab98c33d1e30b4fce1bad53b1c628364725
This commit is contained in:
Jiashen Wang
2021-01-14 16:03:10 -08:00
parent 117f353a0b
commit ff5672ff43

View File

@@ -121,25 +121,21 @@ public final class DownloadableSubscription implements Parcelable {
} }
public Builder(@NonNull String encodedActivationCode) { public Builder(@NonNull String encodedActivationCode) {
Preconditions.checkNotNull(encodedActivationCode, "Activation code may not be null");
this.encodedActivationCode = encodedActivationCode; this.encodedActivationCode = encodedActivationCode;
} }
/** /**
* Builds a {@link DownloadableSubscription} object. If the encoded activation code is * Builds a {@link DownloadableSubscription} object.
* {@code null}, a {@link NullPointerException} will be thrown.
* @return a non-null {@link DownloadableSubscription} object. * @return a non-null {@link DownloadableSubscription} object.
*/ */
@NonNull @NonNull
public DownloadableSubscription build() { public DownloadableSubscription build() {
Preconditions.checkNotNull(encodedActivationCode, "Activation code may not be null");
return new DownloadableSubscription(encodedActivationCode, confirmationCode, return new DownloadableSubscription(encodedActivationCode, confirmationCode,
carrierName, accessRules); carrierName, accessRules);
} }
/** /**
* Sets the encoded activation code. If the encoded activation code is {@code null}, a * Sets the encoded activation code.
* {@link NullPointerException} will be thrown.
* @param value the activation code to use. An activation code can be parsed from a user * @param value the activation code to use. An activation code can be parsed from a user
* scanned QR code. The format of activation code is defined in SGP.22. For * scanned QR code. The format of activation code is defined in SGP.22. For
* example, "1$SMDP.GSMA.COM$04386-AGYFT-A74Y8-3F815$1.3.6.1.4.1.31746". For * example, "1$SMDP.GSMA.COM$04386-AGYFT-A74Y8-3F815$1.3.6.1.4.1.31746". For
@@ -147,7 +143,6 @@ public final class DownloadableSubscription implements Parcelable {
*/ */
@NonNull @NonNull
public Builder setEncodedActivationCode(@NonNull String value) { public Builder setEncodedActivationCode(@NonNull String value) {
Preconditions.checkNotNull(encodedActivationCode, "Activation code may not be null");
encodedActivationCode = value; encodedActivationCode = value;
return this; return this;
} }