@ Override public CMASnapshot deserialize ( JsonElement json , Type typeOfT , JsonDeserializationContext context ) throws JsonParseException { final CMASnapshot result = new CMASnapshot ( ) ; final JsonObject jsonObject = json . getAsJsonObject ( ) ; final CMASystem system = context . deserialize ( jsonObject . get ( "sys" ) , CMASystem . class ) ; result . setSystem ( system ) ; final JsonObject snapshot = jsonObject . getAsJsonObject ( "snapshot" ) ; final String type = snapshot . getAsJsonObject ( "sys" ) . getAsJsonPrimitive ( "type" ) . getAsString ( ) ; if ( CMAType . ContentType . name ( ) . equals ( type ) ) { result . setSnapshot ( context . deserialize ( snapshot , CMAContentType . class ) ) ; } else if ( CMAType . Entry . name ( ) . equals ( type ) ) { result . setSnapshot ( context . deserialize ( snapshot , CMAEntry . class ) ) ; } return result ; }
Inspect json payload and generate either a content type snapshot from it or an entry snap shot .