Skip to content

Instantly share code, notes, and snippets.

@christophe-dooapp
Created June 20, 2013 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christophe-dooapp/5822568 to your computer and use it in GitHub Desktop.
Save christophe-dooapp/5822568 to your computer and use it in GitHub Desktop.
private DoubleBinding averageBinding = new DoubleBinding() {
{
//call #computeValue every time #values() changes
super.bind(values());
}
@Override
protected double computeValue() {
double result = 0;
if (values().isEmpty()) {
return result;
}
for (Double d : values()) {
result += d;
}
return result / values().size();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment