io.camunda.zeebe.model.bpmn.builder.AbstractEndEventBuilder Maven / Gradle / Ivy
/*
* Copyright © 2017 camunda services GmbH ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.camunda.zeebe.model.bpmn.builder;
import io.camunda.zeebe.model.bpmn.BpmnModelInstance;
import io.camunda.zeebe.model.bpmn.instance.EndEvent;
import io.camunda.zeebe.model.bpmn.instance.ErrorEventDefinition;
import io.camunda.zeebe.model.bpmn.instance.TerminateEventDefinition;
/**
* @author Sebastian Menski
*/
public abstract class AbstractEndEventBuilder>
extends AbstractThrowEventBuilder {
protected AbstractEndEventBuilder(
final BpmnModelInstance modelInstance, final EndEvent element, final Class> selfType) {
super(modelInstance, element, selfType);
}
/**
* Sets a dynamic error code for the error that is retrieved from the given expression
*
* @param errorCodeExpression the expression for the error
* @return the builder object
*/
public B errorExpression(final String errorCodeExpression) {
return error(asZeebeExpression(errorCodeExpression));
}
/**
* Sets an error definition for the given error code. If already an error with this code exists it
* will be used, otherwise a new error is created.
*
* @param errorCode the code of the error
* @return the builder object
*/
public B error(final String errorCode) {
final ErrorEventDefinition errorEventDefinition = createErrorEventDefinition(errorCode);
element.getEventDefinitions().add(errorEventDefinition);
return myself;
}
/**
* Creates an error event definition with an unique id and returns a builder for the error event
* definition.
*
* @return the error event definition builder object
*/
public ErrorEventDefinitionBuilder errorEventDefinition(final String id) {
final ErrorEventDefinition errorEventDefinition = createEmptyErrorEventDefinition();
if (id != null) {
errorEventDefinition.setId(id);
}
element.getEventDefinitions().add(errorEventDefinition);
return new ErrorEventDefinitionBuilder(modelInstance, errorEventDefinition);
}
/**
* Creates an error event definition and returns a builder for the error event definition.
*
* @return the error event definition builder object
*/
public ErrorEventDefinitionBuilder errorEventDefinition() {
final ErrorEventDefinition errorEventDefinition = createEmptyErrorEventDefinition();
element.getEventDefinitions().add(errorEventDefinition);
return new ErrorEventDefinitionBuilder(modelInstance, errorEventDefinition);
}
/**
* Creates a terminate event definition and add it to the end event. It morphs the end event into
* a terminate end event.
*
* @return the builder object
*/
public B terminate() {
final TerminateEventDefinition terminateEventDefinition =
createInstance(TerminateEventDefinition.class);
element.getEventDefinitions().add(terminateEventDefinition);
return myself;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy