-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
368 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
2022-10 - 1.0.1 | ||
|
||
- fix #180 "Wrapped Data Types" | ||
|
||
2022-07 | ||
|
||
1.0.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#@define | ||
TypeA { | ||
fizz: String | ||
buzz: String | ||
} | ||
|
||
#@define | ||
TypeB { | ||
foo: TypeA | ||
bar: TypeA | ||
} | ||
|
||
cfg { | ||
typeB: TypeB | ||
additionalParam: String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package tscfg.example; | ||
|
||
public class JavaIssue180Cfg { | ||
public final JavaIssue180Cfg.Cfg cfg; | ||
public static class TypeA { | ||
public final java.lang.String buzz; | ||
public final java.lang.String fizz; | ||
|
||
public TypeA(com.typesafe.config.Config c, java.lang.String parentPath, $TsCfgValidator $tsCfgValidator) { | ||
this.buzz = $_reqStr(parentPath, c, "buzz", $tsCfgValidator); | ||
this.fizz = $_reqStr(parentPath, c, "fizz", $tsCfgValidator); | ||
} | ||
private static java.lang.String $_reqStr(java.lang.String parentPath, com.typesafe.config.Config c, java.lang.String path, $TsCfgValidator $tsCfgValidator) { | ||
if (c == null) return null; | ||
try { | ||
return c.getString(path); | ||
} | ||
catch(com.typesafe.config.ConfigException e) { | ||
$tsCfgValidator.addBadPath(parentPath + path, e); | ||
return null; | ||
} | ||
} | ||
|
||
} | ||
|
||
public static class TypeB { | ||
public final TypeA bar; | ||
public final TypeA foo; | ||
|
||
public TypeB(com.typesafe.config.Config c, java.lang.String parentPath, $TsCfgValidator $tsCfgValidator) { | ||
this.bar = c.hasPathOrNull("bar") ? new TypeA(c.getConfig("bar"), parentPath + "bar.", $tsCfgValidator) : new TypeA(com.typesafe.config.ConfigFactory.parseString("bar{}"), parentPath + "bar.", $tsCfgValidator); | ||
this.foo = c.hasPathOrNull("foo") ? new TypeA(c.getConfig("foo"), parentPath + "foo.", $tsCfgValidator) : new TypeA(com.typesafe.config.ConfigFactory.parseString("foo{}"), parentPath + "foo.", $tsCfgValidator); | ||
} | ||
} | ||
|
||
public static class Cfg { | ||
public final java.lang.String additionalParam; | ||
public final TypeB typeB; | ||
|
||
public Cfg(com.typesafe.config.Config c, java.lang.String parentPath, $TsCfgValidator $tsCfgValidator) { | ||
this.additionalParam = $_reqStr(parentPath, c, "additionalParam", $tsCfgValidator); | ||
this.typeB = c.hasPathOrNull("typeB") ? new TypeB(c.getConfig("typeB"), parentPath + "typeB.", $tsCfgValidator) : new TypeB(com.typesafe.config.ConfigFactory.parseString("typeB{}"), parentPath + "typeB.", $tsCfgValidator); | ||
} | ||
private static java.lang.String $_reqStr(java.lang.String parentPath, com.typesafe.config.Config c, java.lang.String path, $TsCfgValidator $tsCfgValidator) { | ||
if (c == null) return null; | ||
try { | ||
return c.getString(path); | ||
} | ||
catch(com.typesafe.config.ConfigException e) { | ||
$tsCfgValidator.addBadPath(parentPath + path, e); | ||
return null; | ||
} | ||
} | ||
|
||
} | ||
|
||
public JavaIssue180Cfg(com.typesafe.config.Config c) { | ||
final $TsCfgValidator $tsCfgValidator = new $TsCfgValidator(); | ||
final java.lang.String parentPath = ""; | ||
this.cfg = c.hasPathOrNull("cfg") ? new JavaIssue180Cfg.Cfg(c.getConfig("cfg"), parentPath + "cfg.", $tsCfgValidator) : new JavaIssue180Cfg.Cfg(com.typesafe.config.ConfigFactory.parseString("cfg{}"), parentPath + "cfg.", $tsCfgValidator); | ||
$tsCfgValidator.validate(); | ||
} | ||
private static final class $TsCfgValidator { | ||
private final java.util.List<java.lang.String> badPaths = new java.util.ArrayList<>(); | ||
|
||
void addBadPath(java.lang.String path, com.typesafe.config.ConfigException e) { | ||
badPaths.add("'" + path + "': " + e.getClass().getName() + "(" + e.getMessage() + ")"); | ||
} | ||
|
||
void validate() { | ||
if (!badPaths.isEmpty()) { | ||
java.lang.StringBuilder sb = new java.lang.StringBuilder("Invalid configuration:"); | ||
for (java.lang.String path : badPaths) { | ||
sb.append("\n ").append(path); | ||
} | ||
throw new com.typesafe.config.ConfigException(sb.toString()) {}; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.