Skip to content

Commit

Permalink
Merge pull request google#288 from google/jt/jvm-static
Browse files Browse the repository at this point in the history
Remove @JvmStatic annotations in internal classes (not needed for Java interop)
  • Loading branch information
jingtang10 committed Mar 8, 2021
2 parents ee36deb + acaad36 commit e42e9e9
Showing 1 changed file with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ object LocalChangeUtils {
/**
* Squash the changes by merging them two at a time.
*/
@JvmStatic
fun squash(localChangeEntities: List<LocalChangeEntity>): LocalChangeEntity =
localChangeEntities.reduce { first, second -> mergeLocalChanges(first, second) }
localChangeEntities.reduce { first, second -> mergeLocalChanges(first, second) }

@JvmStatic
fun mergeLocalChanges(first: LocalChangeEntity, second: LocalChangeEntity): LocalChangeEntity {
val type: LocalChangeEntity.Type
val payload: String
Expand Down Expand Up @@ -75,21 +73,15 @@ object LocalChangeUtils {
)
}

/**
* Update a JSON object with a JSON patch (RFC 6902).
*/
@JvmStatic
/** Update a JSON object with a JSON patch (RFC 6902). */
private fun applyPatch(resourceString: String, patchString: String): String {
val objectMapper = ObjectMapper()
val resourceJson = objectMapper.readValue(resourceString, JsonNode::class.java)
val patchJson = objectMapper.readValue(patchString, JsonPatch::class.java)
return patchJson.apply(resourceJson).toString()
}

/**
* Merge two JSON patch strings by concatenating their elements into a new JSON array.
*/
@JvmStatic
/** Merge two JSON patch strings by concatenating their elements into a new JSON array. */
private fun mergePatches(firstPatch: String, secondPatch: String): String {
// TODO: validate patches are RFC 6902 compliant JSON patches
val firstMap = JSONArray(firstPatch).patchMergeMap()
Expand All @@ -98,10 +90,7 @@ object LocalChangeUtils {
return JSONArray(firstMap.values).toString()
}

/**
* Calculates the JSON patch between two [Resource]s.
*/
@JvmStatic
/** Calculates the JSON patch between two [Resource]s. */
internal fun diff(parser: IParser, source: Resource, target: Resource): String {
val objectMapper = ObjectMapper()
val jsonDiff = JsonDiff.asJson(
Expand All @@ -116,8 +105,8 @@ object LocalChangeUtils {
)
if (jsonDiff.size() == 0) {
Log.i(
"ResourceDao",
"Target ${target.resourceType}/${target.id} is same as source."
"ResourceDao",
"Target ${target.resourceType}/${target.id} is same as source."
)
}
return jsonDiff.toString()
Expand Down

0 comments on commit e42e9e9

Please sign in to comment.