public final class SetCustomField extends SetCustomFieldBase<ShoppingList>
See also ShoppingListInStoreUpdateCommand.
withUpdateableType(client(), type -> { final CustomFieldsDraft customFieldsDraft = CustomFieldsDraftBuilder.ofType(type).addObject(STRING_FIELD_NAME, "a value").build(); final ShoppingListDraftDsl shoppingListDraft = newShoppingListDraftBuilder().custom(customFieldsDraft).build(); withShoppingList(client(), shoppingListDraft, shoppingList -> { final ShoppingList shoppingListWithCustomType = client().executeBlocking(ShoppingListUpdateCommand.of(shoppingList, SetCustomType.ofTypeIdAndObjects(type.getId(), STRING_FIELD_NAME, "a value"))); assertThat(shoppingListWithCustomType.getCustom().getField(STRING_FIELD_NAME, TypeReferences.stringTypeReference())) .isEqualTo("a value"); final String newValue = randomString(); final ShoppingList shoppingListWithCustomField = client().executeBlocking(ShoppingListUpdateCommand.of(shoppingListWithCustomType, SetCustomField.ofObject(STRING_FIELD_NAME, newValue))); assertThat(shoppingListWithCustomField.getCustom().getField(STRING_FIELD_NAME, TypeReferences.stringTypeReference())) .isEqualTo(newValue); return shoppingListWithCustomField; }); return type; });
See the test code.
Custom
Modifier and Type | Method and Description |
---|---|
static SetCustomField |
ofJson(String name,
com.fasterxml.jackson.databind.JsonNode value) |
static SetCustomField |
ofObject(String name,
Object value) |
static SetCustomField |
ofUnset(String name) |
getName, getValue
getAction
public static SetCustomField ofJson(String name, com.fasterxml.jackson.databind.JsonNode value)
public static SetCustomField ofObject(String name, Object value)
public static SetCustomField ofUnset(String name)