Skip to content

Commit b8fdc85

Browse files
author
Rachel Prince
committed
Convert AppDistributionRelease to Autovalue and add constructors to Exception type
1 parent 57cd78a commit b8fdc85

File tree

3 files changed

+44
-27
lines changed

3 files changed

+44
-27
lines changed

firebase-app-distribution/firebase-app-distribution.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ dependencies {
5555

5656
implementation 'com.google.android.gms:play-services-tasks:17.0.0'
5757

58+
compileOnly 'com.google.auto.value:auto-value-annotations:1.6.5'
59+
annotationProcessor 'com.google.auto.value:auto-value:1.6.5'
60+
5861
implementation 'com.android.support:customtabs:28.0.0'
5962
implementation "androidx.browser:browser:1.3.0"
6063
}

firebase-app-distribution/src/main/java/com/google/firebase/appdistribution/AppDistributionRelease.java

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,43 @@
1515
package com.google.firebase.appdistribution;
1616

1717
import androidx.annotation.NonNull;
18+
import androidx.annotation.Nullable;
19+
import com.google.auto.value.AutoValue;
1820

1921
/**
20-
* Data class for AppDistributionRelease object returned by checkForUpdate() and
22+
* This class represents the AppDistributionRelease object returned by checkForUpdate() and
2123
* updateToLatestRelease()
24+
*
25+
* <p>It is an immutable value class implemented by AutoValue.
26+
*
27+
* @see <a
28+
* href="https://github.com/google/auto/tree/master/value">https://github.com/google/auto/tree/master/value</a>
2229
*/
23-
public final class AppDistributionRelease {
24-
private final String displayVersion;
25-
private final String buildVersion;
26-
private final String releaseNotes;
27-
private final BinaryType binaryType;
28-
29-
AppDistributionRelease(
30-
String displayVersion, String buildVersion, String releaseNotes, BinaryType binaryType) {
31-
this.displayVersion = displayVersion;
32-
this.buildVersion = buildVersion;
33-
this.releaseNotes = releaseNotes;
34-
this.binaryType = binaryType;
35-
}
36-
30+
@AutoValue
31+
public abstract class AppDistributionRelease {
3732
/** The short bundle version of this build (example 1.0.0) */
3833
@NonNull
39-
public String getDisplayVersion() {
40-
return displayVersion;
41-
}
34+
public abstract String getDisplayVersion();
4235

4336
/** The bundle version of this build (example: 123) */
4437
@NonNull
45-
public String getBuildVersion() {
46-
return buildVersion;
47-
}
38+
public abstract String getBuildVersion();
4839

4940
/** The release notes for this build */
50-
@NonNull
51-
public String getReleaseNotes() {
52-
return releaseNotes;
53-
}
41+
@Nullable
42+
public abstract String getReleaseNotes();
5443

5544
/** The binary type for this build */
5645
@NonNull
57-
public BinaryType getBinaryType() {
58-
return binaryType;
46+
public abstract BinaryType getBinaryType();
47+
48+
@NonNull
49+
public static AppDistributionRelease create(
50+
@NonNull String displayVersion,
51+
@NonNull String buildVersion,
52+
@Nullable String releaseNotes,
53+
@NonNull BinaryType binaryType) {
54+
return new AutoValue_AppDistributionRelease(
55+
displayVersion, buildVersion, releaseNotes, binaryType);
5956
}
6057
}

firebase-app-distribution/src/main/java/com/google/firebase/appdistribution/FirebaseAppDistributionException.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,23 @@ public enum Status {
6969
this.release = null;
7070
}
7171

72+
public FirebaseAppDistributionException(
73+
@NonNull String message, @NonNull Status status, @Nullable AppDistributionRelease release) {
74+
super(message);
75+
this.status = status;
76+
this.release = release;
77+
}
78+
79+
public FirebaseAppDistributionException(
80+
@NonNull String message,
81+
@NonNull Status status,
82+
@Nullable AppDistributionRelease release,
83+
@NonNull Throwable cause) {
84+
super(message, cause);
85+
this.status = status;
86+
this.release = release;
87+
}
88+
7289
/** Get cached release when error was thrown */
7390
@NonNull
7491
public AppDistributionRelease getRelease() {

0 commit comments

Comments
 (0)