{"id":21034612,"url":"https://github.com/marthym/entity","last_synced_at":"2026-06-16T07:31:35.491Z","repository":{"id":218348819,"uuid":"746192357","full_name":"Marthym/entity","owner":"Marthym","description":"Entity is a small library that handles the notion of model entity.","archived":false,"fork":false,"pushed_at":"2026-01-27T21:48:08.000Z","size":206,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2026-01-28T09:26:23.649Z","etag":null,"topics":["java","java-17","library"],"latest_commit_sha":null,"homepage":"https://marthym.github.io/entity/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Marthym.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-01-21T10:53:36.000Z","updated_at":"2026-01-27T21:48:12.000Z","dependencies_parsed_at":"2024-01-21T12:26:20.688Z","dependency_job_id":"7973a8b9-27ed-47b7-aae0-289de570a017","html_url":"https://github.com/Marthym/entity","commit_stats":null,"previous_names":["marthym/entity"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/Marthym/entity","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marthym%2Fentity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marthym%2Fentity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marthym%2Fentity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marthym%2Fentity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Marthym","download_url":"https://codeload.github.com/Marthym/entity/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marthym%2Fentity/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34394384,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["java","java-17","library"],"created_at":"2024-11-19T13:07:44.383Z","updated_at":"2026-06-16T07:31:35.485Z","avatar_url":"https://github.com/Marthym.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Entity [![](https://img./github/release/Marthym/entity.svg)](https://GitHub.com/Marthym/entity/releases/) [![GitHub license](https://img.shields.io/github/license/Marthym/entity.svg)](https://github.com/Marthym/entity/blob/master/LICENSE)\n\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Marthym_entity\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=Marthym_entity)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=Marthym_entity\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=Marthym_entity)\n[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=Marthym_entity\u0026metric=sqale_rating)](https://sonarcloud.io/dashboard?id=Marthym_entity)\n\n\u003cimg src=\"favicon.png\" alt=\"Size Limit CLI\" align=\"right\" style=\"float: right; margin: auto; width: 100px\"\u003e\n\n**Entity** is a small library that handles the notion of model entity. **Entity** offers an elegant way of working with\nbusiness objects that may or may not have an identifier.\n\nThe entity can hold, or not, some metadata.\nFor example ID of the user who creates the entity, the date of creation, the last update, ...\nThis metadata was embedded through an EnumMap, the most efficient structure to store unknown number of key/value pairs.\n\nThe jackson package offers a module for serializing and deserializing these entities in a flat manner.\n\n## Features\n\n- 🪪 Identifiable entity\n- 🏷️ Metadata embedded in the entity\n- 🎷 Jackson 2 \u0026 3 module\n- 🫟 GraphQL module\n\n## Installation\n\nUse the package manager [maven](https://maven.apache.org/) to install entity.\n\n```xml\n\n\u003cdependency\u003e\n    \u003cgroupId\u003efr.ght1pc9kc\u003c/groupId\u003e\n    \u003cartifactId\u003eentity-api\u003c/artifactId\u003e\n    \u003cversion\u003eVERSION\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003efr.ght1pc9kc\u003c/groupId\u003e\n    \u003cartifactId\u003eentity-jackson\u003c/artifactId\u003e\n    \u003cversion\u003eVERSION\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e \u003c!-- Jackson \u0026 Jackson 3 modules are exclusive --\u003e\n    \u003cgroupId\u003efr.ght1pc9kc\u003c/groupId\u003e\n    \u003cartifactId\u003eentity-jackson-3\u003c/artifactId\u003e\n    \u003cversion\u003eVERSION\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003efr.ght1pc9kc\u003c/groupId\u003e\n    \u003cartifactId\u003eentity-graphql\u003c/artifactId\u003e\n    \u003cversion\u003eVERSION\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nfor gradle\n\n```groovy\ncompile \"fr.ght1pc9kc:entity-api:VERSION\"\ncompile \"fr.ght1pc9kc:entity-jackson:VERSION\"\ncompile \"fr.ght1pc9kc:entity-jackson-3:VERSION\"\ncompile \"fr.ght1pc9kc:entity-graphql:VERSION\"\n```\n\n## Usage\n\n### Create an entity\n\n```java\nimport fr.ght1pc9kc.entity.api.Entity;\n\nimport java.time.Instant;\n\nimport static fr.ght1pc9kc.demo.DefaultMeta.createdBy;\nimport static fr.ght1pc9kc.demo.DefaultMeta.createdAt;\n\nEntity\u003cString\u003e basic = Entity.identify(\"May the force\")\n        .withId(\"4TH\");\n\nEntity\u003cString\u003e simple = Entity.identify(\"May the force\")\n        .meta(createdBy, \"Yoda\")\n        .meta(createdAt, Instant.now())\n        .withId(\"4TH\");\n\nEntity\u003cString\u003e verySimple = Entity.identify(\"May the force\").withId(\"4TH\");\n\nEntity\u003cSaber\u003e POLYMORPHIC_ENTITY = Entity\n        .\u003cSaber\u003eidentify(new LightSaber(Color.GREEN, 1))\n        .meta(createdAt, Instant.parse(\"2024-01-20T15:06:42.546Z\"))\n        .meta(createdBy, \"okenobi\")\n        .withId(\"LIGHTSABER\");\n```\n\n### Include Jackson 2 module\n\n```java\nimport com.fasterxml.jackson.databind.ObjectMapper;\nimport com.fasterxml.jackson.databind.SerializationFeature;\nimport com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;\nimport fr.ght1pc9kc.entity.jackson.EntityModule;\n\nObjectMapper mapper = new ObjectMapper()\n        .registerModule(new JavaTimeModule())\n        .registerModule(new EntityModule())\n        .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);\n```\n\nUsing `JavaTimeModule` is mandatory to allow serialize `Instant`, `WRITE_DATES_AS_TIMESTAMPS` is optional but provide\nmore beautiful json.\n\n```json\n{\n  \"_id\": \"LIGHTSABER\",\n  \"_createdAt\": \"2024-01-20T15:06:42.546Z\",\n  \"_createdBy\": \"okenobi\",\n  \"@type\": \"LIGHT\",\n  \"blade\": 1,\n  \"color\": \"GREEN\"\n}\n```\n\n### Include Jackson 3 module\n\n```java\nimport tools.jackson.databind.ObjectMapper;\nimport tools.jackson.databind.cfg.DateTimeFeature;\nimport tools.jackson.databind.json.JsonMapper;\nimport fr.ght1pc9kc.entity.jackson.EntityModule;\n\nObjectMapper mapper = JsonMapper.builder()\n        .disable(DateTimeFeature.WRITE_DATES_AS_TIMESTAMPS)\n        .addModule(new EntityModule())\n        .build();\n```\n\nSince jackson 3, `JavaTimeModule` is built-in and does not need to be registered.\n\n```json\n{\n  \"_id\": \"LIGHTSABER\",\n  \"_createdAt\": \"2024-01-20T15:06:42.546Z\",\n  \"_createdBy\": \"okenobi\",\n  \"@type\": \"LIGHT\",\n  \"blade\": 1,\n  \"color\": \"GREEN\"\n}\n```\n\n### Use GraphQL DataFetcher module\n\nIn Spring Boot, create a configuration class into your module\n\n```java\n\n@Slf4j\n@Configuration\npublic class MyObjectEntityConfiguration {\n    @Bean\n    public RuntimeWiringConfigurer customRuntimeWiringConfigurer() {\n        // Create the DataFetcher with the default EntityDataFetcher using simple reflection\n        DataFetcher\u003cObject\u003e dataFetcher = EntityDataFetcher.builder().build();\n        // Create a TypeResolver which detect Entity object\n        TypeResolver typeResolver = new EntityTypeResolver();\n\n        // customize WiringConfigurer to map possible Entity self object to use EntityDataFetcher\n        return wiringBuilder -\u003e wiringBuilder\n                .type(MyObject.class.getSimpleName(), builder -\u003e builder.defaultDataFetcher(dataFetcher).typeResolver(typeResolver));\n    }\n}\n```\n\n```java\n\n@Slf4j\n@Configuration\npublic class MyObjectEntityConfiguration {\n    @Bean\n    public RuntimeWiringConfigurer customRuntimeWiringConfigurer(ObjectMapper mapper) {\n        // Create the DataFetcher with Jackson ObjectMapper\n        DataFetcher\u003cObject\u003e dataFetcher = EntityDataFetcher.builder()\n                .mapper(mapper) // Jackaon 2 or 3 depending on the dependency you choose\n                .build();\n        // Create a TypeResolver which detect Entity object\n        TypeResolver typeResolver = new EntityTypeResolver();\n\n        // customize WiringConfigurer to map possible Entity self object to use EntityDataFetcher\n        return wiringBuilder -\u003e wiringBuilder\n                .type(MyObject.class.getSimpleName(), builder -\u003e builder.defaultDataFetcher(dataFetcher).typeResolver(typeResolver));\n    }\n}\n```\n\nYou can use your own EntityMapper to customize the way the entity is serialized to graphql.\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarthym%2Fentity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarthym%2Fentity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarthym%2Fentity/lists"}