diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-04-08 13:14:59 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-04-18 20:57:17 +0100 |
commit | d44f8ea4c1df4fca2dced0bedeff3612d9dfc486 (patch) | |
tree | 8d979ec19874448a1c7940fcf3769fd6bd783ac4 /scripts | |
parent | Rename is helper function (diff) | |
download | toy-d44f8ea4c1df4fca2dced0bedeff3612d9dfc486.zip |
Fix up type-safe property helpers
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/toy.groovy | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/scripts/toy.groovy b/scripts/toy.groovy index 6c54368..e85b83e 100644 --- a/scripts/toy.groovy +++ b/scripts/toy.groovy @@ -180,7 +180,7 @@ return new Object() { } public <T> T getProp(String i, java.util.function.Function<String, T> f, T d = null) { - final T v = f("toy.$i".toString()); + final T v = f.apply("toy.$i".toString()); if (v == null) return d; return v; } @@ -194,9 +194,9 @@ return new Object() { String dommeTitle() { getDommeProp("title", "Mistress") } String dommeName() { getDommeProp("name", "") } - boolean loadB(String p) { loadBoolean(p) } - int loadI(String p) { loadInteger(p) } - String loadS(String p ) { loadString(p) } + final java.util.function.Function<String, Boolean> loadB = this.&loadBoolean; + final java.util.function.Function<String, Integer> loadI = this.&loadInteger; + final java.util.function.Function<String, String> loadS = this.&loadString; void setProp(String i, Object v) { save("toy.$i".toString(), v) } boolean has(String i) { loadBoolean("toys.$i") == true } boolean likes(String i) { loadBoolean("fetish.$i") == true } |