From a19f0e3a64433e878b1d1f70280573164dd8d1e7 Mon Sep 17 00:00:00 2001 From: Aurora Lahtela <24460436+AuroraLS3@users.noreply.github.com> Date: Sun, 4 Sep 2022 08:48:20 +0300 Subject: [PATCH] Updated DataExtension API Builders (markdown) --- DataExtension-API-Builders.md | 40 ++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/DataExtension-API-Builders.md b/DataExtension-API-Builders.md index 580e7a6..2d4c5c3 100644 --- a/DataExtension-API-Builders.md +++ b/DataExtension-API-Builders.md @@ -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 superheroCountValue() { } private long getSuperheroCount() { - return 0; // TODO implement later eh? :D + return 0; // TODO implement later } ```