{"id":15494277,"url":"https://github.com/andyglow/caseclass-evolution","last_synced_at":"2025-04-22T20:23:23.111Z","repository":{"id":50218143,"uuid":"200340818","full_name":"andyglow/caseclass-evolution","owner":"andyglow","description":"Scala Case Class Extendable","archived":false,"fork":false,"pushed_at":"2021-06-14T20:14:30.000Z","size":61,"stargazers_count":9,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-29T18:36:29.290Z","etag":null,"topics":["case-class","evolution","extend","scala"],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andyglow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-03T06:29:25.000Z","updated_at":"2023-07-02T16:52:35.000Z","dependencies_parsed_at":"2022-09-24T08:41:10.685Z","dependency_job_id":null,"html_url":"https://github.com/andyglow/caseclass-evolution","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyglow%2Fcaseclass-evolution","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyglow%2Fcaseclass-evolution/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyglow%2Fcaseclass-evolution/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyglow%2Fcaseclass-evolution/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andyglow","download_url":"https://codeload.github.com/andyglow/caseclass-evolution/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250316597,"owners_count":21410572,"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":["case-class","evolution","extend","scala"],"created_at":"2024-10-02T08:13:02.116Z","updated_at":"2025-04-22T20:23:23.093Z","avatar_url":"https://github.com/andyglow.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"Scala Case Class Evolution\n--------------------------\n\n[![Build Status](https://cloud.drone.io/api/badges/andyglow/caseclass-evolution/status.svg)](https://cloud.drone.io/andyglow/caseclass-evolution)\n[![codecov](https://codecov.io/gh/andyglow/caseclass-evolution/branch/master/graph/badge.svg)](https://codecov.io/gh/andyglow/caseclass-evolution)\n\nEXPERIMENTAL\n============\n\nWith Scala developer can't extends case classes. \n\nThat's an axiom.\n\nBut sometimes, especially if you, like me, work with big data, you really want scala could do that.\nOtherwise you stuck with doing boilerplate like this.\n\n```scala\ncase class User(\n  id: String,\n  firstName: String,\n  middleName: Option[String],\n  lastName: String,\n  ... // ton of properties \n)\n\ncase class BankUser(\n  id: String,\n  firstName: String,\n  middleName: Option[String],\n  lastName: String,\n  ... // ton of properties\n\n  bank: String,\n  bankAccount: String,\n  bankSwift: String,\n  bankAccountCreatedAt: LocalDate\n)\n```\n\nWith the library I wanted to introduce this boilerplate gets reduced.\n\n```scala\n@evolve(User)\ncase class BankUser(\n  bank: String,\n  bankAccount: String,\n  bankSwift: String,\n  bankAccountCreatedAt: LocalDate)\n``` \n\nSounds good so far?\n\nThe resulted class definition will be the same as an example from previous snippet.\nWith even one helper method added `withUser`, which takes a `User` and applies it to `BankUser`.\n\nThere also 2 extra features.\n- we can reduce case class definition by removing unnecessary fields\n- we can rename fields\n\n```scala\n@evolve(from = User, removed = Set(\"middleName\"), renamed = Map(\"id\" -\u003e \"userId\"))\ncase class UserV2()\n``` \n\nEven though it may look cool, there is a huge obstacle. \n*IDE support is absent*. Code in IDE will be all highlighted and look ugly.\n\n### Apache Spark\n\nIt can be used with Apache Spark to define schemas. `Dataset` API.\n\nAlso with a little trick it might be used with `Frameless`. \nIn order to use it with `Frameless` one need to build model separately from code using it.\nConsider separate module or separate library. \n\n\nTODO\n----\n- same name, but type changed scenario","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyglow%2Fcaseclass-evolution","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandyglow%2Fcaseclass-evolution","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyglow%2Fcaseclass-evolution/lists"}