{"id":20710889,"url":"https://github.com/entur/mapstruct-spi-protobuf","last_synced_at":"2025-04-05T20:07:54.181Z","repository":{"id":37020452,"uuid":"160202422","full_name":"entur/mapstruct-spi-protobuf","owner":"entur","description":"Protobuf accessor naming strategy for Mapstruct","archived":false,"fork":false,"pushed_at":"2024-10-23T19:52:15.000Z","size":456,"stargazers_count":70,"open_issues_count":18,"forks_count":19,"subscribers_count":18,"default_branch":"develop","last_synced_at":"2024-10-24T00:01:13.684Z","etag":null,"topics":["javabean","mapstruct","mapstruct-plugin","protobuf","protobuf3"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"eupl-1.2","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/entur.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"support-core/pom.xml","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-03T14:18:44.000Z","updated_at":"2024-10-23T19:52:19.000Z","dependencies_parsed_at":"2024-03-18T14:28:29.885Z","dependency_job_id":"dc753290-f187-40e8-b4b8-a56fb408c7e9","html_url":"https://github.com/entur/mapstruct-spi-protobuf","commit_stats":null,"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/entur%2Fmapstruct-spi-protobuf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/entur%2Fmapstruct-spi-protobuf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/entur%2Fmapstruct-spi-protobuf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/entur%2Fmapstruct-spi-protobuf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/entur","download_url":"https://codeload.github.com/entur/mapstruct-spi-protobuf/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247393570,"owners_count":20931812,"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":["javabean","mapstruct","mapstruct-plugin","protobuf","protobuf3"],"created_at":"2024-11-17T02:13:27.717Z","updated_at":"2025-04-05T20:07:54.161Z","avatar_url":"https://github.com/entur.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mapstruct SPI implementation for protocol buffers [![CircleCI](https://circleci.com/gh/entur/mapstruct-spi-protobuf.svg?style=svg)](https://circleci.com/gh/entur/mapstruct-spi-protobuf)\n\nThis naming strategy helps [mapstruct](http://mapstruct.org/) generate working mapping code between your domain classes\nand protobuf classes. Both [fullblown Java protobuf](https://github.com/protocolbuffers/protobuf/tree/master/java)\nand [protolite](https://github.com/protocolbuffers/protobuf/blob/master/java/lite.md) classes suported.\n\nRequires on mapstruct 1.4.0+.\n\n## ProtobufAccessorNamingStrategy\n\nExtends ```DefaultProtobufAccessorNamingStrategy``` and provides necessary information to map all fields automatically *\nexcept*\n\n* oneof\n\nwhich require manual mapping.\n\n## ProtobufEnumMappingStrategy\n\nImplements ```EnumMappingStrategy``` and provides complete enum constant mappings if you follow Googles style guide for\nenums https://developers.google.com/protocol-buffers/docs/style#enums\n\nIf needed you can specify a different postfix for the 0 value enum by passing in `mapstructSpi.enumPostfixOverrides` as\na compilerArg in the format of:\n\n`-AmapstructSpi.enumPostfixOverrides=com.package.root.a=POSTFIX_1,com.package.root.b=POSTFIX_2`\n\nOtherwise, this will default to `UNSPECIFIED` as per the Google style guide.\n\n```xml\n\n\u003cplugin\u003e\n    \u003cartifactId\u003emaven-compiler-plugin\u003c/artifactId\u003e\n    \u003cconfiguration\u003e\n        \u003cannotationProcessorPaths\u003e\n            \u003cpath\u003e\n                \u003cgroupId\u003eno.entur.mapstruct.spi\u003c/groupId\u003e\n                \u003cartifactId\u003eprotobuf-spi-impl\u003c/artifactId\u003e\n                \u003cversion\u003eLATEST.VERSION\u003c/version\u003e\n            \u003c/path\u003e\n        \u003c/annotationProcessorPaths\u003e\n        \u003ccompilerArgs\u003e\n            \u003carg\u003e-AmapstructSpi.enumPostfixOverrides=com.company.name=INVALID\u003c/arg\u003e\n        \u003c/compilerArgs\u003e\n    \u003c/configuration\u003e\n\u003c/plugin\u003e\n\n```\n\n## Support - Mapping functions:\n\nStandard mapping functions between often used proto types and java types:\n\n* Timestamp \u003c-\u003e Instant\n* Duration \u003c-\u003e Duration\n* Date \u003c-\u003e LocalDate\n* TimeOfDay \u003c-\u003e LocalTime\n* byte[] \u003c-\u003e ByteString\n\nSee [protobuf-support-standard](support-standard) and/or [protobuf-support-lite](support-lite) folders for a\nready-to-use mapstruct mapper.\n\n# Usage\n\n[See example project](usage/)\n\nNB: Make sure you add `collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED` to your mapping interfaces\nas protobuf stubs use the builder pattern.\n\n```\n@Mapper(collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED)\npublic interface ... {\n```\n\n## Maven\n\nNB: Make sure you use the *same version of mapstruct* both in the annotation process and the general dependency.\n`mapstruct-spi-protobuf` generally depends on the latest released version of mapstruct.\n\nAdd the following section to you maven-compiler-plugin plugin configuration:\n\n```xml\n\n\u003cannotationProcessorPaths\u003e\n    \u003cpath\u003e\n        \u003cgroupId\u003eno.entur.mapstruct.spi\u003c/groupId\u003e\n        \u003cartifactId\u003eprotobuf-spi-impl\u003c/artifactId\u003e \u003c!-- Make sure mapstruct version here is the same as below --\u003e\n        \u003cversion\u003eLATEST.VERSION\u003c/version\u003e\n    \u003c/path\u003e\n\u003c/annotationProcessorPaths\u003e\n\u003cdependencies\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.mapstruct\u003c/groupId\u003e\n    \u003cartifactId\u003emapstruct\u003c/artifactId\u003e\n    \u003cversion\u003e${org.mapstruct.version}\u003c/version\u003e\n\u003c/dependency\u003e\n\u003c/dependencies\u003e\n\n```\n\nComplete example:\n\n```xml\n\n\u003cplugin\u003e\n    \u003cgroupId\u003eorg.apache.maven.plugins\u003c/groupId\u003e\n    \u003cartifactId\u003emaven-compiler-plugin\u003c/artifactId\u003e\n\n    \u003cconfiguration\u003e\n        \u003csource\u003e1.8\u003c/source\u003e\n        \u003ctarget\u003e1.8\u003c/target\u003e\n        \u003cannotationProcessorPaths\u003e\n            \u003cpath\u003e\n                \u003cgroupId\u003eno.entur.mapstruct.spi\u003c/groupId\u003e\n                \u003cartifactId\u003eprotobuf-spi-impl\u003c/artifactId\u003e\n                \u003cversion\u003eLATEST.VERSION\u003c/version\u003e\n            \u003c/path\u003e\n        \u003c/annotationProcessorPaths\u003e\n    \u003c/configuration\u003e\n    \u003cdependencies\u003e\n        \u003cdependency\u003e\n            \u003cgroupId\u003eorg.mapstruct\u003c/groupId\u003e\n            \u003cartifactId\u003emapstruct\u003c/artifactId\u003e\n            \u003cversion\u003e${org.mapstruct.version}\u003c/version\u003e\n        \u003c/dependency\u003e\n    \u003c/dependencies\u003e\n\n\u003c/plugin\u003e\n```\n\n## Gradle\n\nNote: See Maven setup regarding using the same version of mapstruct both in the annotation processor and the general\ndependency.\n\n```java\nimplementation\"org.mapstruct:mapstruct:${mapstructVersion}\"\n        annotationProcessor\"org.mapstruct:mapstruct-processor:${mapstructVersion}\"\n        annotationProcessor\"no.entur.mapstruct.spi:protobuf-spi-impl:LATEST.VERSION\"\n```\n\n# More information:\n\nhttp://mapstruct.org/documentation/stable/reference/html/index.html#using-spi\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fentur%2Fmapstruct-spi-protobuf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fentur%2Fmapstruct-spi-protobuf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fentur%2Fmapstruct-spi-protobuf/lists"}