Skip to content

Commit 45471ee

Browse files
author
Rachel Prince
committed
Convert AppDistributionRelease to Autovalue and add constructors to Exception type
1 parent 460fd3f commit 45471ee

File tree

3 files changed

+38
-26
lines changed

3 files changed

+38
-26
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,7 @@ dependencies {
4242
implementation project(path: ':firebase-components')
4343
implementation 'com.google.android.gms:play-services-tasks:17.0.0'
4444
implementation project(path: ':firebase-common')
45+
46+
compileOnly 'com.google.auto.value:auto-value-annotations:1.6.5'
47+
annotationProcessor 'com.google.auto.value:auto-value:1.6.5'
4548
}

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

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

1717
import androidx.annotation.NonNull;
18+
import com.google.auto.value.AutoValue;
1819

1920
/**
20-
* Data class for AppDistributionRelease object returned by checkForUpdate() and
21+
* This class represents the AppDistributionRelease object returned by checkForUpdate() and
2122
* updateToLatestRelease()
23+
*
24+
* <p>It is an immutable value class implemented by AutoValue.
25+
*
26+
* @see <a
27+
* href="https://github.com/google/auto/tree/master/value">https://github.com/google/auto/tree/master/value</a>
2228
*/
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-
29+
@AutoValue
30+
public abstract class AppDistributionRelease {
3731
/** The short bundle version of this build (example 1.0.0) */
3832
@NonNull
39-
public String getDisplayVersion() {
40-
return displayVersion;
41-
}
33+
public abstract String getDisplayVersion();
4234

4335
/** The bundle version of this build (example: 123) */
4436
@NonNull
45-
public String getBuildVersion() {
46-
return buildVersion;
47-
}
37+
public abstract String getBuildVersion();
4838

4939
/** The release notes for this build */
5040
@NonNull
51-
public String getReleaseNotes() {
52-
return releaseNotes;
53-
}
41+
public abstract String getReleaseNotes();
5442

5543
/** The binary type for this build */
5644
@NonNull
57-
public BinaryType getBinaryType() {
58-
return binaryType;
45+
public abstract BinaryType getBinaryType();
46+
47+
public static AppDistributionRelease create(
48+
String displayVersion, String buildVersion, String releaseNotes, BinaryType binaryType) {
49+
return new AutoValue_AppDistributionRelease(
50+
displayVersion, buildVersion, releaseNotes, binaryType);
5951
}
6052
}

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
@@ -63,6 +63,23 @@ public enum Status {
6363
this.release = release;
6464
}
6565

66+
public FirebaseAppDistributionException(
67+
@NonNull String message, @NonNull Status status, @NonNull AppDistributionRelease release) {
68+
super(message);
69+
this.status = status;
70+
this.release = release;
71+
}
72+
73+
public FirebaseAppDistributionException(
74+
@NonNull String message,
75+
@NonNull Status status,
76+
@NonNull AppDistributionRelease release,
77+
@NonNull Throwable cause) {
78+
super(message, cause);
79+
this.status = status;
80+
this.release = release;
81+
}
82+
6683
/** Get cached release when error was thrown */
6784
@NonNull
6885
public AppDistributionRelease getRelease() {

0 commit comments

Comments
 (0)