{"id":23401598,"url":"https://github.com/luiz-otavio/placeholder4j","last_synced_at":"2025-07-04T00:05:39.321Z","repository":{"id":41959186,"uuid":"442006314","full_name":"luiz-otavio/placeholder4j","owner":"luiz-otavio","description":"Easy-to-use placeholder library written in Java focused on performance.","archived":false,"fork":false,"pushed_at":"2024-05-02T23:49:06.000Z","size":142,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T19:12:56.981Z","etag":null,"topics":["gnu","gradle","java","library","placeholder"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luiz-otavio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-12-26T23:53:13.000Z","updated_at":"2024-05-02T23:48:55.000Z","dependencies_parsed_at":"2025-04-11T19:12:36.444Z","dependency_job_id":"53f270d2-a4cf-4e02-a9f8-9c1bbe73e5c1","html_url":"https://github.com/luiz-otavio/placeholder4j","commit_stats":null,"previous_names":["luiz-otavio/placeholder4j"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/luiz-otavio/placeholder4j","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luiz-otavio%2Fplaceholder4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luiz-otavio%2Fplaceholder4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luiz-otavio%2Fplaceholder4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luiz-otavio%2Fplaceholder4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luiz-otavio","download_url":"https://codeload.github.com/luiz-otavio/placeholder4j/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luiz-otavio%2Fplaceholder4j/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263421921,"owners_count":23464048,"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":["gnu","gradle","java","library","placeholder"],"created_at":"2024-12-22T11:17:18.340Z","updated_at":"2025-07-04T00:05:39.280Z","avatar_url":"https://github.com/luiz-otavio.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# \u003cp align=\"center\"\u003ePlaceholder4j\u003c/p\u003e\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/luiz-otavio/placeholder4j?style=for-the-badge\" alt=\"License\"/\u003e\n    \u003cimg src=\"https://img.shields.io/github/v/release/luiz-otavio/placeholder4j?style=for-the-badge\" alt=\"Release\"/\u003e\n    \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/luiz-otavio/placeholder4j/gradle.yml?branch=main\u0026style=for-the-badge\" alt=\"Build\"/\u003e\n    \u003cimg src=\"https://img.shields.io/github/issues/luiz-otavio/placeholder4j?style=for-the-badge\" alt=\"Issues\"/\u003e\n    \u003cimg src=\"https://img.shields.io/github/forks/luiz-otavio/placeholder4j?style=for-the-badge\" alt=\"Forks\"/\u003e\n    \u003cimg src=\"https://img.shields.io/github/stars/luiz-otavio/placeholder4j?style=for-the-badge\" alt=\"Stars\"/\u003e\n\u003c/div\u003e\n\n## Beside of understanding how placeholders are important: \u003c/p\u003e\nConstantly we need to replace some values in a string. For example, if we have a message like this: `Hello {name}, how are you?` \nand we want to replace the `{name}` with a value, we can use the `replaceAll` method from the `String` class.\n```java\npublic static void main(String[]args){\n    String message = \"Hello {name}, how are you?\";\n    String name = \"John\";\n    String replacedMessage = message.replaceAll(\"\\\\{name\\\\}\", name);\n    System.out.println(replacedMessage);\n}\n```\n\nBut, if we have multiple placeholders, we need to call the `replaceAll` method multiple times which is not a good practice.\n```java\npublic static void main(String[]args){\n    String message = \"Hello {name}, how are you? I'm {age} years old.\";\n    String name = \"John\";\n    String age = \"20\";\n    String replacedMessage = message.replaceAll(\"\\\\{name\\\\}\", name).replaceAll(\"\\\\{age\\\\}\", age);\n    System.out.println(replacedMessage);\n}\n```\n\n## How Placeholder4j can help you\nPlaceholder4j is a library that helps you to replace placeholders in a string. It is simple to use, and you can replace multiple placeholders in a single call.\n```java\npublic static void main(String[]args){\n    PlaceholderAPI placeholderAPI = new PlaceholderAPI();\n    // Registering a new placeholder for the name\n    placeholderAPI.register(new VariablePlaceholder(\"%name%\", \"John\"));\n    // Registering a new placeholder for the age\n    placeholderAPI.register(new VariablePlaceholder(\"%age%\", \"20\"));\n    \n    // Calling PlaceholderAPI to replace it.\n    System.out.println(\n        placeholderAPI.replace(\"Hello %name%, how are you? I'm %age% years old.\")\n    );\n}\n```\nCalling it, the output will be: `Hello John, how are you? I'm 20 years old.`\n\n## How to install\nGroovy DSL:\n```groovy\nrepositories {\n    maven { url 'https://jitpack.io' }\n}\n\ndependencies {\n    implementation 'com.github.luiz-otavio:placeholder4j:{PROJECT_VERSION}'\n}\n```\n\nKotlin DSL:\n```kotlin\nrepositories() {\n    maven(\"https://jitpack.io\")\n}\n\ndependencies() {\n    implementation(\"com.github.luiz-otavio:placeholder4j:{PROJECT_VERSION}\")\n}\n```\n\nMaven:\n```xml\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003ejitpack\u003c/id\u003e\n        \u003cname\u003ejitpack\u003c/name\u003e\n        \u003curl\u003ehttps://jitpack.io\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.github.luiz-otavio\u003c/groupId\u003e\n        \u003cartifactId\u003eplaceholder4j\u003c/artifactId\u003e\n        \u003cversion\u003e{PROJECT_VERSION}\u003c/version\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n## License\nThis project is licensed under the [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.html).\n\n## Contributing\nOpen an issue or a pull request and let's discuss about it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluiz-otavio%2Fplaceholder4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluiz-otavio%2Fplaceholder4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluiz-otavio%2Fplaceholder4j/lists"}