MCPcopy Index your code
hub / github.com/google/gson / accept

Method accept

src/main/java/com/google/gson/ObjectNavigator.java:97–126  ·  view source on GitHub ↗

Navigate all the fields of the specified object. If a field is null, it does not get visited. @param objTypePair The object,type (fully genericized) being navigated

(ObjectTypePair objTypePair, Visitor visitor)

Source from the content-addressed store, hash-verified

95 * @param objTypePair The object,type (fully genericized) being navigated
96 */
97 public void accept(ObjectTypePair objTypePair, Visitor visitor) {
98 if (exclusionStrategy.shouldSkipClass($Gson$Types.getRawType(objTypePair.type))) {
99 return;
100 }
101 boolean visitedWithCustomHandler = visitor.visitUsingCustomHandler(objTypePair);
102 if (!visitedWithCustomHandler) {
103 Object obj = objTypePair.getObject();
104 Object objectToVisit = (obj == null) ? visitor.getTarget() : obj;
105 if (objectToVisit == null) {
106 return;
107 }
108 objTypePair.setObject(objectToVisit);
109 visitor.start(objTypePair);
110 try {
111 if ($Gson$Types.isArray(objTypePair.type)) {
112 visitor.visitArray(objectToVisit, objTypePair.type);
113 } else if (objTypePair.type == Object.class && isPrimitiveOrString(objectToVisit)) {
114 // TODO(Joel): this is only used for deserialization of "primitives"
115 // we should rethink this!!!
116 visitor.visitPrimitive(objectToVisit);
117 visitor.getTarget();
118 } else {
119 visitor.startVisitingObject(objectToVisit);
120 reflectingFieldNavigator.visitFieldsReflectively(objTypePair, visitor);
121 }
122 } finally {
123 visitor.end(objTypePair);
124 }
125 }
126 }
127
128 private static boolean isPrimitiveOrString(Object objectToVisit) {
129 Class<?> realClazz = objectToVisit.getClass();

Callers 6

fromJsonArrayMethod · 0.80
fromJsonObjectMethod · 0.80
fromJsonPrimitiveMethod · 0.80
visitChildMethod · 0.80
serializeMethod · 0.80

Calls 14

isPrimitiveOrStringMethod · 0.95
getObjectMethod · 0.80
setObjectMethod · 0.80
isArrayMethod · 0.80
shouldSkipClassMethod · 0.65
getTargetMethod · 0.65
startMethod · 0.65
visitArrayMethod · 0.65
visitPrimitiveMethod · 0.65
startVisitingObjectMethod · 0.65

Tested by

no test coverage detected