I would build it like:
Mutable version:
class Options extends JavaScriptObject {
public native Options with(String option, String value) /*-{
this[option] = value;
return this;
}-*/;
}
Options options = Options.createObject()
.with("opacity", "0.5")
.with("width", "100");
An immutable Options class would also be possible but as it is GWT you are
dealing with things are never really immutable thanks to JSNI magic. Using
JSNI magic you could hide the JavaScriptObject from Java code but still use
it inside your perform() method, e.g.
class Options {
private JavaScriptObject nativePeer;
// Builder class having the "with(.., ..)" method and which configures
the native peer
// getter, etc. to inspect the native peer if needed.
}
public native CssHolder perform(Element e, int duration, Options options)
/*-{
var nativeOptions = options.@<full qualified class name>::nativePeer;
return $wnd.CssMod.perform(e, duration, nativeOptions);
}-*/;
-- J.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.