Skip to content

Commit cb65221

Browse files
committed
update README
1 parent 4a7ad5f commit cb65221

1 file changed

Lines changed: 112 additions & 43 deletions

File tree

README.md

Lines changed: 112 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,45 @@
1-
# Propify
1+
# 🔧 Propify
22

33
![Build Status](https://github.com/vgerbot-libraries/propify/actions/workflows/build.yml/badge.svg) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/9d3df77c87d243a9bb68b8687a87bfeb)](https://app.codacy.com/gh/vgerbot-libraries/propify/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/9d3df77c87d243a9bb68b8687a87bfeb)](https://app.codacy.com/gh/vgerbot-libraries/propify/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage)
44

55
----
66

7-
A lightweight Java annotation processor that automatically generates **type-safe** classes for both configuration files (YAML or `.properties`) and internationalization bundles. Access every configuration key and message through Java methods—no more stringly-typed keys—and catch invalid accesses at compile time. Supports nested properties, custom lookup providers, and full ICU4J formatting.
7+
**Propify** is a powerful, lightweight Java annotation processor that eliminates configuration errors by generating **type-safe** classes from your configuration files (YAML, INI, or `.properties`) and internationalization bundles.
88

9-
---
9+
> **Say goodbye to "stringly-typed" keys and runtime errors!** Access every configuration value and message through strongly-typed Java methods, catching invalid accesses at compile time instead of runtime.
10+
11+
Propify seamlessly supports nested properties, custom lookup providers, and full ICU4J formatting while adding zero runtime dependencies to your application.
12+
13+
----
1014

1115
## 📖 Table of Contents
1216

13-
1. [Why Propify?](#why-propify)
14-
2. [Features](#features)
15-
3. [Requirements](#requirements)
16-
4. [Installation](#installation)
17-
5. [Quick Start](#quick-start)
18-
6. [Advanced Usage](#advanced-usage)
19-
7. [Internationalization (i18n)](#internationalization-i18n)
20-
8. [How It Works](#how-it-works)
21-
9. [Contributing](#contributing)
22-
10. [License](#license)
23-
11. [Acknowledgments](#acknowledgments)
17+
1. [Why Propify?](#-why-propify)
18+
2. [Features](#-features)
19+
3. [Requirements](#-requirements)
20+
4. [Installation](#-installation)
21+
5. [Quick Start](#-quick-start)
22+
6. [Advanced Usage](#-advanced-usage)
23+
7. [Internationalization (i18n)](#-internationalization-i18n)
24+
8. [How It Works](#️-how-it-works)
25+
9. [Examples](#-examples)
26+
10. [Getting Help](#-getting-help)
27+
11. [Contributing](#-contributing)
28+
12. [License](#-license)
29+
13. [Acknowledgments](#-acknowledgments)
2430

25-
---
31+
----
2632

27-
## Why Propify?
33+
## 🤔 Why Propify?
2834

2935
- **Type-Safety**: Access configuration and messages via Java methods—no more stringly-typed keys.
3036
- **Compile-Time Guarantees**: Prevent typos in code (incorrect keys) from compiling, so invalid property accesses are caught before runtime.
3137
- **Productivity**: Skip manual parsing and error-prone lookups.
3238
- **Extendable**: Plug in custom lookup providers for environment variables, system properties, or your own sources.
3339

34-
---
40+
----
3541

36-
## Features
42+
## Features
3743

3844
- 🔒 **Type-Safe Config**: Generates POJOs from YAML, INI, or `.properties` files
3945
- 🌐 **Type-Safe i18n**: Strongly-typed resource bundles with ICU4J formatting
@@ -42,16 +48,16 @@ A lightweight Java annotation processor that automatically generates **type-safe
4248
- 🔄 **Custom Lookups**: Inject dynamic values (env, system props, custom)
4349
- ⚡️ **Zero Runtime Overhead**: All code generated at compile time
4450

45-
---
51+
----
4652

47-
## Requirements
53+
## 📋 Requirements
4854

4955
- **Java**: 8 or higher
5056
- **Build**: Maven or Gradle
5157

52-
---
58+
----
5359

54-
## Installation
60+
## 📥 Installation
5561

5662
### Maven
5763

@@ -111,11 +117,12 @@ dependencies {
111117

112118
> For other tools, configure your build to include `propify` as an annotation processor.
113119
114-
---
120+
----
115121

116-
## Quick Start
122+
## 🚀 Quick Start
117123

118124
1. **Create** `src/main/resources/application.yml`:
125+
119126
```yaml
120127
server:
121128
host: localhost
@@ -125,12 +132,16 @@ dependencies {
125132
username: root
126133
password: secret
127134
```
135+
128136
2. **Annotate** an interface:
137+
129138
```java
130139
@Propify(location = "application.yml")
131140
public interface AppConfig {}
132141
```
142+
133143
3. **Use** the generated API:
144+
134145
```java
135146
public class Main {
136147
public static void main(String[] args) {
@@ -142,6 +153,7 @@ dependencies {
142153
```
143154

144155
Configuration locations can be:
156+
145157
- On the classpath (e.g., `application.yml` in `src/main/resources/`)
146158
- Local file system (`file:///path/to/config.yml`)
147159
- HTTP/HTTPS URL (`https://...`)
@@ -155,9 +167,9 @@ public interface WebConfig {}
155167

156168
> ⚠️ Ensure your configuration files are reachable at build time—whether via classpath, file path, or network URL.
157169
158-
---
170+
----
159171

160-
## Advanced Usage
172+
## 🔧 Advanced Usage
161173

162174
### Custom Class Name
163175

@@ -189,13 +201,15 @@ Propify lets you interpolate dynamic values at build time via lookup providers.
189201
- **Custom lookups**: `{lookupName:variableName}` — resolved by the corresponding lookup class
190202

191203
**Example configuration** (`application.yml`):
204+
192205
```yaml
193206
app:
194207
tempDir: "{env:TEMP_DIR}"
195208
secretKey: "{vault:db-secret}"
196209
```
197210
198211
**Annotate your interface**:
212+
199213
```java
200214
@Propify(
201215
location = "application.yml",
@@ -208,20 +222,21 @@ public interface AppConfig {}
208222
```
209223

210224
**Usage in code**:
225+
211226
```java
212227
AppConfig cfg = new AppConfigPropify();
213228
String tempDir = cfg.getApp().getTempDir(); // from $TEMP_DIR
214229
String secret = cfg.getApp().getSecretKey(); // from vault lookup
215-
```
216-
217-
---
230+
```
218231

232+
----
219233

220-
## Internationalization (i18n)
234+
## 🌐 Internationalization (i18n)
221235

222236
Generate type-safe resource bundles using ICU4J:
223237

224238
1. **Create** message files in `resources/`:
239+
225240
```properties
226241
# messages.properties (default)
227242
welcome=Welcome
@@ -231,31 +246,86 @@ Generate type-safe resource bundles using ICU4J:
231246
welcome=欢迎
232247
greeting=你好, {name}!
233248
```
249+
234250
2. **Annotate** a class:
251+
235252
```java
236253
@I18n(baseName = "messages", defaultLocale = "en")
237254
public class Messages {}
238255
```
256+
239257
3. **Access** messages:
258+
240259
```java
241260
String hi = MessageResource.getDefault().greeting("Alice");
242261
String hiZh = MessageResource.get(Locale.CHINESE).greeting("张三");
243262
```
244263

245264
Supports pluralization, dates, numbers, and custom ICU patterns—fully validated at compile time.
246265

247-
---
266+
----
248267

249-
## How It Works
268+
## ⚙️ How It Works
250269

251270
1. **Scan** for `@Propify` and `@I18n` annotations
252271
2. **Parse** configuration and message files
253272
3. **Generate** Java implementation classes
254273
4. **Compile** everything together—fail-fast on errors
255274

256-
---
275+
----
276+
277+
## 📝 Examples
278+
279+
Here are some practical examples of how to use Propify in common scenarios:
280+
281+
### Nested Configuration
282+
283+
```java
284+
// application.yml
285+
// server:
286+
// http:
287+
// port: 8080
288+
// https:
289+
// port: 8443
290+
// keystore: /path/to/keystore
291+
292+
@Propify(location = "application.yml")
293+
public interface ServerConfig {}
294+
295+
// Usage
296+
ServerConfigPropify config = new ServerConfigPropify();
297+
int httpPort = config.getServer().getHttp().getPort(); // 8080
298+
String keystore = config.getServer().getHttps().getKeystore(); // /path/to/keystore
299+
```
300+
301+
### Environment-Specific Configuration
302+
303+
```java
304+
// Using environment variables in your config
305+
// app.yml
306+
// database:
307+
// url: "jdbc:mysql://{env:DB_HOST}:{env:DB_PORT}/{env:DB_NAME}"
308+
309+
@Propify(
310+
location = "app.yml",
311+
lookups = { EnvironmentLookup.class }
312+
)
313+
public interface AppConfig {}
314+
```
315+
316+
----
317+
318+
## 🙋 Getting Help
319+
320+
If you encounter any issues or have questions about using Propify:
257321

258-
## Contributing
322+
- **GitHub Issues**: Submit a [new issue](https://github.com/vgerbot-libraries/propify/issues) on our GitHub repository
323+
- **Documentation**: Check the [Wiki](https://github.com/vgerbot-libraries/propify/wiki) for detailed documentation
324+
- **Examples**: Browse the [examples directory](https://github.com/vgerbot-libraries/propify/tree/main/examples) for sample projects
325+
326+
----
327+
328+
## 👥 Contributing
259329

260330
1. Fork the repo
261331
2. Create a feature branch (`git checkout -b feature/xyz`)
@@ -264,18 +334,17 @@ Supports pluralization, dates, numbers, and custom ICU patterns—fully validate
264334

265335
Please follow the existing coding style and update tests.
266336

267-
---
337+
----
268338

269-
## License
339+
## 📄 License
270340

271341
[MIT](LICENSE) © 2024 vgerbot-libraries
272342

273-
---
274-
275-
## Acknowledgments
343+
----
276344

277-
- [JavaPoet](https://github.com/square/javapoet)
278-
- [Jackson YAML](https://github.com/FasterXML/jackson-dataformats-text)
279-
- [Apache Commons Configuration](https://commons.apache.org/proper/commons-configuration/)
280-
- [ICU4J](https://unicode-org.github.io/icu/userguide/icu4j/)
345+
## 🙏 Acknowledgments
281346

347+
- [JavaPoet](https://github.com/square/javapoet) - Java source file generation
348+
- [Jackson YAML](https://github.com/FasterXML/jackson-dataformats-text) - YAML parsing
349+
- [Apache Commons Configuration](https://commons.apache.org/proper/commons-configuration/) - Configuration management
350+
- [ICU4J](https://unicode-org.github.io/icu/userguide/icu4j/) - Internationalization support

0 commit comments

Comments
 (0)