Updated DataExtension API Builders (markdown)

Aurora Lahtela 2022-09-04 08:48:20 +03:00
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
}
```