{"id":37016553,"url":"https://github.com/ccheptea/auto-value-variant","last_synced_at":"2026-01-14T01:52:48.972Z","repository":{"id":57718146,"uuid":"81982738","full_name":"ccheptea/auto-value-variant","owner":"ccheptea","description":"AutoValue extension to easily determine variants for objects with known properties ","archived":false,"fork":false,"pushed_at":"2017-04-03T12:15:44.000Z","size":93,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-06-30T01:01:24.932Z","etag":null,"topics":["auto-value-extension","autovalue","filter","similar-objects","variants"],"latest_commit_sha":null,"homepage":"","language":"Java","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/ccheptea.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-14T19:48:30.000Z","updated_at":"2023-06-27T01:27:45.000Z","dependencies_parsed_at":"2022-08-24T13:38:22.145Z","dependency_job_id":null,"html_url":"https://github.com/ccheptea/auto-value-variant","commit_stats":null,"previous_names":[],"tags_count":2,"template":null,"template_full_name":null,"purl":"pkg:github/ccheptea/auto-value-variant","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccheptea%2Fauto-value-variant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccheptea%2Fauto-value-variant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccheptea%2Fauto-value-variant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccheptea%2Fauto-value-variant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ccheptea","download_url":"https://codeload.github.com/ccheptea/auto-value-variant/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccheptea%2Fauto-value-variant/sbom","scorecard":{"id":269135,"data":{"date":"2025-08-11","repo":{"name":"github.com/ccheptea/auto-value-variant","commit":"f93c761b8836b4f54c06d8907aa97900c3366c9a"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.9,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":9,"reason":"binaries present in source code","details":["Warn: binary detected: gradle/wrapper/gradle-wrapper.jar:1"],"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/26 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-17T12:54:52.661Z","repository_id":57718146,"created_at":"2025-08-17T12:54:52.661Z","updated_at":"2025-08-17T12:54:52.661Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408692,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["auto-value-extension","autovalue","filter","similar-objects","variants"],"created_at":"2026-01-14T01:52:48.244Z","updated_at":"2026-01-14T01:52:48.967Z","avatar_url":"https://github.com/ccheptea.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AutoValue: Variant Extension [![Build Status](https://travis-ci.org/ccheptea/auto-value-variant.svg?branch=master)](https://travis-ci.org/ccheptea/auto-value-variant)\n\nAn extension for Google's [AutoValue](https://github.com/google/auto/tree/master/value) \nthat generates a few handy methods to determine object variations based on statically defined variance groups.\n\n## The problem\n\nConsider the following class:\n```java\n@AutoValue abstract class Car{\n    abstract String manufacturer();\n    abstract String model();\n    abstract String plateNumber();\n    abstract int color();\n    abstract String body();\n}\n```\n\nHaving a list of cars and a reference car, lets filter all the cars that have the manufacturer and model fields \nequal to the ones defined in our reference. Most probably we'll end up with some code similar to this:\n```java\nCar ref = new AutoValue_Car(\"Tesla\", \"Model S\", \"\", 0, \"\");\nfor(Car car : cars){\n    boolean match = (ref.manufacturer() == null ? car.manufacturer() == null : ref.manufacturer().equals(car.manufacturer()))\n        \u0026\u0026 (ref.model() == null ? car.model() == null : ref.model().equals(car.model()))\n    \n    if(match){\n        filtered.add(car);\n    }\n}\n```\nThis code is hard to read and maintain and can get worse if filters get more complex.\n\n## Variant definition\n\n#### Short \nTwo objects are _variants_ if they are of the same type and are not equal except for a set of their properties.\n\n#### Long\nLets call an object **A** _variant_ of object **B** if the followings apply:\n\n* **A** and **B** are of the same type\n* **A** and **B** have a set **F** of fields that are considered constant\n* Each property from **F(A)** equals to its corresponding property in **F(B)**\n* ``A.equals(B)`` returns ``false``\n \n## Usage\n\nAutoValue Variant has two key elements:\n\n* ``Variant`` interface, containing the methods for determining variants\n* ``@NonVariant`` annotation, applied to fields that we want to consider constant\n\nImplement ``Variant``, then apply the ``@NonVariant`` annotation on fields you want to consider constant. \n```java\n@AutoValue abstract class Car implements Variant{\n    @NonVariant abstract String manufacturer();\n    @NonVariant abstract String model();\n    abstract String plateNumber();\n    abstract int color();\n    abstract String body();\n}\n```\n\nThen filtering will look like this:\n```java\nfor(Car car : cars){\n    if(ref.like(car)){\n        filtered.add(car);\n    }\n}\n// or \nfiltered = cars.stream().filter(car -\u003e ref.like(car));\n```\n\n## Multiple variant groups\nYou can define multiple variant groups by specifying the group name when applying the ``@NonVariant`` annotation\n\n```java\npublic abstract class Car implements Variant\u003cCar\u003e {\n\n    @NonVariant(VariantGroups.IDENTITY)\n    abstract String manufacturer();\n\n    @NonVariant({VariantGroups.IDENTITY, VariantGroups.MODEL_AND_BODY})\n    abstract String model();\n\n    abstract String plateNumber();\n\n    @NonVariant(VariantGroups.ASPECT)\n    abstract int color();\n\n    @NonVariant({VariantGroups.ASPECT, VariantGroups.MODEL_AND_BODY})\n    abstract String body();\n\n    static class VariantGroups {\n        static final String IDENTITY = \"identity\";\n        static final String ASPECT = \"aspect\";\n        static final String MODEL_AND_BODY = \"model_and_body\";\n    }\n}\n```\nThen apply the ``like(Object, String)`` method\n\n```java\nCar ref = new AutoValue_Car(\"Tesla\", \"Model S\", \"\", 0xFF000000, \"Sedan\");\n\nsimilarTeslaModelSCars = cars.stream().filter(car -\u003e ref.like(car, Car.VariantGroups.IDENTITY));\nblackSedans = cars.stream().filter(car -\u003e ref.like(car, Car.VariantGroups.ASPECT));\n```\n\n## Download\n\n```groovy\nannotationProcessor 'com.ccheptea.auto.value:auto-value-variant:1.2.0'\ncompile 'com.ccheptea.auto.value:auto-value-variant-runtime:1.2.0'\n ```\n\nSnapshots of the development version are available in [Sonatype's `snapshots` repository][snap].\n\n\n## Notes\n\nThe code for auto deploying artifacts with Travis as well as some of the extension code is based on or inspired by parts of:\n* [AutoValue: Redacted Extension] (https://github.com/square/auto-value-redacted)\n* [AutoValue: Parcel Extension] (https://github.com/rharter/auto-value-parcel)\n\n## License\n\n\n```\nCopyright 2017 Constantin Cheptea.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n\n[snap]: https://oss.sonatype.org/content/repositories/snapshots/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccheptea%2Fauto-value-variant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fccheptea%2Fauto-value-variant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccheptea%2Fauto-value-variant/lists"}