mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-28 13:45:38 +01:00
Updated DataExtension API Builders (markdown)
parent
74ae57de23
commit
a19f0e3a64
@ -26,7 +26,7 @@ In the most simple form:
|
||||
```java
|
||||
ExtensionDataBuilder builder = newExtensionDataBuilder();
|
||||
return builder.addValue(Long.class,
|
||||
builder.valueBuilder("Steps taken")
|
||||
builder.valueBuilder("Steps taken") // The text should be different for each value
|
||||
.buildNumber(53298L)
|
||||
);
|
||||
```
|
||||
@ -35,24 +35,26 @@ You can add multiple values to a single builder before returning it.
|
||||
|
||||
Here are the types and build methods that are available:
|
||||
```java
|
||||
builder.addValue(Boolean.class, builder.valueBuilder("Example").buildBoolean(false));
|
||||
ExtensionDataBuilder builder = newExtensionDataBuilder();
|
||||
|
||||
Boolean.class, ...buildBoolean(false));
|
||||
Boolean.class, ...buildBoolean(() -> false));
|
||||
Boolean.class, ...buildBooleanProvidingCondition(false, "conditionName")); // for use with @Conditional on other provider annotations
|
||||
Boolean.class, ...buildBooleanProvidingCondition(() -> false, "conditionName")); // for use with @Conditional on other provider annotations
|
||||
Long.class, ...buildNumber(1234L));
|
||||
Long.class, ...buildNumber(() -> 1234L));
|
||||
Double.class, ...buildDouble(500.52));
|
||||
Double.class, ...buildDouble(() ->500.52));
|
||||
Double.class, ...buildPercentage(0.52));
|
||||
Double.class, ...buildPercentage(() -> 0.52));
|
||||
String.class, ...buildString("Example"));
|
||||
String.class, ...buildString(() -> "Example"));
|
||||
String[].class, ...buildGroup(new String[]{"Admin", "Moderator"}));
|
||||
String[].class, ...buildGroup(() -> new String[]{"Admin", "Moderator"}));
|
||||
Table.class, ...buildTable(Table.builder()...build(), Color.BLUE);
|
||||
Table.class, ...buildTable(() -> Table.builder()...build(), Color.BLUE);
|
||||
builder.addValue(Boolean.class, builder.valueBuilder("...").buildBoolean(false));
|
||||
builder.addValue(Boolean.class, builder.valueBuilder("...").buildBoolean(() -> false));
|
||||
// for use with @Conditional on other provider annotations
|
||||
builder.addValue(Boolean.class, builder.valueBuilder("...").buildBooleanProvidingCondition(false, "conditionName"));
|
||||
// for use with @Conditional on other provider annotations
|
||||
builder.addValue(Boolean.class, builder.valueBuilder("...").buildBooleanProvidingCondition(() -> false, "conditionName"));
|
||||
builder.addValue(Long.class, builder.valueBuilder("...").buildNumber(1234L));
|
||||
builder.addValue(Long.class, builder.valueBuilder("...").buildNumber(() -> 1234L));
|
||||
builder.addValue(Double.class, builder.valueBuilder("...").buildDouble(500.52));
|
||||
builder.addValue(Double.class, builder.valueBuilder("...").buildDouble(() ->500.52));
|
||||
builder.addValue(Double.class, builder.valueBuilder("...").buildPercentage(0.52));
|
||||
builder.addValue(Double.class, builder.valueBuilder("...").buildPercentage(() -> 0.52));
|
||||
builder.addValue(String.class, builder.valueBuilder("...").buildString("Example"));
|
||||
builder.addValue(String.class, builder.valueBuilder("...").buildString(() -> "Example"));
|
||||
builder.addValue(String[].class, builder.valueBuilder("...").buildGroup(new String[]{"Admin", "Moderator"}));
|
||||
builder.addValue(String[].class, builder.valueBuilder("...").buildGroup(() -> new String[]{"Admin", "Moderator"}));
|
||||
builder.addValue(Table.class, builder.valueBuilder("...").buildTable(Table.builder()...build(), Color.BLUE));
|
||||
builder.addValue(Table.class, builder.valueBuilder("...").buildTable(() -> Table.builder()...build(), Color.BLUE));
|
||||
```
|
||||
The lambda methods can be used for method references, conditional values (eg returning null sometimes) and for throwing `NotReadyException` for a specific value.
|
||||
|
||||
@ -86,7 +88,7 @@ private DataValue<Long> superheroCountValue() {
|
||||
}
|
||||
|
||||
private long getSuperheroCount() {
|
||||
return 0; // TODO implement later eh? :D
|
||||
return 0; // TODO implement later
|
||||
}
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user