Skip to content

Commit

Permalink
include record example
Browse files Browse the repository at this point in the history
  • Loading branch information
carueda committed Jan 25, 2025
1 parent 0e18876 commit 5b2cb1a
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ For example, from this configuration:

```hocon
service {
url = "http://example.net/rest"
url = "https://example.net/rest"
poolSize = 32
debug = true
factor = 0.75
Expand All @@ -70,19 +70,35 @@ tscfg will generate the following (javadoc, constructors and other methods omitt

- Java:

```java
public class Cfg {
public final Service service;
public static class Service {
public final boolean debug;
public final double factor;
public final int poolSize;
public final String url;
}
}
```
- With records (`--java:records`):

```java
public record Cfg(Service service) {
public record Service(
boolean debug,
double factor,
int poolSize,
String url
) {}
}
```
Nesting of configuration properties is captured via inner records.

- POJOs:

```java
public class Cfg {
public final Service service;
public static class Service {
public final boolean debug;
public final double factor;
public final int poolSize;
public final String url;
}
}
```
Nesting of configuration properties is captured via inner static classes.

Nesting of configuration properties is captured via inner static classes.

- Scala:

Expand All @@ -99,7 +115,6 @@ tscfg will generate the following (javadoc, constructors and other methods omitt
)
}
```

Nesting of configuration properties is captured via nested companion objects.

The tool determines the type of each field according to the given value
Expand Down

0 comments on commit 5b2cb1a

Please sign in to comment.