Skip to content

Commit 1f859ec

Browse files
author
Inderjeet Singh
committed
addressed code review comments.
1 parent 2df6550 commit 1f859ec

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

gson/src/main/java/com/google/gson/Gson.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public final class Gson {
134134
private final boolean generateNonExecutableJson;
135135
private final boolean prettyPrinting;
136136
private final boolean lenient;
137-
private JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory;
137+
private final JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory;
138138

139139
/**
140140
* Constructs a Gson object with default configuration. The default configuration has the
@@ -488,14 +488,13 @@ public <T> TypeAdapter<T> getAdapter(TypeToken<T> type) {
488488
* @since 2.2
489489
*/
490490
public <T> TypeAdapter<T> getDelegateAdapter(TypeAdapterFactory skipPast, TypeToken<T> type) {
491-
boolean skipPastFound = false;
492-
493491
// Hack. If the skipPast factory isn't registered, assume the factory is being requested via
494492
// our @JsonAdapter annotation.
495493
if (!factories.contains(skipPast)) {
496494
skipPast = jsonAdapterFactory;
497495
}
498496

497+
boolean skipPastFound = false;
499498
for (TypeAdapterFactory factory : factories) {
500499
if (!skipPastFound) {
501500
if (factory == skipPast) {

gson/src/test/java/com/google/gson/functional/JsonAdapterAnnotationOnFieldsTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -274,20 +274,20 @@ private static final class LongToStringTypeAdapterFactory implements TypeAdapter
274274
}
275275

276276
public void testFieldAnnotationWorksForParameterizedType() {
277-
Gson gson = new Gson();
278-
String json = gson.toJson(new Gizmo2(Arrays.asList(new Part("Part"))));
279-
assertEquals("{\"part\":\"GizmoPartTypeAdapterFactory\"}", json);
280-
Gizmo2 computer = gson.fromJson("{'part':'Part'}", Gizmo2.class);
281-
assertEquals("GizmoPartTypeAdapterFactory", computer.part.get(0).name);
282-
}
277+
Gson gson = new Gson();
278+
String json = gson.toJson(new Gizmo2(Arrays.asList(new Part("Part"))));
279+
assertEquals("{\"part\":\"GizmoPartTypeAdapterFactory\"}", json);
280+
Gizmo2 computer = gson.fromJson("{'part':'Part'}", Gizmo2.class);
281+
assertEquals("GizmoPartTypeAdapterFactory", computer.part.get(0).name);
282+
}
283283

284284
private static final class Gizmo2 {
285-
@JsonAdapter(Gizmo2PartTypeAdapterFactory.class)
286-
List<Part> part;
287-
Gizmo2(List<Part> part) {
288-
this.part = part;
289-
}
285+
@JsonAdapter(Gizmo2PartTypeAdapterFactory.class)
286+
List<Part> part;
287+
Gizmo2(List<Part> part) {
288+
this.part = part;
290289
}
290+
}
291291

292292
private static class Gizmo2PartTypeAdapterFactory implements TypeAdapterFactory {
293293
@Override public <T> TypeAdapter<T> create(Gson gson, final TypeToken<T> type) {

0 commit comments

Comments
 (0)