|
4 | 4 | import org.jetbrains.annotations.Contract; |
5 | 5 | import org.jspecify.annotations.Nullable; |
6 | 6 |
|
7 | | -import java.util.Map; |
8 | 7 | import java.util.Optional; |
9 | 8 | import java.util.concurrent.Callable; |
10 | 9 |
|
@@ -50,21 +49,51 @@ public interface Chart<T> { |
50 | 49 | Optional<JsonElement> getData() throws Exception; |
51 | 50 |
|
52 | 51 | /** |
53 | | - * Create a bar chart. |
| 52 | + * Create a string array chart. |
54 | 53 | * |
55 | 54 | * @param id the chart id |
56 | 55 | * @param callable the chart data callable |
57 | | - * @return the bar chart |
| 56 | + * @return the string array chart |
58 | 57 | * @throws IllegalArgumentException if the chart id is invalid |
59 | 58 | * @apiNote The callable must be thread-safe and pure (i.e. not modify any shared state). |
60 | 59 | * @see #compute() |
61 | | - * @since 0.1.0 |
| 60 | + * @since 0.5.0 |
| 61 | + */ |
| 62 | + @Contract(value = "_, _ -> new", pure = true) |
| 63 | + static Chart<String[]> stringArray(@ChartId String id, Callable<String @Nullable []> callable) throws IllegalArgumentException { |
| 64 | + return new ArrayChart<>(id, callable); |
| 65 | + } |
| 66 | + |
| 67 | + /** |
| 68 | + * Create a boolean array chart. |
| 69 | + * |
| 70 | + * @param id the chart id |
| 71 | + * @param callable the chart data callable |
| 72 | + * @return the boolean array chart |
| 73 | + * @throws IllegalArgumentException if the chart id is invalid |
| 74 | + * @apiNote The callable must be thread-safe and pure (i.e. not modify any shared state). |
| 75 | + * @see #compute() |
| 76 | + * @since 0.5.0 |
| 77 | + */ |
| 78 | + @Contract(value = "_, _ -> new", pure = true) |
| 79 | + static Chart<Boolean[]> booleanArray(@ChartId String id, Callable<Boolean @Nullable []> callable) throws IllegalArgumentException { |
| 80 | + return new ArrayChart<>(id, callable); |
| 81 | + } |
| 82 | + |
| 83 | + /** |
| 84 | + * Create a number array chart. |
| 85 | + * |
| 86 | + * @param id the chart id |
| 87 | + * @param callable the chart data callable |
| 88 | + * @return the number array chart |
| 89 | + * @throws IllegalArgumentException if the chart id is invalid |
| 90 | + * @apiNote The callable must be thread-safe and pure (i.e. not modify any shared state). |
| 91 | + * @see #compute() |
| 92 | + * @since 0.5.0 |
62 | 93 | */ |
63 | | - // todo: introduce a better way to transmit multiple values |
64 | | - @Deprecated |
65 | 94 | @Contract(value = "_, _ -> new", pure = true) |
66 | | - static Chart<Map<String, Number>> bar(@ChartId String id, Callable<@Nullable Map<String, Number>> callable) throws IllegalArgumentException { |
67 | | - return new SimpleBarChart(id, callable); |
| 95 | + static Chart<Number[]> numberArray(@ChartId String id, Callable<Number @Nullable []> callable) throws IllegalArgumentException { |
| 96 | + return new ArrayChart<>(id, callable); |
68 | 97 | } |
69 | 98 |
|
70 | 99 | /** |
|
0 commit comments