Commit Graph

37 Commits

Author SHA1 Message Date
Maicol 742fd50ff7
Fix error prone warns (#2319)
* Adds a javadoc summary to the methods in the `SerializedName` annotation

Fixes the `MissingSummary` warn given by ErrorProne

* Adds a javadoc summary to the methods of the `ExclusionStrategy` annotation

 Fixes the `MissingSummary` warn given by ErrorProne

* Adds a javadoc summary to `getDeclaringClass()` and `getName()` methods of the `FieldAttributes` class

 Fixes the `MissingSummary` warn given by ErrorProne

* Adds a javadoc summary to `getMajorJavaVersion()` and `isJava9OrLater()` methods of the `JavaVersion` class

 Fixes the `MissingSummary` warn given by ErrorProne

* Adds a comment in the empty catch block of the `AccessChecker:101` class

 Fixes the `EmptyCatch` warn given by ErrorProne

* Adds a comment in the empty catch block of the `DefaultDateTypeAdapter:158` class

 Fixes the `EmptyCatch` warn given by ErrorProne

* Adds a comment in the empty catch blocks of the `UnsafeAllocator:(67|92|113)` class

 Fixes the `EmptyCatch` warn given by ErrorProne

* Adds a comment in the empty catch block of the `DateTypeAdapter:85` class

 Fixes the `EmptyCatch` warn given by ErrorProne

* Fixes javadoc param of the `deserialize(...)` method of the `JsonDeserializer` interface

 Fixes the `InvalidParam` warn given by ErrorProne

* Adds a charset `StandardCharsets.UTF_8` in the `resourceToString()` method of the `ParseBenchmark` class

Fixes the `DefaultCharset` warn given by ErrorProne

* Fixes a typo

* Implements review feedback

* Adds blank line before @ tag.
2023-02-17 09:58:16 -08:00
Marcono1234 7f77ad4ff6
Replace `$Gson$Preconditions.checkNotNull` with `Objects.requireNonNull` (#2180)
* Replace $Gson$Preconditions.checkNotNull with Objects.requireNonNull

* Add back checkNotNull
2022-08-22 07:22:32 -07:00
Marcono1234 6d2557d5d1
Remove unused package-private FieldAttributes methods (#2162) 2022-07-29 10:10:54 -07:00
Igor Mysak ee691fba43 fix javaDoc (#1122) 2017-07-21 10:12:25 -07:00
Dongjoon Hyun aa209fa255 Fix some typos in gson comments. 2016-02-15 14:11:23 -08:00
Jesse Wilson 7e47f46ac1 Remove an unused method. 2011-11-23 13:39:33 +00:00
Jesse Wilson aa2f61b7d8 Rename GsonExclusionStrategy to Excluder. The new class is its own factory, which simplifies its caller in GsonBuilder. It no longer implements ExclusionStrategy, which allows the callers to pass in a boolean for serialize/deserialize. This allows us to use one excluder for both code paths. The delegate ExclusionStrategy instances might end up not being shared so it has two lists internally. 2011-11-22 07:37:13 +00:00
Jesse Wilson 4da08b0ec6 Remove two implementation classes that weren't generally useful:
- The cache interface has only one implementation. Drop the interface; we can add it back later if necessary.
 - The DefaultTypeAdapters class contains one member class. Just make that a top-level class.
2011-11-21 06:23:42 +00:00
Jesse Wilson e23973afec Smash together ReflectiveTypeAdapterFactory and its subclass. The separation was useful earlier when we were contemplating keeping Gson and MiniGson separate. 2011-11-21 05:42:30 +00:00
Jesse Wilson de727d8c48 Delete dead code found by coverage 2011-10-01 02:04:48 +00:00
Jesse Wilson 25c6ae177b Down to 22 failing tests.
Consolidated all of the different code paths that we use to construct instances. We now have an ObjectConstructor class that knows what type it constructs; this means that we don't need to ever do reflection to lookup a constructor at construction time.

Cleaned up some buggy type adapters, particularly around handling of null.

Removed dead code for object graph navigation.

Moved some classes into 'internal' so they are visible to the 'bind' subpackage.

Turned some TypeAdapterFactory/TypeAdapter pairs inside out so that the TypeAdapter is now the inner class. This is necessary so that the factories can take parameters.

Added an API to request the 'next' type adapter for a type. This allows type adapters to compose other type adapters. We're using this in two places:
 - where the user has excluded a type from serialization but not deserialization, we need to use the "default" deserialization but interpose null on serialization. We create a type adapter that delegates for one and returns null for the other.
 - similarly when a DOM type serializer is registered but no deserializer, or vice versa.
This is the biggest change to the MiniGson core.

For backwards compatibility, return null for the empty string.

Simplify JsonSerializationContext/JsonDeserializationContext to simply call through to GSON. SerializeDefault is currently unsupported.

More useful error messages when calling getAsBoolean on a JsonNull.

Remove currently unused MemoryRefStack. We might need this back again, though wiring it back in will be much more difficult because we don't interject ourselves between the users' various type adapters.
2011-09-11 07:04:56 +00:00
Joel Leitch aa89773008 Quick fix for threading issue. Should maybe look into synchronizing this method instead. 2011-06-07 01:28:30 +00:00
Inderjeet Singh 8fd4072f9b fixed javadocs 2011-06-03 19:01:08 +00:00
Joel Leitch 854b92a78f Comments from r789 2011-04-07 18:00:12 +00:00
Inderjeet Singh 4bd261ae06 Made FieldNamingStrategy2 and its corresponding builder method package-private. 2011-04-07 17:41:35 +00:00
Inderjeet Singh 05ae10a144 removed the constructor in FieldAttributes that was only used in tests. 2011-04-06 00:51:01 +00:00
Inderjeet Singh c8bd121db2 Renamed $Preconditions to $Gson$Preconditions and $Types to $Gson$Types.
Marked the two private classes in $Types as final.
2011-04-06 00:26:57 +00:00
Inderjeet Singh 8d3bfc0f47 Marked the getTypeInfoForField() method package private as it was inadvertently marked public.
Removed commented out code in pom.xml that is now obsoleted with sonatype syncing.
2011-04-06 00:13:31 +00:00
Joel Leitch 52bf144859 Comments for r767 2011-04-05 23:57:13 +00:00
Inderjeet Singh bf4ab04413 replaced multiple caches in ReflectingFieldNavigator with a single one.
Two additional optimizations:
- storing the field list for the entire type hierarchy in the cache instead of navigating it every time.
- storing the resolved type for the field in FieldAttributes instead of using reflection every time.
2011-04-01 23:54:41 +00:00
Inderjeet Singh 5bc80cd693 Moved Cache, LruCache, Pair, Primitives and UnsafeAllocator to com.google.gson and made them package private. 2011-03-30 13:59:06 +00:00
Jesse Wilson 4efb133b4a bling bling
Prefix internal classes with $ to prevent them from interfering with IDE's auto import functionality.
2011-03-29 21:24:26 +00:00
Joel Leitch 861e047a62 Create an "internals" package for classes that we do not want to share, but is needed across multiple pacakges.
As well, move non-Gson specific classes, such as Preconditions, to this new "internals" package.
2011-03-21 22:30:35 +00:00
Joel Leitch 279c0e87ed Update Precondition checks and have it throw a NPE instead. 2011-03-16 07:23:44 +00:00
Inderjeet Singh 520259fefa removed eclipse warnings. 2010-11-12 19:21:16 +00:00
Joel Leitch d0977c2e3a Exposing the declaring class for the field wrapped by FieldAttributes. 2010-11-01 22:31:48 +00:00
Joel Leitch 9c7bfc677a Allow cache size to be configured. 2010-05-19 20:47:27 +00:00
Joel Leitch 9816426bba Add new Cache interface and LRU Cache implementation to cache field annotations per "Class" (rather than per instance). This results in a significant speed-up (approx. 3X) when serializing/deserializing the same classes over and over again. 2010-01-10 00:32:21 +00:00
Joel Leitch e3af076ff2 Deprecate the FieldNamingStrategy interface and replace it with FieldNamingStrategy2. This is the first step to help make it easy to cache field annotations across all instances of a class, etc. 2010-01-09 22:43:27 +00:00
Joel Leitch c329d020b9 Make some fields final and initialize immediately. 2009-12-03 23:13:39 +00:00
Joel Leitch 33e816dcf0 More lazy initialization done for FieldAttributes. 2009-12-03 22:28:58 +00:00
Joel Leitch 641390b1a1 Lazily initialize fields in FieldAttributes to prevent multiple Java reflection invocations. 2009-12-03 22:17:39 +00:00
Joel Leitch 81e6ae25f1 Make FieldAttributes public so it can be used by public clients. 2009-10-09 03:11:16 +00:00
Joel Leitch 282ef30280 Updating JavaDoc tag to @code instead of @link. 2009-10-09 03:03:04 +00:00
Inderjeet Singh e37add7836 Implemented some code review comments from r482 2009-10-09 01:35:45 +00:00
Joel Leitch dc5922e703 Addresses comments in r481 (except for the interface change....leaving FieldAttributes as a class).
Change the exclusion order in ObjectNavigator to exclude a top-level class (if exclusion strategy suggests class should be skipped) even if it is marked with a custom (de)serializer.
2009-10-08 20:51:40 +00:00
Joel Leitch 839b0c2f94 Refactored exclusion strategies so that they can easily be exposed as part of the public API. 2009-10-07 09:23:14 +00:00