Skip to content

Commit e967dd1

Browse files
committed
Remove kotlinx.datetime.Instant support
1 parent 135d202 commit e967dd1

File tree

3 files changed

+6
-39
lines changed

3 files changed

+6
-39
lines changed

firebase-firestore/firebase-firestore.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ dependencies {
147147

148148
compileOnly libs.autovalue.annotations
149149
compileOnly libs.javax.annotation.jsr250
150-
compileOnly libs.kotlinx.datetime
151150

152151
annotationProcessor libs.autovalue
153152

@@ -165,7 +164,6 @@ dependencies {
165164
testImplementation libs.hamcrest.junit
166165
testImplementation libs.mockito.core
167166
testImplementation libs.robolectric
168-
testImplementation libs.kotlinx.datetime
169167

170168
testCompileOnly libs.protobuf.java
171169

firebase-firestore/src/main/java/com/google/firebase/firestore/util/CustomClassMapper.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,6 @@ private static <T> Object serialize(T o, ErrorPath path) {
183183
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && o instanceof Instant) {
184184
Instant instant = (Instant) o;
185185
return new Timestamp(instant.getEpochSecond(), instant.getNano());
186-
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
187-
&& o instanceof kotlinx.datetime.Instant) {
188-
kotlinx.datetime.Instant instant = (kotlinx.datetime.Instant) o;
189-
return new Timestamp(instant.getEpochSeconds(), instant.getNanosecondsOfSecond());
190186
} else if (o instanceof Uri || o instanceof URI || o instanceof URL) {
191187
return o.toString();
192188
} else {
@@ -250,9 +246,6 @@ private static <T> T deserializeToClass(Object o, Class<T> clazz, DeserializeCon
250246
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
251247
&& Instant.class.isAssignableFrom(clazz)) {
252248
return (T) convertInstant(o, context);
253-
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
254-
&& kotlinx.datetime.Instant.class.isAssignableFrom(clazz)) {
255-
return (T) new kotlinx.datetime.Instant(convertInstant(o, context));
256249
} else if (Blob.class.isAssignableFrom(clazz)) {
257250
return (T) convertBlob(o, context);
258251
} else if (GeoPoint.class.isAssignableFrom(clazz)) {
@@ -965,8 +958,7 @@ private void applyFieldAnnotations(Field field) {
965958
Class<?> fieldType = field.getType();
966959
if (fieldType != Date.class
967960
&& fieldType != Timestamp.class
968-
&& !(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
969-
&& (fieldType == Instant.class || fieldType == kotlinx.datetime.Instant.class))) {
961+
&& !(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && fieldType == Instant.class)) {
970962
throw new IllegalArgumentException(
971963
"Field "
972964
+ field.getName()
@@ -989,8 +981,7 @@ private void applyGetterAnnotations(Method method) {
989981
Class<?> returnType = method.getReturnType();
990982
if (returnType != Date.class
991983
&& returnType != Timestamp.class
992-
&& !(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
993-
&& (returnType == Instant.class || returnType == kotlinx.datetime.Instant.class))) {
984+
&& !(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && returnType == Instant.class)) {
994985
throw new IllegalArgumentException(
995986
"Method "
996987
+ method.getName()

firebase-firestore/src/test/java/com/google/firebase/firestore/util/MapperTest.java

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ private static class TimeBean {
102102
public Timestamp timestamp;
103103
public Date date;
104104
public Instant instant;
105-
public kotlinx.datetime.Instant instantKt;
106105

107106
@Override
108107
public boolean equals(Object o) {
@@ -112,13 +111,12 @@ public boolean equals(Object o) {
112111
TimeBean timeBean = (TimeBean) o;
113112
return Objects.equals(timestamp, timeBean.timestamp)
114113
&& Objects.equals(date, timeBean.date)
115-
&& Objects.equals(instant, timeBean.instant)
116-
&& Objects.equals(instantKt, timeBean.instantKt);
114+
&& Objects.equals(instant, timeBean.instant);
117115
}
118116

119117
@Override
120118
public int hashCode() {
121-
return Objects.hash(timestamp, date, instant, instantKt);
119+
return Objects.hash(timestamp, date, instant);
122120
}
123121

124122
@Override
@@ -130,8 +128,6 @@ public String toString() {
130128
+ timestamp
131129
+ ", _instant="
132130
+ instant
133-
+ ", _instantKt="
134-
+ instantKt
135131
+ '}';
136132
}
137133
}
@@ -1523,17 +1519,8 @@ public void serializeTimeBean() {
15231519
bean.instant = Instant.ofEpochSecond(1234, 5678);
15241520
bean.timestamp = new Timestamp(bean.instant);
15251521
bean.date = new Date(1234);
1526-
bean.instantKt = new kotlinx.datetime.Instant(bean.instant);
15271522
assertEquals(
1528-
Map.of(
1529-
"timestamp",
1530-
bean.timestamp,
1531-
"date",
1532-
bean.date,
1533-
"instant",
1534-
bean.timestamp,
1535-
"instantKt",
1536-
bean.timestamp),
1523+
Map.of("timestamp", bean.timestamp, "date", bean.date, "instant", bean.timestamp),
15371524
serialize(bean));
15381525
}
15391526

@@ -1543,19 +1530,10 @@ public void deserializeTimeBean() {
15431530
bean.instant = Instant.ofEpochSecond(1234, 5678);
15441531
bean.timestamp = new Timestamp(bean.instant);
15451532
bean.date = new Date(1234);
1546-
bean.instantKt = new kotlinx.datetime.Instant(bean.instant);
15471533
assertEquals(
15481534
bean,
15491535
convertToCustomClass(
1550-
Map.of(
1551-
"timestamp",
1552-
bean.timestamp,
1553-
"date",
1554-
bean.date,
1555-
"instant",
1556-
bean.timestamp,
1557-
"instantKt",
1558-
bean.timestamp),
1536+
Map.of("timestamp", bean.timestamp, "date", bean.date, "instant", bean.timestamp),
15591537
TimeBean.class));
15601538
}
15611539

0 commit comments

Comments
 (0)