public ChoiceTypeImpl() { super(new ChoiceType()); }
@Override public String validateInternalValue(Object internalValue) { List<ChoiceOption> options = type.getOptions(); if (options!=null) { for (ChoiceOption option: options) { if (internalValue.equals(option.getId())) { return null; } } } return "Invalid value '"+internalValue+"'. Expected one of "+options+" (or null)."; } }
public ChoiceType option(String option) { option(new ChoiceOption().id(option)); return this; }
.variable("team-bonus", MoneyType.INSTANCE) .variable("bugs-fixed", NumberType.INSTANCE) .variable("distribution", new ChoiceType().option("Internal").option("External")) .variable("stakeholders", new ListType().elementType(EmailAddressType.INSTANCE)); assertEquals(2, choiceType.getOptions().size()); assertEquals("Internal", choiceType.getOptions().get(0).getId()); assertEquals("External", choiceType.getOptions().get(1).getId());
ChoiceType choiceType = new ChoiceType().option("Red pill").option("Blue pill"); workflow.variable(new Variable().id("variable02").type(choiceType).defaultValue("Blue pill")); workflow.variable(new Variable().id("variable03").type(new DateType()).defaultValue(now)); assertEquals("Red pill", ((ChoiceType) workflow.getVariables().get(1).getType()).getOptions().get(0).getId()); assertEquals("Blue pill", workflow.getVariables().get(1).getDefaultValue());
public ChoiceType option(String option) { option(new ChoiceOption().id(option)); return this; }
@Override public void readBpmn(BpmnReader r) { for (XmlElement optionElement : r.readElementsEffektif("option")) { r.startElement(optionElement); ChoiceOption option = new ChoiceOption(); option.readBpmn(r); option(option); r.endElement(); } }
@Override public void readBpmn(BpmnReader r) { for (XmlElement optionElement : r.readElementsEffektif("option")) { r.startElement(optionElement); ChoiceOption option = new ChoiceOption(); option.readBpmn(r); option(option); r.endElement(); } }