{"id":25337493,"url":"https://github.com/petitviolet/scala-generic-diff","last_synced_at":"2025-04-08T09:20:48.126Z","repository":{"id":57737579,"uuid":"160697032","full_name":"petitviolet/scala-generic-diff","owner":"petitviolet","description":"extract objects' diff generically","archived":false,"fork":false,"pushed_at":"2020-01-04T14:22:01.000Z","size":36,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-07-05T12:09:19.217Z","etag":null,"topics":["generic-programming","metaprogramming","scala","shapeless"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/petitviolet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-06T15:50:35.000Z","updated_at":"2020-01-04T14:22:03.000Z","dependencies_parsed_at":"2022-08-24T12:51:05.307Z","dependency_job_id":null,"html_url":"https://github.com/petitviolet/scala-generic-diff","commit_stats":null,"previous_names":[],"tags_count":5,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petitviolet%2Fscala-generic-diff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petitviolet%2Fscala-generic-diff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petitviolet%2Fscala-generic-diff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petitviolet%2Fscala-generic-diff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/petitviolet","download_url":"https://codeload.github.com/petitviolet/scala-generic-diff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238797654,"owners_count":19532215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["generic-programming","metaprogramming","scala","shapeless"],"created_at":"2025-02-14T06:35:52.591Z","updated_at":"2025-02-14T06:35:53.132Z","avatar_url":"https://github.com/petitviolet.png","language":"Scala","readme":"# Extract diff between objects\n\n[![MavenCentral](https://maven-badges.herokuapp.com/maven-central/net.petitviolet/generic-diff_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/net.petitviolet/generic-diff_2.12)\n [![CircleCI](https://circleci.com/gh/petitviolet/scala-generic-diff.svg?style=svg)](https://circleci.com/gh/petitviolet/scala-generic-diff)\n [![Coverage Status](https://coveralls.io/repos/github/petitviolet/scala-generic-diff/badge.svg?branch=master)](https://coveralls.io/github/petitviolet/scala-generic-diff?branch=master)\n\nA Scala library to extract differences between two objects.\nThis makes easy finding out what changes are applied on the old object.\n\nQuick example:\n\n```scala\n// Using Ammonite-REPL\n@ import $ivy.`net.petitviolet::generic-diff:\u003cVERSION\u003e`\n@ import net.petitviolet.generic.diff._\n...\n\n@ case class User(id: Long, name: String)\ndefined class User\n\n@ User(1L, \"alice\") diff User(1L, \"bob\")\nres2: DiffResult[User] = DiffResult(List(FieldSame(\"id\", 1L), FieldDiff(\"name\", \"alice\", \"bob\")))\n```\n\n## Getting Started\n\n```scala\nlibraryDependencies += \"net.petitviolet\" %% \"generic-diff\" % \"\u003cversion\u003e\"\n```\n\n## Example\n\n```scala\nimport net.petitviolet.generic.diff._\n\ncase class User(id: Long, name: String, age: Int)\n\ncase class GroupName(value: String)\ncase class Group(id: Long, name: GroupName)\n\ndef main(args: Array[String]): Unit = {\n  // extract difference between 2 objects\n  val userDiff = User(1L, \"alice\", 20) diff User(2L, \"alice\", 35)\n\n  // result contains sequence of FieldDiff and FieldSame\n  assert(userDiff.fields == List(FieldDiff(\"id\", 1, 2), FieldSame(\"name\", \"alice\"), FieldDiff(\"age\", 20, 35)))\n\n  // dynamic field access\n  assert(userDiff.name == FieldSame(\"name\", \"alice\"))\n  assert(userDiff.age == FieldDiff(\"age\", 20, 35))\n  // userDiff.foo // compile error!\n\n  // extract diff from nested objects\n  val groupDiff = Group(1, GroupName(\"tech\")) diff Group(2L, GroupName(\"hoge\"))\n  assert(\n    groupDiff.fields == List(\n      FieldDiff(\"id\", 1, 2),\n      FieldDiff(\"name\", GroupName(\"tech\"), GroupName(\"hoge\"))\n    )\n  )\n}\n```\n\n## Publish\n\n```console\nsbt 'project genericDiffMacro' +publishSigned sonatypeReleaseAll \\\n    'project genericDiff' +publishSigned sonatypeReleaseAll\n```\n\n## LICENSE\n\n[Apache-2.0](https://github.com/petitviolet/scala-generic-diff/blob/master/LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetitviolet%2Fscala-generic-diff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpetitviolet%2Fscala-generic-diff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetitviolet%2Fscala-generic-diff/lists"}