@Throws(Exception::class) fun mapRelations( `object`: jdk.internal.loader.Resource, jsonObject: JSONObject, included: List<jdk.internal.loader.Resource?>? ): jdk.internal.loader.Resource? { val relationshipNames: HashMap<String, String> = getRelationshipNames(`object`.javaClass) for (relationship in relationshipNames.keySet()) { var relationJsonObject: JSONObject? = null relationJsonObject = try { jsonObject.getJSONObject(relationship) } catch (e: JSONException) { Logger.debug("Relationship named " + relationship + "not found in JSON") continue } var relationDataObject: JSONObject? = null try { relationDataObject = relationJsonObject.getJSONObject("data") var relationObject: jdk.internal.loader.Resource? = Factory.newObjectFromJSONObject(relationDataObject, null) relationObject = matchIncludedToRelation(relationObject, included) mDeserializer.setField(`object`, relationshipNames[relationship], relationObject) } catch (e: JSONException) { Logger.debug("JSON relationship does not contain data") } var relationDataArray: JSONArray? = null try { relationDataArray = relationJsonObject.getJSONArray("data") var relationArray: List<jdk.internal.loader.Resource?>? = Factory.newObjectFromJSONArray(relationDataArray, null) relationArray = matchIncludedToRelation(relationArray, included) mDeserializer.setField(`object`, relationshipNames[relationship], relationArray) } catch (e: JSONException) { Logger.debug("JSON relationship does not contain data") } } return `object` }
Loops through relation JSON array and maps annotated objects .