mirror of
https://github.com/Coloryr/AllMusic.git
synced 2026-11-26 08:03:07 +00:00
33 lines
919 B
Java
33 lines
919 B
Java
package com.coloryr.allmusic.server.bstats.charts;
|
|
|
|
import com.coloryr.allmusic.server.bstats.json.JsonObjectBuilder;
|
|
|
|
import java.util.concurrent.Callable;
|
|
|
|
public class SimplePie extends CustomChart {
|
|
|
|
private final Callable<String> callable;
|
|
|
|
/**
|
|
* Class constructor.
|
|
*
|
|
* @param chartId The id of the chart.
|
|
* @param callable The callable which is used to request the chart data.
|
|
*/
|
|
public SimplePie(String chartId, Callable<String> callable) {
|
|
super(chartId);
|
|
this.callable = callable;
|
|
}
|
|
|
|
@Override
|
|
protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
|
|
String value = callable.call();
|
|
if (value == null || value.isEmpty()) {
|
|
// Null = skip the chart
|
|
return null;
|
|
}
|
|
return new JsonObjectBuilder()
|
|
.appendField("value", value)
|
|
.build();
|
|
}
|
|
} |