From d44f8ea4c1df4fca2dced0bedeff3612d9dfc486 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 8 Apr 2019 13:14:59 +0100 Subject: Fix up type-safe property helpers --- scripts/toy.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'scripts') 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 getProp(String i, java.util.function.Function 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 loadB = this.&loadBoolean; + final java.util.function.Function loadI = this.&loadInteger; + final java.util.function.Function 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 } -- cgit v1.2.3