-
-
Save jnehlmeier/c8494b8cffc3f81b23cc to your computer and use it in GitHub Desktop.
gwt-d3: Workaround Double/Boolean unboxed in GWT 2.8
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
// package protected because its internal | |
interface BooleanDatumFunction { | |
public boolean apply(Element context, Value d, int index); | |
} |
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
public interface DatumFunction<T> { | |
public T apply(Element context, Value d, int index); | |
} |
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
// make it a Java method | |
public final Selection classed(String classNames, DatumFunction<Boolean> addFunction) { | |
return classed(classNames, new BooleanDatumFunction() { | |
public boolean apply(Element context, Value d, int index) { | |
Boolean ret = addFunction.apply(context, d, index); | |
return ret == null ? false : ret.booleanValue(); | |
} | |
}); | |
}; | |
private native final Selection classedImpl(String classNames, BooleanDatumFunction addFunction)/*-{ | |
return this.classed( | |
classNames, | |
function(d, i) { | |
// always returns primitive boolean now | |
// JSNI Shortcut notation | |
return addFunction.@BooleanDatumFunction::apply(*)(this,{datum:d},i); | |
}); | |
}-*/; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment