{"id":16101608,"url":"https://github.com/bjansen/proxy-config","last_synced_at":"2025-04-06T00:28:05.652Z","repository":{"id":3403522,"uuid":"4453456","full_name":"bjansen/proxy-config","owner":"bjansen","description":"Type-safe configurations based on interfaces","archived":false,"fork":false,"pushed_at":"2012-06-28T19:03:04.000Z","size":190,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-12T06:38:58.706Z","etag":null,"topics":["configuration","java","library"],"latest_commit_sha":null,"homepage":null,"language":"Java","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/bjansen.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":"2012-05-26T07:46:49.000Z","updated_at":"2020-10-27T10:28:17.000Z","dependencies_parsed_at":"2022-09-05T16:30:44.743Z","dependency_job_id":null,"html_url":"https://github.com/bjansen/proxy-config","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjansen%2Fproxy-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjansen%2Fproxy-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjansen%2Fproxy-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjansen%2Fproxy-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bjansen","download_url":"https://codeload.github.com/bjansen/proxy-config/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419638,"owners_count":20936009,"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":["configuration","java","library"],"created_at":"2024-10-09T18:50:27.162Z","updated_at":"2025-04-06T00:28:05.595Z","avatar_url":"https://github.com/bjansen.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"proxy-config\n============\n\nType-safe configurations based on interfaces\n\nWhy is it so awesome for my app?\n--------------------------------\nBecause you won't have to mess with string-only-and-not-type-safe-Properties! You only need to to represent \nyour configuration as a plain old Java interface, and proxy-config will automatically bind it with virtually any\nconfiguration source (properties files included ;-)).\n\nFirst define your interface as you would like to use it in your code:\n\n```java\npublic interface ApplicationConfig {\n\n  // Standard access\n  public String getApplicationName();\n\n  // Non-String return type\n  public int getApplicationVersion();\n\n  // User-defined key name\n  @ConfigurationKey(\"developer.names\")\n  @Separator(regexp = \"\\\\s*,\\\\s*\") // This is the default value, you don't have to use @Separator int this case\n  public List\u003cString\u003e getDevelopers();\n\n  // Default value if no matching key is found in the source\n  @Default(\"1,2,3\")\n  public Integer[] getPreviousVersions();\n}\n```\n\nThen write the according properties file (proxy-config will try to deduce the configuration keys from the method name,\nminus the \"get\" prefix):\n\n```properties\napplication.name=My superb app\napplication.version=4\ndeveloper.names=Foo, Bar, Baz\n\n# Note that previous.versions is missing\n```\n\nAll right, you are ready to start using proxy-config in your project!\n\n```java\nConfigurationFactory.setMethodNameTransformers(DefaultMethodNameTransformers.CAMEL_CASE_TO_DOTS);\nConfigurationFactory.setConfigurationSource(new PropertiesConfigurationSource(\"app-config.properties\"));\nConfigurationFactory.setTypeCasters(PrimitiveTypesCaster.values());\n\nApplicationConfig config = ConfigurationFactory.getConfiguration(AnnotatedApplicationConfig.class);\n\n// Yay!\nSystem.out.println(String.format(\"Running app %s\", config.getApplicationName()));\n```\n\nHow can I start using it?\n-------------------------\nThe single entry point is the ConfigurationFactory. You have to configure it using the static methods \nsetMethodNameTransformers, setConfigurationSource and setTypeCasters to fit your needs.\n\nThen you only have to pass your interface's class to getConfiguration() and you are ready to rock!\n\nproxy-config ships a default set of transformers, sources and casters:\n\n* DefaultMethodNameTransformers (NO_TRANSFORM, LOWER_CASE, CAMEL_CASE_TO_DOTS, CAMEL_CASE_TO_UNDERSCORES, UNCAP_FIRST)\n* PrimitiveTypesCaster to cast String to primitive types or their wrapper counterpart\n* MessageFormatTypeCaster to format a String using MessageFormatter and the parameters passed to the interface's method\n* ListTypeCaster and ArrayTypeCaster for lists and arrays of supported types\n* EnumTypeCaster to cast a String to an enum's value\n* ResourceBundleConfigurationSource and PropertiesConfigurationSource to load your config from a properties file\n\nYou can also create your own subclasses of ConfigurationSource, MethodNameTransformer and TypeCaster if this is not enough!\n\nComparison with other tools\n---------------------------\nA spreadsheet comparing features provided by proxy-config and similar tools is available [here](https://docs.google.com/a/excilys.com/spreadsheet/ccc?key=0AndG-zBLycfndEI4UmJTdkZOZEV3bEUwdUxRZi1raFE#gid=0)\n\nTestimonial\n-----------\n\nYourKit is kindly supporting open source projects with its full-featured Java Profiler.\nYourKit, LLC is the creator of innovative and intelligent tools for profiling\nJava and .NET applications. Take a look at YourKit's leading software products:\n[YourKit Java Profiler](http://www.yourkit.com/java/profiler/index.jsp) and [YourKit .NET Profiler](http://www.yourkit.com/.net/profiler/index.jsp).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjansen%2Fproxy-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbjansen%2Fproxy-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjansen%2Fproxy-config/lists"}