Commit Graph

28 Commits

Author SHA1 Message Date
Maicol 2658aca66a
Fix error prone warnings (#2316)
* Fix `OperatorPrecedence` warn in `JsonWriter#close`

* Fix `ReferenceEquality` warn in `LinkedTreeMap#replaceInParent`

* Fix `UnnecessaryParentheses` warn in `LinkedTreeMap#replaceInParent`

* Fix `ReferenceEquality` warn in `LinkedTreeMap#hasNext`

* Fix `ReferenceEquality` warn in `LinkedTreeMap#nextNode`

* Adds `error_prone_annotations` to the `pom.xml` of `gson`

* Fix `InlineMeSuggester` warns in `JsonParser`

* Fix `UnnecessaryParentheses` warns in `ConstructorConstructor#newDefaultImplementationConstructor`

* Fix `ThreadLocalUsage` warn in `Gson`

* Fix `JdkObsolete` warn in `GsonBuilder`

* Fix `ReferenceEquality` warn in `LazilyParsedNumber#equals`

* Fix `OperatorPrecedence` warn in `TreeTypeAdapter#create`

* Fix `OperatorPrecedence` warn in `ArrayTypeAdapter`

* Fix `UnnecessaryParentheses` warn in `TypeAdapters`

* Adds `-XepExcludedPaths` flag to ErrorProne plugin to exclude tests and proto path

* Fix `ClassNewInstance` warn in `InterceptorAdapter`

* Fix `ThreadLocalUsage` warn in `GraphAdapterBuilder`

* Fix `JdkObsolete` warn in `GraphAdapterBuilder`

* Revert "Adds `error_prone_annotations` to the `pom.xml` of `gson`"

This reverts commit 14af14dfa23b46a54f4855a70ccf2b0a2cdc3e3f.

* Revert "Fix `InlineMeSuggester` warns in `JsonParser`"

This reverts commit 095bfd517e06510e4cc9cc6b1aac58ad9bf3038a.

* Adds `@SuppressWarnings("ThreadLocalUsage")`

* Fix `OperatorPrecedence` in `JsonWriter`

* Revert "Fix `ReferenceEquality` warn in `LinkedTreeMap#nextNode`"

This reverts commit 387746c7f7e3d0943c8f80501f5d9c3710f4862e.

* Adds `@SuppressWarnings("ReferenceEquality")`

* Adds `guava-testlib` to the gson `pom.xml`

* `@SuppressWarnings("TruthSelfEquals")` removed to use `EqualsTester()`
2023-02-15 05:18:43 -08:00
Maicol 9f26679e7a
Adds Error Prone to the `maven-compiler-plugin` (#2308)
* Adds Error Prone to the `pom.xml`

* Adds Error Prone annotations to avoid compiling errors

* Adds profile to run Error Prone in JDK8

* Revert "Adds profile to run Error Prone in JDK8"

This reverts commit 61771d0da55003ea5bc8c6f086d925aec583c9a2.

* Fix Error Prone warn

* Add comment to `pom.xml`

* Fix the `@SuppressWarnings("GetClassOnClass")`

* Replace the Error Prone link in the `pom.xml`

* Disable Error Prone with jdk-15`

* Remove a new-line in `pom.xml`
2023-02-06 06:13:28 -08:00
Maicol 49b00d1a86
Port all Junit assert to Truth asserts (#2304)
* Port Junit assert to Truth in `com.google.gson.stream`

* Port Junit assert to Truth in `com.google.gson.regression`

* Port Junit assert to Truth in `om.google.gson.reflect`

* Port Junit assert to Truth in `com.google.gson.metrics`

* Port Junit assert to Truth in `com.google.gson.internal`

* Port Junit assert to Truth in `com.google.gson.internal.sql`

* Port Junit assert to Truth in `com.google.gson.internal.reflect`

* Port Junit assert to Truth in `com.google.gson.internal.bind`

* Port Junit assert to Truth in `com.google.gson.internal.bind.util`

* Port Junit assert to Truth in `com.google.gson.functional`

* Replaces `List.of` with `Arrays.asList` to grant legacy

* Simplify `==` asserts

* Simplify `.contain()` asserts + Minor fixes

* Simplify asserts
2023-01-31 11:20:54 -08:00
Maicol be87c3fd0e
Port Junit test to Truth in the package `com.google.gson` of the module `gson` (#2299)
* Add the Truth dependency

* Port Junit test to Truth in the package `com.google.gson` of the module `gson`

* Replace the `assertThat(e.getMessage()).isEqualTo(...)"` with `assertThat(e).hasMessageThat().isEqualTo(...)`

* Minor fixes
2023-01-17 07:59:10 -08:00
Doug Hoard ceb3b8747e
Added JsonObject method isEmpty() (#2233)
* Added isEmpty()

* Fixed Javadoc typo

* Changed test to use assertTrue() and assertFalse()
2022-11-13 12:58:30 -08:00
Marcono1234 954d526af4
Add `JsonArray.asList` and `JsonObject.asMap` view methods (#2225)
* Add `JsonArray.asList` and `JsonObject.asMap` view methods

* Address review comments
2022-10-16 12:30:49 -07:00
Marcono1234 847d7f6638
Improve documentation (#2193)
* Improve JsonElement subclasses javadoc and add tests

* Slightly improve JsonSerializer and JsonDeserializer javadoc

* Improve ReflectionAccessTest failure message

* Improve documentation regarding field and class exclusion
2022-09-09 07:32:55 -07:00
Marcono1234 5e1005ea27
Disallow `JsonObject` `Entry.setValue(null)` (#2167)
* Disallow JsonObject Entry.setValue(null)

* Adjust comments in JsonObjectTest
2022-08-18 13:10:43 -07:00
Marcono1234 ca2ed748ba
Fix warnings (#2014)
* Fix warnings

* Address review feedback
2021-11-07 08:43:49 -08:00
Degubi c5a3f21fba Refactor JsonParser to statics & fix tests 2019-04-15 22:35:10 -04:00
Mark Hess 4976e420fc Add keySet method and test (#942) 2016-12-13 22:15:49 -08:00
Jake Wharton c16be41e77 Expose JsonObject size. 2016-06-10 00:46:32 -04:00
Joel Leitch 14f16e2d0c Adding Red-Black Tree implementation and tying it into the Gson bindings. 2012-10-11 03:15:49 +00:00
Jesse Wilson 9c4b23b39a JsonObject.deepCopy() for Gson. 2012-08-21 01:19:43 +00:00
Jesse Wilson 172143df7c Removing JsonObject.deepCopy() and JsonArray.deepCopy() 2011-11-12 23:32:44 +00:00
Jesse Wilson f74dffc6fd Add deepCopy to JsonArray and JsonObject.
Resolves issue 301.
2011-06-17 21:46:28 +00:00
Joel Leitch c9ee7adcc5 Start using JsonNull.INSTANCE everywhere and remove creation method. 2011-06-03 19:02:28 +00:00
Inderjeet Singh f2eb76eac9 removed deprecation warnings by using JsonNull.INSTANCE 2011-05-25 16:48:39 +00:00
Inderjeet Singh feb9617bf0 Incorporated comments from r726 2011-04-04 22:09:51 +00:00
Joel Leitch 279c0e87ed Update Precondition checks and have it throw a NPE instead. 2011-03-16 07:23:44 +00:00
Jesse Wilson 3d006c90a2 equals & hashCode for subclasses of JsonElement.
Resolves issue 64.
2011-02-15 00:14:20 +00:00
Jesse Wilson 486820f515 Fix some test problems.
JsonWriter was using suboptimal escape characters for newlines etc: unicode escapes rather than \x escapes.

JsonObjectTest was banning empty and whitespace-only keys. These values are permitted as of r585.
2010-08-28 08:18:13 +00:00
Jesse Wilson 7e1e4eab07 Remove the constraint that map keys mustn't be the empty string.
See bug 227.
2010-08-28 05:02:33 +00:00
Inderjeet Singh de0f8da151 replaced unchecked suppressed warnings token with more specific rawtypes.
removed unused imports.
2010-08-20 16:27:46 +00:00
Jesse Wilson bc5b836103 Test demonstrating a bug reported in issue 182, wherein malformed JSON is emitted when an property name contains a double-quote. 2010-08-20 05:45:51 +00:00
Joel Leitch d87d3f807f Added functional tests for user defined exclusion strategy.
Added test to ensure empty/null properties are added for the JsonObject.
2009-10-09 21:12:07 +00:00
Joel Leitch 5ae7e1f803 Adding new convenience method to JsonObject for adding Booleans and Characters. 2008-11-30 23:36:29 +00:00
Joel Leitch 3df2d44e40 Adding a "remove" method to the JsonObject class. Created a unit test to ensure it is functioning properly. 2008-11-19 01:22:21 +00:00