Excluder.smali 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. .class public final Lcom/google/gson/internal/Excluder;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # interfaces
  5. .implements Lcom/google/gson/TypeAdapterFactory;
  6. .implements Ljava/lang/Cloneable;
  7. # static fields
  8. .field public static final DEFAULT:Lcom/google/gson/internal/Excluder;
  9. .field private static final IGNORE_VERSIONS:D = -1.0
  10. # instance fields
  11. .field private deserializationStrategies:Ljava/util/List;
  12. .annotation system Ldalvik/annotation/Signature;
  13. value = {
  14. "Ljava/util/List<",
  15. "Lcom/google/gson/ExclusionStrategy;",
  16. ">;"
  17. }
  18. .end annotation
  19. .end field
  20. .field private modifiers:I
  21. .field private requireExpose:Z
  22. .field private serializationStrategies:Ljava/util/List;
  23. .annotation system Ldalvik/annotation/Signature;
  24. value = {
  25. "Ljava/util/List<",
  26. "Lcom/google/gson/ExclusionStrategy;",
  27. ">;"
  28. }
  29. .end annotation
  30. .end field
  31. .field private serializeInnerClasses:Z
  32. .field private version:D
  33. # direct methods
  34. .method static constructor <clinit>()V
  35. .locals 1
  36. new-instance v0, Lcom/google/gson/internal/Excluder;
  37. invoke-direct {v0}, Lcom/google/gson/internal/Excluder;-><init>()V
  38. sput-object v0, Lcom/google/gson/internal/Excluder;->DEFAULT:Lcom/google/gson/internal/Excluder;
  39. return-void
  40. .end method
  41. .method public constructor <init>()V
  42. .locals 2
  43. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  44. const-wide/high16 v0, -0x4010000000000000L # -1.0
  45. iput-wide v0, p0, Lcom/google/gson/internal/Excluder;->version:D
  46. const/16 v0, 0x88
  47. iput v0, p0, Lcom/google/gson/internal/Excluder;->modifiers:I
  48. const/4 v0, 0x1
  49. iput-boolean v0, p0, Lcom/google/gson/internal/Excluder;->serializeInnerClasses:Z
  50. invoke-static {}, Ljava/util/Collections;->emptyList()Ljava/util/List;
  51. move-result-object v0
  52. iput-object v0, p0, Lcom/google/gson/internal/Excluder;->serializationStrategies:Ljava/util/List;
  53. invoke-static {}, Ljava/util/Collections;->emptyList()Ljava/util/List;
  54. move-result-object v0
  55. iput-object v0, p0, Lcom/google/gson/internal/Excluder;->deserializationStrategies:Ljava/util/List;
  56. return-void
  57. .end method
  58. .method private isAnonymousOrLocal(Ljava/lang/Class;)Z
  59. .locals 1
  60. .annotation system Ldalvik/annotation/Signature;
  61. value = {
  62. "(",
  63. "Ljava/lang/Class<",
  64. "*>;)Z"
  65. }
  66. .end annotation
  67. const-class v0, Ljava/lang/Enum;
  68. invoke-virtual {v0, p1}, Ljava/lang/Class;->isAssignableFrom(Ljava/lang/Class;)Z
  69. move-result v0
  70. if-nez v0, :cond_1
  71. invoke-virtual {p1}, Ljava/lang/Class;->isAnonymousClass()Z
  72. move-result v0
  73. if-nez v0, :cond_0
  74. invoke-virtual {p1}, Ljava/lang/Class;->isLocalClass()Z
  75. move-result p1
  76. if-eqz p1, :cond_1
  77. :cond_0
  78. const/4 p1, 0x1
  79. goto :goto_0
  80. :cond_1
  81. const/4 p1, 0x0
  82. :goto_0
  83. return p1
  84. .end method
  85. .method private isInnerClass(Ljava/lang/Class;)Z
  86. .locals 1
  87. .annotation system Ldalvik/annotation/Signature;
  88. value = {
  89. "(",
  90. "Ljava/lang/Class<",
  91. "*>;)Z"
  92. }
  93. .end annotation
  94. invoke-virtual {p1}, Ljava/lang/Class;->isMemberClass()Z
  95. move-result v0
  96. if-eqz v0, :cond_0
  97. invoke-direct {p0, p1}, Lcom/google/gson/internal/Excluder;->isStatic(Ljava/lang/Class;)Z
  98. move-result p1
  99. if-nez p1, :cond_0
  100. const/4 p1, 0x1
  101. goto :goto_0
  102. :cond_0
  103. const/4 p1, 0x0
  104. :goto_0
  105. return p1
  106. .end method
  107. .method private isStatic(Ljava/lang/Class;)Z
  108. .locals 0
  109. .annotation system Ldalvik/annotation/Signature;
  110. value = {
  111. "(",
  112. "Ljava/lang/Class<",
  113. "*>;)Z"
  114. }
  115. .end annotation
  116. invoke-virtual {p1}, Ljava/lang/Class;->getModifiers()I
  117. move-result p1
  118. and-int/lit8 p1, p1, 0x8
  119. if-eqz p1, :cond_0
  120. const/4 p1, 0x1
  121. goto :goto_0
  122. :cond_0
  123. const/4 p1, 0x0
  124. :goto_0
  125. return p1
  126. .end method
  127. .method private isValidSince(Lcom/google/gson/annotations/Since;)Z
  128. .locals 4
  129. if-eqz p1, :cond_0
  130. invoke-interface {p1}, Lcom/google/gson/annotations/Since;->value()D
  131. move-result-wide v0
  132. iget-wide v2, p0, Lcom/google/gson/internal/Excluder;->version:D
  133. cmpl-double p1, v0, v2
  134. if-lez p1, :cond_0
  135. const/4 p1, 0x0
  136. return p1
  137. :cond_0
  138. const/4 p1, 0x1
  139. return p1
  140. .end method
  141. .method private isValidUntil(Lcom/google/gson/annotations/Until;)Z
  142. .locals 4
  143. if-eqz p1, :cond_0
  144. invoke-interface {p1}, Lcom/google/gson/annotations/Until;->value()D
  145. move-result-wide v0
  146. iget-wide v2, p0, Lcom/google/gson/internal/Excluder;->version:D
  147. cmpg-double p1, v0, v2
  148. if-gtz p1, :cond_0
  149. const/4 p1, 0x0
  150. return p1
  151. :cond_0
  152. const/4 p1, 0x1
  153. return p1
  154. .end method
  155. .method private isValidVersion(Lcom/google/gson/annotations/Since;Lcom/google/gson/annotations/Until;)Z
  156. .locals 0
  157. invoke-direct {p0, p1}, Lcom/google/gson/internal/Excluder;->isValidSince(Lcom/google/gson/annotations/Since;)Z
  158. move-result p1
  159. if-eqz p1, :cond_0
  160. invoke-direct {p0, p2}, Lcom/google/gson/internal/Excluder;->isValidUntil(Lcom/google/gson/annotations/Until;)Z
  161. move-result p1
  162. if-eqz p1, :cond_0
  163. const/4 p1, 0x1
  164. goto :goto_0
  165. :cond_0
  166. const/4 p1, 0x0
  167. :goto_0
  168. return p1
  169. .end method
  170. # virtual methods
  171. .method protected clone()Lcom/google/gson/internal/Excluder;
  172. .locals 2
  173. :try_start_0
  174. invoke-super {p0}, Ljava/lang/Object;->clone()Ljava/lang/Object;
  175. move-result-object v0
  176. check-cast v0, Lcom/google/gson/internal/Excluder;
  177. :try_end_0
  178. .catch Ljava/lang/CloneNotSupportedException; {:try_start_0 .. :try_end_0} :catch_0
  179. return-object v0
  180. :catch_0
  181. move-exception v0
  182. new-instance v1, Ljava/lang/AssertionError;
  183. invoke-direct {v1, v0}, Ljava/lang/AssertionError;-><init>(Ljava/lang/Object;)V
  184. throw v1
  185. .end method
  186. .method protected bridge synthetic clone()Ljava/lang/Object;
  187. .locals 1
  188. .annotation system Ldalvik/annotation/Throws;
  189. value = {
  190. Ljava/lang/CloneNotSupportedException;
  191. }
  192. .end annotation
  193. invoke-virtual {p0}, Lcom/google/gson/internal/Excluder;->clone()Lcom/google/gson/internal/Excluder;
  194. move-result-object v0
  195. return-object v0
  196. .end method
  197. .method public create(Lcom/google/gson/Gson;Lcom/google/gson/reflect/TypeToken;)Lcom/google/gson/TypeAdapter;
  198. .locals 8
  199. .annotation system Ldalvik/annotation/Signature;
  200. value = {
  201. "<T:",
  202. "Ljava/lang/Object;",
  203. ">(",
  204. "Lcom/google/gson/Gson;",
  205. "Lcom/google/gson/reflect/TypeToken<",
  206. "TT;>;)",
  207. "Lcom/google/gson/TypeAdapter<",
  208. "TT;>;"
  209. }
  210. .end annotation
  211. invoke-virtual {p2}, Lcom/google/gson/reflect/TypeToken;->getRawType()Ljava/lang/Class;
  212. move-result-object v0
  213. const/4 v1, 0x1
  214. invoke-virtual {p0, v0, v1}, Lcom/google/gson/internal/Excluder;->excludeClass(Ljava/lang/Class;Z)Z
  215. move-result v5
  216. const/4 v1, 0x0
  217. invoke-virtual {p0, v0, v1}, Lcom/google/gson/internal/Excluder;->excludeClass(Ljava/lang/Class;Z)Z
  218. move-result v4
  219. if-nez v5, :cond_0
  220. if-nez v4, :cond_0
  221. const/4 p1, 0x0
  222. return-object p1
  223. :cond_0
  224. new-instance v0, Lcom/google/gson/internal/Excluder$1;
  225. move-object v2, v0
  226. move-object v3, p0
  227. move-object v6, p1
  228. move-object v7, p2
  229. invoke-direct/range {v2 .. v7}, Lcom/google/gson/internal/Excluder$1;-><init>(Lcom/google/gson/internal/Excluder;ZZLcom/google/gson/Gson;Lcom/google/gson/reflect/TypeToken;)V
  230. return-object v0
  231. .end method
  232. .method public disableInnerClassSerialization()Lcom/google/gson/internal/Excluder;
  233. .locals 2
  234. invoke-virtual {p0}, Lcom/google/gson/internal/Excluder;->clone()Lcom/google/gson/internal/Excluder;
  235. move-result-object v0
  236. const/4 v1, 0x0
  237. iput-boolean v1, v0, Lcom/google/gson/internal/Excluder;->serializeInnerClasses:Z
  238. return-object v0
  239. .end method
  240. .method public excludeClass(Ljava/lang/Class;Z)Z
  241. .locals 6
  242. .annotation system Ldalvik/annotation/Signature;
  243. value = {
  244. "(",
  245. "Ljava/lang/Class<",
  246. "*>;Z)Z"
  247. }
  248. .end annotation
  249. iget-wide v0, p0, Lcom/google/gson/internal/Excluder;->version:D
  250. const/4 v2, 0x1
  251. const-wide/high16 v3, -0x4010000000000000L # -1.0
  252. cmpl-double v5, v0, v3
  253. if-eqz v5, :cond_0
  254. const-class v0, Lcom/google/gson/annotations/Since;
  255. invoke-virtual {p1, v0}, Ljava/lang/Class;->getAnnotation(Ljava/lang/Class;)Ljava/lang/annotation/Annotation;
  256. move-result-object v0
  257. check-cast v0, Lcom/google/gson/annotations/Since;
  258. const-class v1, Lcom/google/gson/annotations/Until;
  259. invoke-virtual {p1, v1}, Ljava/lang/Class;->getAnnotation(Ljava/lang/Class;)Ljava/lang/annotation/Annotation;
  260. move-result-object v1
  261. check-cast v1, Lcom/google/gson/annotations/Until;
  262. invoke-direct {p0, v0, v1}, Lcom/google/gson/internal/Excluder;->isValidVersion(Lcom/google/gson/annotations/Since;Lcom/google/gson/annotations/Until;)Z
  263. move-result v0
  264. if-nez v0, :cond_0
  265. return v2
  266. :cond_0
  267. iget-boolean v0, p0, Lcom/google/gson/internal/Excluder;->serializeInnerClasses:Z
  268. if-nez v0, :cond_1
  269. invoke-direct {p0, p1}, Lcom/google/gson/internal/Excluder;->isInnerClass(Ljava/lang/Class;)Z
  270. move-result v0
  271. if-eqz v0, :cond_1
  272. return v2
  273. :cond_1
  274. invoke-direct {p0, p1}, Lcom/google/gson/internal/Excluder;->isAnonymousOrLocal(Ljava/lang/Class;)Z
  275. move-result v0
  276. if-eqz v0, :cond_2
  277. return v2
  278. :cond_2
  279. if-eqz p2, :cond_3
  280. iget-object p2, p0, Lcom/google/gson/internal/Excluder;->serializationStrategies:Ljava/util/List;
  281. goto :goto_0
  282. :cond_3
  283. iget-object p2, p0, Lcom/google/gson/internal/Excluder;->deserializationStrategies:Ljava/util/List;
  284. :goto_0
  285. invoke-interface {p2}, Ljava/util/List;->iterator()Ljava/util/Iterator;
  286. move-result-object p2
  287. :cond_4
  288. invoke-interface {p2}, Ljava/util/Iterator;->hasNext()Z
  289. move-result v0
  290. if-eqz v0, :cond_5
  291. invoke-interface {p2}, Ljava/util/Iterator;->next()Ljava/lang/Object;
  292. move-result-object v0
  293. check-cast v0, Lcom/google/gson/ExclusionStrategy;
  294. invoke-interface {v0, p1}, Lcom/google/gson/ExclusionStrategy;->shouldSkipClass(Ljava/lang/Class;)Z
  295. move-result v0
  296. if-eqz v0, :cond_4
  297. return v2
  298. :cond_5
  299. const/4 p1, 0x0
  300. return p1
  301. .end method
  302. .method public excludeField(Ljava/lang/reflect/Field;Z)Z
  303. .locals 6
  304. iget v0, p0, Lcom/google/gson/internal/Excluder;->modifiers:I
  305. invoke-virtual {p1}, Ljava/lang/reflect/Field;->getModifiers()I
  306. move-result v1
  307. and-int/2addr v0, v1
  308. const/4 v1, 0x1
  309. if-eqz v0, :cond_0
  310. return v1
  311. :cond_0
  312. iget-wide v2, p0, Lcom/google/gson/internal/Excluder;->version:D
  313. const-wide/high16 v4, -0x4010000000000000L # -1.0
  314. cmpl-double v0, v2, v4
  315. if-eqz v0, :cond_1
  316. const-class v0, Lcom/google/gson/annotations/Since;
  317. invoke-virtual {p1, v0}, Ljava/lang/reflect/Field;->getAnnotation(Ljava/lang/Class;)Ljava/lang/annotation/Annotation;
  318. move-result-object v0
  319. check-cast v0, Lcom/google/gson/annotations/Since;
  320. const-class v2, Lcom/google/gson/annotations/Until;
  321. invoke-virtual {p1, v2}, Ljava/lang/reflect/Field;->getAnnotation(Ljava/lang/Class;)Ljava/lang/annotation/Annotation;
  322. move-result-object v2
  323. check-cast v2, Lcom/google/gson/annotations/Until;
  324. invoke-direct {p0, v0, v2}, Lcom/google/gson/internal/Excluder;->isValidVersion(Lcom/google/gson/annotations/Since;Lcom/google/gson/annotations/Until;)Z
  325. move-result v0
  326. if-nez v0, :cond_1
  327. return v1
  328. :cond_1
  329. invoke-virtual {p1}, Ljava/lang/reflect/Field;->isSynthetic()Z
  330. move-result v0
  331. if-eqz v0, :cond_2
  332. return v1
  333. :cond_2
  334. iget-boolean v0, p0, Lcom/google/gson/internal/Excluder;->requireExpose:Z
  335. if-eqz v0, :cond_5
  336. const-class v0, Lcom/google/gson/annotations/Expose;
  337. invoke-virtual {p1, v0}, Ljava/lang/reflect/Field;->getAnnotation(Ljava/lang/Class;)Ljava/lang/annotation/Annotation;
  338. move-result-object v0
  339. check-cast v0, Lcom/google/gson/annotations/Expose;
  340. if-eqz v0, :cond_4
  341. if-eqz p2, :cond_3
  342. invoke-interface {v0}, Lcom/google/gson/annotations/Expose;->serialize()Z
  343. move-result v0
  344. if-nez v0, :cond_5
  345. goto :goto_0
  346. :cond_3
  347. invoke-interface {v0}, Lcom/google/gson/annotations/Expose;->deserialize()Z
  348. move-result v0
  349. if-nez v0, :cond_5
  350. :cond_4
  351. :goto_0
  352. return v1
  353. :cond_5
  354. iget-boolean v0, p0, Lcom/google/gson/internal/Excluder;->serializeInnerClasses:Z
  355. if-nez v0, :cond_6
  356. invoke-virtual {p1}, Ljava/lang/reflect/Field;->getType()Ljava/lang/Class;
  357. move-result-object v0
  358. invoke-direct {p0, v0}, Lcom/google/gson/internal/Excluder;->isInnerClass(Ljava/lang/Class;)Z
  359. move-result v0
  360. if-eqz v0, :cond_6
  361. return v1
  362. :cond_6
  363. invoke-virtual {p1}, Ljava/lang/reflect/Field;->getType()Ljava/lang/Class;
  364. move-result-object v0
  365. invoke-direct {p0, v0}, Lcom/google/gson/internal/Excluder;->isAnonymousOrLocal(Ljava/lang/Class;)Z
  366. move-result v0
  367. if-eqz v0, :cond_7
  368. return v1
  369. :cond_7
  370. if-eqz p2, :cond_8
  371. iget-object p2, p0, Lcom/google/gson/internal/Excluder;->serializationStrategies:Ljava/util/List;
  372. goto :goto_1
  373. :cond_8
  374. iget-object p2, p0, Lcom/google/gson/internal/Excluder;->deserializationStrategies:Ljava/util/List;
  375. :goto_1
  376. invoke-interface {p2}, Ljava/util/List;->isEmpty()Z
  377. move-result v0
  378. if-nez v0, :cond_a
  379. new-instance v0, Lcom/google/gson/FieldAttributes;
  380. invoke-direct {v0, p1}, Lcom/google/gson/FieldAttributes;-><init>(Ljava/lang/reflect/Field;)V
  381. invoke-interface {p2}, Ljava/util/List;->iterator()Ljava/util/Iterator;
  382. move-result-object p1
  383. :cond_9
  384. invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z
  385. move-result p2
  386. if-eqz p2, :cond_a
  387. invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
  388. move-result-object p2
  389. check-cast p2, Lcom/google/gson/ExclusionStrategy;
  390. invoke-interface {p2, v0}, Lcom/google/gson/ExclusionStrategy;->shouldSkipField(Lcom/google/gson/FieldAttributes;)Z
  391. move-result p2
  392. if-eqz p2, :cond_9
  393. return v1
  394. :cond_a
  395. const/4 p1, 0x0
  396. return p1
  397. .end method
  398. .method public excludeFieldsWithoutExposeAnnotation()Lcom/google/gson/internal/Excluder;
  399. .locals 2
  400. invoke-virtual {p0}, Lcom/google/gson/internal/Excluder;->clone()Lcom/google/gson/internal/Excluder;
  401. move-result-object v0
  402. const/4 v1, 0x1
  403. iput-boolean v1, v0, Lcom/google/gson/internal/Excluder;->requireExpose:Z
  404. return-object v0
  405. .end method
  406. .method public withExclusionStrategy(Lcom/google/gson/ExclusionStrategy;ZZ)Lcom/google/gson/internal/Excluder;
  407. .locals 2
  408. invoke-virtual {p0}, Lcom/google/gson/internal/Excluder;->clone()Lcom/google/gson/internal/Excluder;
  409. move-result-object v0
  410. if-eqz p2, :cond_0
  411. new-instance p2, Ljava/util/ArrayList;
  412. iget-object v1, p0, Lcom/google/gson/internal/Excluder;->serializationStrategies:Ljava/util/List;
  413. invoke-direct {p2, v1}, Ljava/util/ArrayList;-><init>(Ljava/util/Collection;)V
  414. iput-object p2, v0, Lcom/google/gson/internal/Excluder;->serializationStrategies:Ljava/util/List;
  415. iget-object p2, v0, Lcom/google/gson/internal/Excluder;->serializationStrategies:Ljava/util/List;
  416. invoke-interface {p2, p1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
  417. :cond_0
  418. if-eqz p3, :cond_1
  419. new-instance p2, Ljava/util/ArrayList;
  420. iget-object p3, p0, Lcom/google/gson/internal/Excluder;->deserializationStrategies:Ljava/util/List;
  421. invoke-direct {p2, p3}, Ljava/util/ArrayList;-><init>(Ljava/util/Collection;)V
  422. iput-object p2, v0, Lcom/google/gson/internal/Excluder;->deserializationStrategies:Ljava/util/List;
  423. iget-object p2, v0, Lcom/google/gson/internal/Excluder;->deserializationStrategies:Ljava/util/List;
  424. invoke-interface {p2, p1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
  425. :cond_1
  426. return-object v0
  427. .end method
  428. .method public varargs withModifiers([I)Lcom/google/gson/internal/Excluder;
  429. .locals 5
  430. invoke-virtual {p0}, Lcom/google/gson/internal/Excluder;->clone()Lcom/google/gson/internal/Excluder;
  431. move-result-object v0
  432. const/4 v1, 0x0
  433. iput v1, v0, Lcom/google/gson/internal/Excluder;->modifiers:I
  434. array-length v2, p1
  435. :goto_0
  436. if-ge v1, v2, :cond_0
  437. aget v3, p1, v1
  438. iget v4, v0, Lcom/google/gson/internal/Excluder;->modifiers:I
  439. or-int/2addr v3, v4
  440. iput v3, v0, Lcom/google/gson/internal/Excluder;->modifiers:I
  441. add-int/lit8 v1, v1, 0x1
  442. goto :goto_0
  443. :cond_0
  444. return-object v0
  445. .end method
  446. .method public withVersion(D)Lcom/google/gson/internal/Excluder;
  447. .locals 1
  448. invoke-virtual {p0}, Lcom/google/gson/internal/Excluder;->clone()Lcom/google/gson/internal/Excluder;
  449. move-result-object v0
  450. iput-wide p1, v0, Lcom/google/gson/internal/Excluder;->version:D
  451. return-object v0
  452. .end method