1414
1515package com .google .firebase .firestore .util ;
1616
17- import static com .google .firebase .firestore .util .ApiUtil .invoke ;
18- import static com .google .firebase .firestore .util .ApiUtil .newInstance ;
19-
20- import android .net .Uri ;
21- import android .os .Build ;
22- import androidx .annotation .RequiresApi ;
23- import com .google .firebase .Timestamp ;
24- import com .google .firebase .firestore .Blob ;
25- import com .google .firebase .firestore .DocumentId ;
26- import com .google .firebase .firestore .DocumentReference ;
27- import com .google .firebase .firestore .Exclude ;
28- import com .google .firebase .firestore .FieldValue ;
29- import com .google .firebase .firestore .GeoPoint ;
30- import com .google .firebase .firestore .IgnoreExtraProperties ;
31- import com .google .firebase .firestore .PropertyName ;
32- import com .google .firebase .firestore .ServerTimestamp ;
33- import com .google .firebase .firestore .ThrowOnExtraProperties ;
34- import com .google .firebase .firestore .VectorValue ;
3517import java .lang .reflect .AccessibleObject ;
3618import java .lang .reflect .Constructor ;
3719import java .lang .reflect .Field ;
5739import java .util .concurrent .ConcurrentHashMap ;
5840import java .util .concurrent .ConcurrentMap ;
5941
42+ import android .net .Uri ;
43+ import android .os .Build ;
44+ import androidx .annotation .RequiresApi ;
45+ import com .google .firebase .Timestamp ;
46+ import com .google .firebase .firestore .Blob ;
47+ import com .google .firebase .firestore .DocumentId ;
48+ import com .google .firebase .firestore .DocumentReference ;
49+ import com .google .firebase .firestore .Exclude ;
50+ import com .google .firebase .firestore .FieldValue ;
51+ import com .google .firebase .firestore .GeoPoint ;
52+ import com .google .firebase .firestore .IgnoreExtraProperties ;
53+ import com .google .firebase .firestore .PropertyName ;
54+ import com .google .firebase .firestore .ServerTimestamp ;
55+ import com .google .firebase .firestore .ThrowOnExtraProperties ;
56+ import com .google .firebase .firestore .VectorValue ;
57+
58+ import static com .google .firebase .firestore .util .ApiUtil .invoke ;
59+ import static com .google .firebase .firestore .util .ApiUtil .newInstance ;
60+
6061/** Helper class to convert to/from custom POJO classes and plain Java types. */
6162public class CustomClassMapper {
6263 /** Maximum depth before we give up and assume it's a recursive object graph. */
@@ -243,7 +244,8 @@ private static <T> T deserializeToClass(Object o, Class<T> clazz, DeserializeCon
243244 return (T ) convertDate (o , context );
244245 } else if (Timestamp .class .isAssignableFrom (clazz )) {
245246 return (T ) convertTimestamp (o , context );
246- } else if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O && Instant .class .isAssignableFrom (clazz )) {
247+ } else if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O
248+ && Instant .class .isAssignableFrom (clazz )) {
247249 return (T ) convertInstant (o , context );
248250 } else if (Blob .class .isAssignableFrom (clazz )) {
249251 return (T ) convertBlob (o , context );
@@ -955,8 +957,9 @@ Map<String, Object> serialize(T object, ErrorPath path) {
955957 private void applyFieldAnnotations (Field field ) {
956958 if (field .isAnnotationPresent (ServerTimestamp .class )) {
957959 Class <?> fieldType = field .getType ();
958- if (fieldType != Date .class && fieldType != Timestamp .class
959- && ! (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O && fieldType == Instant .class )) {
960+ if (fieldType != Date .class
961+ && fieldType != Timestamp .class
962+ && !(Build .VERSION .SDK_INT >= Build .VERSION_CODES .O && fieldType == Instant .class )) {
960963 throw new IllegalArgumentException (
961964 "Field "
962965 + field .getName ()
@@ -977,8 +980,9 @@ private void applyFieldAnnotations(Field field) {
977980 private void applyGetterAnnotations (Method method ) {
978981 if (method .isAnnotationPresent (ServerTimestamp .class )) {
979982 Class <?> returnType = method .getReturnType ();
980- if (returnType != Date .class && returnType != Timestamp .class
981- && ! (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O && returnType == Instant .class )) {
983+ if (returnType != Date .class
984+ && returnType != Timestamp .class
985+ && !(Build .VERSION .SDK_INT >= Build .VERSION_CODES .O && returnType == Instant .class )) {
982986 throw new IllegalArgumentException (
983987 "Method "
984988 + method .getName ()
0 commit comments