{"id":34243518,"url":"https://github.com/state-machine-systems/envy","last_synced_at":"2025-12-16T05:02:36.903Z","repository":{"id":20655882,"uuid":"23938072","full_name":"state-machine-systems/envy","owner":"state-machine-systems","description":"Super simple configuration for Java.","archived":false,"fork":false,"pushed_at":"2018-07-06T09:13:10.000Z","size":194,"stargazers_count":8,"open_issues_count":12,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-16T03:39:00.183Z","etag":null,"topics":["configuration","java","simple"],"latest_commit_sha":null,"homepage":null,"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/state-machine-systems.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":null}},"created_at":"2014-09-11T22:27:12.000Z","updated_at":"2020-03-02T22:39:15.000Z","dependencies_parsed_at":"2022-08-21T19:01:04.577Z","dependency_job_id":null,"html_url":"https://github.com/state-machine-systems/envy","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/state-machine-systems/envy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/state-machine-systems%2Fenvy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/state-machine-systems%2Fenvy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/state-machine-systems%2Fenvy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/state-machine-systems%2Fenvy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/state-machine-systems","download_url":"https://codeload.github.com/state-machine-systems/envy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/state-machine-systems%2Fenvy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27759611,"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","status":"online","status_checked_at":"2025-12-16T02:00:10.477Z","response_time":57,"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":["configuration","java","simple"],"created_at":"2025-12-16T05:02:36.148Z","updated_at":"2025-12-16T05:02:36.891Z","avatar_url":"https://github.com/state-machine-systems.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Envy\n\n## Super simple configuration for Java.\n\nEnvy provides easy, uniform access to environment variables and system properties,\nwhich helps you build [twelve-factor apps](http://www.12factor.net/config).\n\nSay you need to access the environment variables `API_KEY` and `API_SECRET` in your program.\nFirst, you define an interface with getter methods named after the parameters you want to bring in:\n\n```java\ninterface MyConfig {\n    String getApiKey();\n    String getApiSecret();\n}\n```\n\nEnvy can then instantiate your configuration interface like this:\n\n```java\nimport com.statemachinesystems.envy.Envy;\n...\nMyConfig config = Envy.configure(MyConfig.class);\n```\n\nNow, calling `config.getApiKey()` will return the value of the `API_KEY` environment variable, and\n`config.getApiSecret()` will return the value of `API_SECRET`.\n\nThis also works for JVM system properties, using a lower-case dotted naming convention,\nwhich would be `api.key` and `api.secret` in the above example. When an environment variable and a\nsystem property are both defined with equivalent names, the system property takes precedence.\n\nAlso, you don't have to use bean-style method names - the following version would work in exactly the same way:\n\n```java\n  interface MyConfig {\n      String apiKey();\n      String apiSecret();\n  }\n```\n\n### Getting started\n\nEnvy's in the Maven Central repo, so just add the\n[latest version](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.statemachinesystems%22%20AND%20a%3A%22envy%22)\nas a dependency in your Maven/SBT/Gradle/whatever build.\n\n### Default values\n\nEnvy treats all parameters as mandatory, but you can provide a default value using the `@Default` annotation:\n\n```java\nimport com.statemachinesystems.envy.Default;\n\ninterface ServerConfig {\n    @Default(\"80\")\n    int getHttpPort();\n}\n```\n\n### Optional values\n\nSometimes a parameter type has no meaningful default value, or you need to test for its absence.\nEnvy supports Java 8's `Optional`, Scala's `Option` and Guava's `Optional` types.\n\n```java\ninterface FooConfig {\n    Optional\u003cURL\u003e getUrl();\n}\n```\n\nYou can force Envy to allow null values using the `@Nullable` annotation:\n\n```java\nimport com.statemachinesystems.envy.Nullable;\n\ninterface FooConfig {\n    @Nullable\n    URL nullableUrl();\n}\n```\n\n### Sensitive values\n\nBy default, Envy provides a `toString()` method that includes all configured values.\nTo mask out sensitive values such as passwords, use the `@Sensitive` annotation:\n\n```java\nimport com.statemachinesystems.envy.Sensitive;\n\ninterface Credentials {\n    String username();\n    @Sensitive String password();\n}\n```\n\n### Custom naming\n\nLong and/or awkward names can be overridden using the `@Name` annotation:\n\n```java\nimport com.statemachinesystems.envy.Name;\n\ninterface BarConfig {\n    @Name(\"com.foo.extremely.long.property.name.for.thing\")\n    String getThing();\n}\n```\n\nTo apply a prefix to all names in a configuration interface, use the `@Prefix` annotation:\n\n```java\nimport com.statemachinesystems.envy.Prefix;\n\n@Prefix(\"baz.config\")\ninterface BazConfig {\n    /**\n     * Configured by BAZ_CONFIG_HTTP_PORT\n     */\n    int getHttpPort();\n}\n```\n\n### Inheritance\n\nInterface inheritance is supported, so you can factor out common parameters in more complex configurations.\n\nAnnotations on methods (`@Name`, `@Nullable` and `@Default`) are inherited,\nbut can be overridden (or removed entirely) by redeclaring the method in a sub-interface. `@Prefix` annotations\nare *not* inherited.\n\n\n### Nesting\n\nConfiguration interfaces can be nested, which allows reuse of repeated structures. Here's an example using both\ninheritance and nesting:\n\n```java\ninterface Credentials {\n    String username();\n    @Sensitive String password();\n}\n\ninterface ConnectionConfig extends Credentials {\n    java.net.InetSocketAddress address();\n}\n\ninterface AppConfig {\n    /**\n     * Configured by DATABASE_ADDRESS, DATABASE_USERNAME and DATABASE_PASSWORD\n     */\n    ConnectionConfig database();\n\n    /**\n     * Configured by MESSAGE_BROKER_ADDRESS, MESSAGE_BROKER_USERNAME and MESSAGE_BROKER_PASSWORD\n     */\n    ConnectionConfig messageBroker();\n}\n```\n\n### Supported data types\n\nEnvy will do the following type conversions for you:\n\n* Strings (no conversion needed)\n* Numbers (`int`/`Integer`, `long`/`Long`, `byte`/`Byte`, `short`/`Short`, `float`/`Float`, `double`/`Double`, `java.math.BigDecimal`, `java.math.BigInteger`)\n* Booleans (true/false, yes/no, y/n, on/off)\n* Characters (`char`/`Character`)\n* Enums\n* Arrays, comma-separated\n* Anything with a constructor that takes a single `String` argument\n* `java.io.File`\n* `java.lang.Class`\n* `java.net.URL`, `java.net.URI`\n* `java.net.InetAddress`, `Inet4Address`, `Inet6Address`, `InetSocketAddress`\n* `java.util.regex.Pattern`\n* `java.util.UUID`\n* `java.time.Duration` e.g. \"100ms\", \"30 seconds\", \"1000\" (defaults to millis)\n* `java.time.Period` e.g. \"1d\", \"2 weeks\", \"3 months\", \"10\" (defaults to days)\n\n### Custom data types\n\nTo parse a custom type, implement the `ValueParser` interface:\n\n```java\nimport com.statemachinesystems.envy.ValueParser;\n\npublic class MyCustomTypeParser implements ValueParser\u003cMyCustomType\u003e {\n    @Override\n    public MyCustomType parseValue(String value) {\n        ...\n    }\n\n    @Override\n    public Class\u003cMyCustomType\u003e getValueClass() {\n        return MyCustomType.class;\n    }\n}\n```\n\nThen, when instantiating your configuration, pass along an instance of your parser like this:\n\n```java\nMyConfig config = Envy.configure(MyConfig.class, new MyCustomTypeParser());\n```\n\n\u0026copy; 2014-2018 State Machine Systems Ltd. [Apache Licence, Version 2.0]( http://www.apache.org/licenses/LICENSE-2.0)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstate-machine-systems%2Fenvy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstate-machine-systems%2Fenvy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstate-machine-systems%2Fenvy/lists"}