diff --git a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/BaseBpmnXMLConverter.java b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/BaseBpmnXMLConverter.java index cc6e4659188..8612b69b024 100644 --- a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/BaseBpmnXMLConverter.java +++ b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/BaseBpmnXMLConverter.java @@ -95,8 +95,7 @@ public void convertToBpmnModel(XMLStreamReader xtr, BpmnModel model, Process act BaseElement parsedElement = convertXMLToElement(xtr, model); - if (parsedElement instanceof Artifact) { - Artifact currentArtifact = (Artifact) parsedElement; + if (parsedElement instanceof Artifact currentArtifact) { currentArtifact.setId(elementId); if (!activeSubProcessList.isEmpty()) { @@ -107,39 +106,34 @@ public void convertToBpmnModel(XMLStreamReader xtr, BpmnModel model, Process act } } - if (parsedElement instanceof FlowElement) { + if (parsedElement instanceof FlowElement currentFlowElement) { - FlowElement currentFlowElement = (FlowElement) parsedElement; currentFlowElement.setId(elementId); if (currentFlowElement.getName() == null) { currentFlowElement.setName(elementName); } - if (currentFlowElement instanceof FlowNode) { - FlowNode flowNode = (FlowNode) currentFlowElement; + if (currentFlowElement instanceof FlowNode flowNode) { flowNode.setAsynchronous(async); flowNode.setAsynchronousLeave(asyncLeave); flowNode.setNotExclusive(notExclusive); flowNode.setAsynchronousLeaveNotExclusive(asyncLeaveNotExclusive); - if (currentFlowElement instanceof Activity) { + if (currentFlowElement instanceof Activity activity) { - Activity activity = (Activity) currentFlowElement; activity.setForCompensation(isForCompensation); if (StringUtils.isNotEmpty(defaultFlow)) { activity.setDefaultFlow(defaultFlow); } } - if (currentFlowElement instanceof Gateway) { - Gateway gateway = (Gateway) currentFlowElement; + if (currentFlowElement instanceof Gateway gateway) { if (StringUtils.isNotEmpty(defaultFlow)) { gateway.setDefaultFlow(defaultFlow); } } - if (currentFlowElement instanceof ServiceTask) { - ServiceTask serviceTask = (ServiceTask) currentFlowElement; + if (currentFlowElement instanceof ServiceTask serviceTask) { serviceTask.setTriggerable(triggerable); } } @@ -175,8 +169,7 @@ public void convertToXML(XMLStreamWriter xtw, BaseElement baseElement, BpmnModel } } - if (baseElement instanceof FlowNode) { - final FlowNode flowNode = (FlowNode) baseElement; + if (baseElement instanceof FlowNode flowNode) { if (flowNode.isAsynchronous()) { writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, ATTRIBUTE_VALUE_TRUE, xtw); @@ -191,8 +184,7 @@ public void convertToXML(XMLStreamWriter xtw, BaseElement baseElement, BpmnModel } } - if (baseElement instanceof Activity) { - final Activity activity = (Activity) baseElement; + if (baseElement instanceof Activity activity) { if (activity.isForCompensation()) { writeDefaultAttribute(ATTRIBUTE_ACTIVITY_ISFORCOMPENSATION, ATTRIBUTE_VALUE_TRUE, xtw); } @@ -204,8 +196,7 @@ public void convertToXML(XMLStreamWriter xtw, BaseElement baseElement, BpmnModel } } - if (baseElement instanceof Gateway) { - final Gateway gateway = (Gateway) baseElement; + if (baseElement instanceof Gateway gateway) { if (StringUtils.isNotEmpty(gateway.getDefaultFlow())) { FlowElement defaultFlowElement = model.getFlowElement(gateway.getDefaultFlow()); if (defaultFlowElement instanceof SequenceFlow) { @@ -217,8 +208,7 @@ public void convertToXML(XMLStreamWriter xtw, BaseElement baseElement, BpmnModel writeAdditionalAttributes(baseElement, model, xtw); - if (baseElement instanceof FlowElement) { - final FlowElement flowElement = (FlowElement) baseElement; + if (baseElement instanceof FlowElement flowElement) { if (StringUtils.isNotEmpty(flowElement.getDocumentation())) { xtw.writeStartElement(ELEMENT_DOCUMENTATION); @@ -234,8 +224,7 @@ public void convertToXML(XMLStreamWriter xtw, BaseElement baseElement, BpmnModel didWriteExtensionStartElement = writeExtensionChildElements(baseElement, didWriteExtensionStartElement, xtw); didWriteExtensionStartElement = writeListeners(baseElement, didWriteExtensionStartElement, xtw); didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(baseElement, didWriteExtensionStartElement, model.getNamespaces(), xtw); - if (baseElement instanceof Activity) { - final Activity activity = (Activity) baseElement; + if (baseElement instanceof Activity activity) { didWriteExtensionStartElement = FailedJobRetryCountExport.writeFailedJobRetryCount(activity, didWriteExtensionStartElement, xtw); } @@ -243,8 +232,7 @@ public void convertToXML(XMLStreamWriter xtw, BaseElement baseElement, BpmnModel xtw.writeEndElement(); } - if (baseElement instanceof Activity) { - final Activity activity = (Activity) baseElement; + if (baseElement instanceof Activity activity) { MultiInstanceExport.writeMultiInstance(activity, model, xtw); for (DataAssociation dataInputAssociation : activity.getDataInputAssociations()) { @@ -663,7 +651,7 @@ protected void writeTerminateDefinition(Event parentEvent, TerminateEventDefinit protected boolean writeVariableListenerDefinition(Event parentEvent, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception { if (parentEvent.getEventDefinitions().size() == 1) { EventDefinition eventDefinition = parentEvent.getEventDefinitions().iterator().next(); - if (eventDefinition instanceof VariableListenerEventDefinition) { + if (eventDefinition instanceof VariableListenerEventDefinition variableListenerEventDefinition) { if (!didWriteExtensionStartElement) { xtw.writeStartElement(ELEMENT_EXTENSIONS); didWriteExtensionStartElement = true; @@ -671,7 +659,6 @@ protected boolean writeVariableListenerDefinition(Event parentEvent, boolean did xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ELEMENT_EVENT_VARIABLELISTENERDEFINITION, FLOWABLE_EXTENSIONS_NAMESPACE); - VariableListenerEventDefinition variableListenerEventDefinition = (VariableListenerEventDefinition) eventDefinition; if (StringUtils.isNotEmpty(variableListenerEventDefinition.getVariableName())) { writeDefaultAttribute(ATTRIBUTE_VARIABLE_NAME, variableListenerEventDefinition.getVariableName(), xtw); } diff --git a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/BpmnXMLConverter.java b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/BpmnXMLConverter.java index 64e6e82eba6..25c75a35425 100644 --- a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/BpmnXMLConverter.java +++ b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/BpmnXMLConverter.java @@ -425,8 +425,7 @@ public BpmnModel convertToBpmnModel(XMLStreamReader xtr) { } else if (ELEMENT_COMPLETION_CONDITION.equals(xtr.getLocalName())) { if (!activeSubProcessList.isEmpty()) { SubProcess subProcess = activeSubProcessList.get(activeSubProcessList.size() - 1); - if (subProcess instanceof AdhocSubProcess) { - AdhocSubProcess adhocSubProcess = (AdhocSubProcess) subProcess; + if (subProcess instanceof AdhocSubProcess adhocSubProcess) { adhocSubProcess.setCompletionCondition(xtr.getElementText()); } } @@ -472,8 +471,7 @@ public BpmnModel convertToBpmnModel(XMLStreamReader xtr) { protected void processFlowElements(Collection flowElementList, BaseElement parentScope) { for (FlowElement flowElement : flowElementList) { - if (flowElement instanceof SequenceFlow) { - SequenceFlow sequenceFlow = (SequenceFlow) flowElement; + if (flowElement instanceof SequenceFlow sequenceFlow) { FlowNode sourceNode = getFlowNodeFromScope(sequenceFlow.getSourceRef(), parentScope); if (sourceNode != null) { sourceNode.getOutgoingFlows().add(sequenceFlow); @@ -486,17 +484,14 @@ protected void processFlowElements(Collection flowElementList, Base sequenceFlow.setTargetFlowElement(targetNode); } - } else if (flowElement instanceof BoundaryEvent) { - BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement; + } else if (flowElement instanceof BoundaryEvent boundaryEvent) { FlowElement attachedToElement = getFlowNodeFromScope(boundaryEvent.getAttachedToRefId(), parentScope); - if (attachedToElement instanceof Activity) { - Activity attachedActivity = (Activity) attachedToElement; + if (attachedToElement instanceof Activity attachedActivity) { boundaryEvent.setAttachedToRef(attachedActivity); attachedActivity.getBoundaryEvents().add(boundaryEvent); } - } else if (flowElement instanceof SubProcess) { - SubProcess subProcess = (SubProcess) flowElement; + } else if (flowElement instanceof SubProcess subProcess) { Collection childFlowElements = subProcess.getFlowElements(); processFlowElements(childFlowElements, subProcess); } @@ -579,9 +574,8 @@ public byte[] convertToXML(BpmnModel model, String encoding) { protected void createXML(FlowElement flowElement, BpmnModel model, XMLStreamWriter xtw) throws Exception { - if (flowElement instanceof SubProcess) { + if (flowElement instanceof SubProcess subProcess) { - SubProcess subProcess = (SubProcess) flowElement; if (flowElement instanceof Transaction) { xtw.writeStartElement(ELEMENT_TRANSACTION); } else if (flowElement instanceof AdhocSubProcess) { @@ -602,8 +596,7 @@ protected void createXML(FlowElement flowElement, BpmnModel model, XMLStreamWrit if (subProcess instanceof EventSubProcess) { xtw.writeAttribute(ATTRIBUTE_TRIGGERED_BY, ATTRIBUTE_VALUE_TRUE); - } else if (subProcess instanceof AdhocSubProcess) { - AdhocSubProcess adhocSubProcess = (AdhocSubProcess) subProcess; + } else if (subProcess instanceof AdhocSubProcess adhocSubProcess) { BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_CANCEL_REMAINING_INSTANCES, String.valueOf(adhocSubProcess.isCancelRemainingInstances()), xtw); if (StringUtils.isNotEmpty(adhocSubProcess.getOrdering())) { BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_ORDERING, adhocSubProcess.getOrdering(), xtw); @@ -648,8 +641,7 @@ protected void createXML(FlowElement flowElement, BpmnModel model, XMLStreamWrit createXML(subElement, model, xtw); } - if (subProcess instanceof AdhocSubProcess) { - AdhocSubProcess adhocSubProcess = (AdhocSubProcess) subProcess; + if (subProcess instanceof AdhocSubProcess adhocSubProcess) { if (StringUtils.isNotEmpty(adhocSubProcess.getCompletionCondition())) { xtw.writeStartElement(ELEMENT_COMPLETION_CONDITION); xtw.writeCData(adhocSubProcess.getCompletionCondition()); diff --git a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/FlowNodeRefParser.java b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/FlowNodeRefParser.java index e296bd86abe..0d96af5016a 100644 --- a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/FlowNodeRefParser.java +++ b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/FlowNodeRefParser.java @@ -30,11 +30,10 @@ public String getElementName() { @Override public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { - if (!(parentElement instanceof Lane)) { + if (!(parentElement instanceof Lane lane)) { return; } - Lane lane = (Lane) parentElement; lane.getFlowReferences().add(xtr.getElementText()); } } diff --git a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/FlowableCollectionParser.java b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/FlowableCollectionParser.java index 6811b85e107..5fbc1c7d34e 100644 --- a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/FlowableCollectionParser.java +++ b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/FlowableCollectionParser.java @@ -29,11 +29,9 @@ public class FlowableCollectionParser extends BaseChildElementParser { @Override public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { - if (!(parentElement instanceof MultiInstanceLoopCharacteristics)) { + if (!(parentElement instanceof MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics)) { return; } - - MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics = (MultiInstanceLoopCharacteristics) parentElement; CollectionHandler collectionHandler = null; diff --git a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/InParameterParser.java b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/InParameterParser.java index 236eaf050f2..73058240c66 100644 --- a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/InParameterParser.java +++ b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/InParameterParser.java @@ -72,8 +72,7 @@ public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, Bp BpmnXMLUtil.addCustomAttributes(xtr, parameter, defaultInParameterAttributes); - } else if (parentElement instanceof CallActivity) { - CallActivity callActivity = (CallActivity) parentElement; + } else if (parentElement instanceof CallActivity callActivity) { String variables = xtr.getAttributeValue(null, ATTRIBUTE_IOPARAMETER_VARIABLES); if ("all".equalsIgnoreCase(variables)) { @@ -95,4 +94,4 @@ public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, Bp } } -} \ No newline at end of file +} diff --git a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/OutParameterParser.java b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/OutParameterParser.java index 174bfd58fa4..69abfed9c2d 100644 --- a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/OutParameterParser.java +++ b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/OutParameterParser.java @@ -67,8 +67,7 @@ public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, Bp ((HasOutParameters) parentElement).addOutParameter(parameter); } - } else if (parentElement instanceof CallActivity) { - CallActivity callActivity = (CallActivity) parentElement; + } else if (parentElement instanceof CallActivity callActivity) { String variables = xtr.getAttributeValue(null, ATTRIBUTE_IOPARAMETER_VARIABLES); if ("all".equalsIgnoreCase(variables)) { @@ -84,4 +83,4 @@ public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, Bp } } -} \ No newline at end of file +} diff --git a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/TimeCycleParser.java b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/TimeCycleParser.java index 2f5749f957d..55a0adf8167 100644 --- a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/TimeCycleParser.java +++ b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/TimeCycleParser.java @@ -32,12 +32,10 @@ public String getElementName() { @Override public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { - if (!(parentElement instanceof TimerEventDefinition)) { + if (!(parentElement instanceof TimerEventDefinition eventDefinition)) { return; } - TimerEventDefinition eventDefinition = (TimerEventDefinition) parentElement; - if (StringUtils.isNotEmpty(BpmnXMLUtil.getAttributeValue(ATTRIBUTE_END_DATE, xtr))) { eventDefinition.setEndDate(BpmnXMLUtil.getAttributeValue(ATTRIBUTE_END_DATE, xtr)); } diff --git a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/TimeDateParser.java b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/TimeDateParser.java index 9de071eb77d..3ae5508f2db 100644 --- a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/TimeDateParser.java +++ b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/TimeDateParser.java @@ -30,11 +30,10 @@ public String getElementName() { @Override public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { - if (!(parentElement instanceof TimerEventDefinition)) { + if (!(parentElement instanceof TimerEventDefinition eventDefinition)) { return; } - TimerEventDefinition eventDefinition = (TimerEventDefinition) parentElement; eventDefinition.setTimeDate(xtr.getElementText()); } } diff --git a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/TimeDurationParser.java b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/TimeDurationParser.java index e673889572c..4679d49b5ca 100644 --- a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/TimeDurationParser.java +++ b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/TimeDurationParser.java @@ -30,11 +30,10 @@ public String getElementName() { @Override public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { - if (!(parentElement instanceof TimerEventDefinition)) { + if (!(parentElement instanceof TimerEventDefinition eventDefinition)) { return; } - TimerEventDefinition eventDefinition = (TimerEventDefinition) parentElement; eventDefinition.setTimeDuration(xtr.getElementText()); } } diff --git a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/VariableAggregationDefinitionParser.java b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/VariableAggregationDefinitionParser.java index 8bdf582557f..28797ff9a1c 100644 --- a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/VariableAggregationDefinitionParser.java +++ b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/VariableAggregationDefinitionParser.java @@ -29,12 +29,10 @@ public class VariableAggregationDefinitionParser extends BaseChildElementParser @Override public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { - if (!(parentElement instanceof MultiInstanceLoopCharacteristics)) { + if (!(parentElement instanceof MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics)) { return; } - MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics = (MultiInstanceLoopCharacteristics) parentElement; - VariableAggregationDefinition aggregationDefinition = new VariableAggregationDefinition(); if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_TASK_SERVICE_CLASS))) { diff --git a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/VariableListenerEventDefinitionParser.java b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/VariableListenerEventDefinitionParser.java index 02dbb8779e6..2d13f8e28dc 100644 --- a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/VariableListenerEventDefinitionParser.java +++ b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/VariableListenerEventDefinitionParser.java @@ -34,7 +34,7 @@ public String getElementName() { @Override public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { - if (!(parentElement instanceof Event)) { + if (!(parentElement instanceof Event event)) { throw new FlowableException("variableListenerEventDefinition is only supported for events, not for activity id " + parentElement.getId()); } @@ -49,8 +49,7 @@ public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, Bp String variableChangeType = xtr.getAttributeValue(null, ATTRIBUTE_VARIABLE_CHANGE_TYPE); eventDefinition.setVariableChangeType(variableChangeType); - - Event event = (Event) parentElement; + event.addEventDefinition(eventDefinition); model.addActivityIdForVariableListenerName(variableName, parentElement.getId()); diff --git a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/export/BPMNDIExport.java b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/export/BPMNDIExport.java index 87c1b3af5ab..91c0b9f04a7 100644 --- a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/export/BPMNDIExport.java +++ b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/export/BPMNDIExport.java @@ -54,12 +54,11 @@ public static void writeBPMNDI(BpmnModel model, XMLStreamWriter xtw) throws Exce for (String elementId : model.getLocationMap().keySet()) { FlowElement flowElement = model.getFlowElement(elementId); - if (flowElement instanceof SubProcess) { + if (flowElement instanceof SubProcess subProcess) { String flowId = flowElement.getId(); GraphicInfo gi = model.getGraphicInfo(flowId); Boolean isExpanded = gi.getExpanded(); if (isExpanded != null && isExpanded == false) { - SubProcess subProcess = (SubProcess) flowElement; for (FlowElement element : subProcess.getFlowElements()) { // the key is the element. the value is the collapsed subprocess. collapsedSubProcessChildren.put(element.getId(), elementId); @@ -78,15 +77,13 @@ public static void writeBPMNDI(BpmnModel model, XMLStreamWriter xtw) throws Exce for (String elementId : model.getFlowLocationMap().keySet()) { FlowElement flowElement = model.getFlowElement(elementId); String belongsTo = null; - if (flowElement instanceof SequenceFlow) { - SequenceFlow sequenceFlow = (SequenceFlow) flowElement; + if (flowElement instanceof SequenceFlow sequenceFlow) { belongsTo = collapsedSubProcessChildren.get(sequenceFlow.getTargetRef()); } else if (flowElement == null) { // check if its an artifact Artifact artifact = model.getArtifact(elementId); - if (artifact instanceof Association) { - Association association = (Association) artifact; + if (artifact instanceof Association association) { belongsTo = collapsedSubProcessChildren.get(association.getTargetRef()); } } diff --git a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/export/SignalAndMessageDefinitionExport.java b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/export/SignalAndMessageDefinitionExport.java index 3c3a32b1111..eb933ba8070 100644 --- a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/export/SignalAndMessageDefinitionExport.java +++ b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/export/SignalAndMessageDefinitionExport.java @@ -35,8 +35,7 @@ public static void writeSignalsAndMessages(BpmnModel model, XMLStreamWriter xtw) Event event = (Event) flowElement; if (!event.getEventDefinitions().isEmpty()) { EventDefinition eventDefinition = event.getEventDefinitions().get(0); - if (eventDefinition instanceof SignalEventDefinition) { - SignalEventDefinition signalEvent = (SignalEventDefinition) eventDefinition; + if (eventDefinition instanceof SignalEventDefinition signalEvent) { if (StringUtils.isNotEmpty(signalEvent.getSignalRef())) { if (!model.containsSignalId(signalEvent.getSignalRef())) { Signal signal = new Signal(signalEvent.getSignalRef(), signalEvent.getSignalRef()); @@ -44,8 +43,7 @@ public static void writeSignalsAndMessages(BpmnModel model, XMLStreamWriter xtw) } } - } else if (eventDefinition instanceof MessageEventDefinition) { - MessageEventDefinition messageEvent = (MessageEventDefinition) eventDefinition; + } else if (eventDefinition instanceof MessageEventDefinition messageEvent) { if (StringUtils.isNotEmpty(messageEvent.getMessageRef())) { if (!model.containsMessageId(messageEvent.getMessageRef())) { Message message = new Message(messageEvent.getMessageRef(), messageEvent.getMessageRef(), null); diff --git a/modules/flowable-bpmn-layout/src/main/java/org/flowable/bpmn/BPMNLayout.java b/modules/flowable-bpmn-layout/src/main/java/org/flowable/bpmn/BPMNLayout.java index 35a4e4b3306..67ab536419d 100644 --- a/modules/flowable-bpmn-layout/src/main/java/org/flowable/bpmn/BPMNLayout.java +++ b/modules/flowable-bpmn-layout/src/main/java/org/flowable/bpmn/BPMNLayout.java @@ -327,8 +327,7 @@ public void execute(Object parent) { } protected boolean isBoundaryEvent(Object obj) { - if (obj instanceof mxCell) { - mxCell cell = (mxCell) obj; + if (obj instanceof mxCell cell) { return cell.getId().startsWith("boundary-event-"); } return false; diff --git a/modules/flowable-bpmn-model/src/main/java/org/flowable/bpmn/model/Process.java b/modules/flowable-bpmn-model/src/main/java/org/flowable/bpmn/model/Process.java index 6367a410ac4..2a8b4734d3c 100644 --- a/modules/flowable-bpmn-model/src/main/java/org/flowable/bpmn/model/Process.java +++ b/modules/flowable-bpmn-model/src/main/java/org/flowable/bpmn/model/Process.java @@ -138,8 +138,7 @@ public List findAssociationsWithSourceRefRecursive(String sourceRef protected List findAssociationsWithSourceRefRecursive(FlowElementsContainer flowElementsContainer, String sourceRef) { List associations = new ArrayList<>(); for (Artifact artifact : flowElementsContainer.getArtifacts()) { - if (artifact instanceof Association) { - Association association = (Association) artifact; + if (artifact instanceof Association association) { if (association.getSourceRef() != null && association.getTargetRef() != null && association.getSourceRef().equals(sourceRef)) { associations.add(association); } @@ -161,8 +160,7 @@ public List findAssociationsWithTargetRefRecursive(String targetRef protected List findAssociationsWithTargetRefRecursive(FlowElementsContainer flowElementsContainer, String targetRef) { List associations = new ArrayList<>(); for (Artifact artifact : flowElementsContainer.getArtifacts()) { - if (artifact instanceof Association) { - Association association = (Association) artifact; + if (artifact instanceof Association association) { if (association.getTargetRef() != null && association.getTargetRef().equals(targetRef)) { associations.add(association); } diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/BaseCmmnXmlConverter.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/BaseCmmnXmlConverter.java index 751589dac18..178805b7c97 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/BaseCmmnXmlConverter.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/BaseCmmnXmlConverter.java @@ -43,13 +43,11 @@ public BaseElement convertToCmmnModel(XMLStreamReader xtr, ConversionHelper conv baseElement.setId(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_ID)); CmmnXmlUtil.addXMLLocation(baseElement, xtr); - if (baseElement instanceof CmmnElement) { - CmmnElement cmmnElement = (CmmnElement) baseElement; + if (baseElement instanceof CmmnElement cmmnElement) { conversionHelper.setCurrentCmmnElement(cmmnElement); } - if (baseElement instanceof Criterion) { - Criterion criterion = (Criterion) baseElement; + if (baseElement instanceof Criterion criterion) { conversionHelper.getCmmnModel().addCriterion(criterion.getId(), criterion); } diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CaseRefExpressionXmlConverter.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CaseRefExpressionXmlConverter.java index 1bbcbd29ccc..80384e41e0f 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CaseRefExpressionXmlConverter.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CaseRefExpressionXmlConverter.java @@ -39,8 +39,7 @@ public boolean hasChildElements() { protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHelper) { try { String expression = xtr.getElementText(); - if (StringUtils.isNotEmpty(expression) && conversionHelper.getCurrentCmmnElement() instanceof CaseTask) { - CaseTask caseTask = (CaseTask) conversionHelper.getCurrentCmmnElement(); + if (StringUtils.isNotEmpty(expression) && conversionHelper.getCurrentCmmnElement() instanceof CaseTask caseTask) { caseTask.setCaseRefExpression(expression); } } catch (XMLStreamException e) { @@ -49,4 +48,4 @@ protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHe return null; } -} \ No newline at end of file +} diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnXmlConverter.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnXmlConverter.java index 039dede6331..70e6e5edc0c 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnXmlConverter.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnXmlConverter.java @@ -489,8 +489,7 @@ protected void processCriteria(CmmnModel cmmnModel, List criteria) { protected void processPlanFragment(CmmnModel cmmnModel, PlanFragment planFragment) { processPlanItems(cmmnModel, planFragment); - if (planFragment instanceof Stage) { - Stage stage = (Stage) planFragment; + if (planFragment instanceof Stage stage) { for (PlanItemDefinition planItemDefinition : stage.getPlanItemDefinitions()) { if (planItemDefinition instanceof PlanFragment) { processPlanFragment(cmmnModel, (PlanFragment) planItemDefinition); @@ -529,13 +528,11 @@ protected void procesPlanItem(CmmnModel cmmnModel, PlanItem planItem, PlanItemDe resolveExitCriteriaSentry(planItem); } - if (planItemDefinition instanceof Stage) { - Stage planItemStage = (Stage) planItemDefinition; + if (planItemDefinition instanceof Stage planItemStage) { planItemStage.setPlanItem(planItem); processPlanFragment(cmmnModel, planItemStage); - } else if (planItemDefinition instanceof ProcessTask) { - ProcessTask processTask = (ProcessTask) planItemDefinition; + } else if (planItemDefinition instanceof ProcessTask processTask) { if (processTask.getProcessRef() != null) { org.flowable.cmmn.model.Process process = cmmnModel.getProcessById(processTask.getProcessRef()); if (process != null) { @@ -543,8 +540,7 @@ protected void procesPlanItem(CmmnModel cmmnModel, PlanItem planItem, PlanItemDe } } - } else if (planItemDefinition instanceof DecisionTask) { - DecisionTask decisionTask = (DecisionTask) planItemDefinition; + } else if (planItemDefinition instanceof DecisionTask decisionTask) { if (decisionTask.getDecisionRef() != null) { org.flowable.cmmn.model.Decision decision = cmmnModel.getDecisionById(decisionTask.getDecisionRef()); if (decision != null) { @@ -552,8 +548,7 @@ protected void procesPlanItem(CmmnModel cmmnModel, PlanItem planItem, PlanItemDe } } - } else if (planItemDefinition instanceof TimerEventListener) { - TimerEventListener timerEventListener = (TimerEventListener) planItemDefinition; + } else if (planItemDefinition instanceof TimerEventListener timerEventListener) { String sourceRef = timerEventListener.getTimerStartTriggerSourceRef(); PlanItem startTriggerPlanItem = timerEventListener.getParentStage().findPlanItemInPlanFragmentOrUpwards(sourceRef); if (startTriggerPlanItem != null) { diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/DecisionRefExpressionXmlConverter.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/DecisionRefExpressionXmlConverter.java index 3c20df9dd02..5be20a6f51d 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/DecisionRefExpressionXmlConverter.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/DecisionRefExpressionXmlConverter.java @@ -39,8 +39,7 @@ public boolean hasChildElements() { protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHelper) { try { String expression = xtr.getElementText(); - if (StringUtils.isNotEmpty(expression) && conversionHelper.getCurrentCmmnElement() instanceof DecisionTask) { - DecisionTask decisionTask = (DecisionTask) conversionHelper.getCurrentCmmnElement(); + if (StringUtils.isNotEmpty(expression) && conversionHelper.getCurrentCmmnElement() instanceof DecisionTask decisionTask) { decisionTask.setDecisionRefExpression(expression); } } catch (XMLStreamException e) { diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/ExtensionElementsXMLConverter.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/ExtensionElementsXMLConverter.java index 3fa67f04b23..b4257854cae 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/ExtensionElementsXMLConverter.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/ExtensionElementsXMLConverter.java @@ -159,11 +159,10 @@ protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHe } protected void readCompletionNeutralRule(XMLStreamReader xtr, ConversionHelper conversionHelper) { - if (conversionHelper.getCurrentCmmnElement() instanceof PlanItemControl) { + if (conversionHelper.getCurrentCmmnElement() instanceof PlanItemControl planItemControl) { CompletionNeutralRule completionNeutralRule = new CompletionNeutralRule(); completionNeutralRule.setName(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_NAME)); - PlanItemControl planItemControl = (PlanItemControl) conversionHelper.getCurrentCmmnElement(); planItemControl.setCompletionNeutralRule(completionNeutralRule); readCommonXmlInfo(completionNeutralRule, xtr); @@ -205,12 +204,11 @@ protected void readCompletionNeutralRule(XMLStreamReader xtr, ConversionHelper c } protected void readParentCompletionRule(XMLStreamReader xtr, ConversionHelper conversionHelper) { - if (conversionHelper.getCurrentCmmnElement() instanceof PlanItemControl) { + if (conversionHelper.getCurrentCmmnElement() instanceof PlanItemControl planItemControl) { ParentCompletionRule parentCompletionRule = new ParentCompletionRule(); parentCompletionRule.setName(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_NAME)); parentCompletionRule.setType(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_TYPE)); - PlanItemControl planItemControl = (PlanItemControl) conversionHelper.getCurrentCmmnElement(); planItemControl.setParentCompletionRule(parentCompletionRule); readCommonXmlInfo(parentCompletionRule, xtr); @@ -218,15 +216,13 @@ protected void readParentCompletionRule(XMLStreamReader xtr, ConversionHelper co } protected void readReactivationRule(XMLStreamReader xtr, ConversionHelper conversionHelper) { - if (conversionHelper.getCurrentCmmnElement() instanceof PlanItemControl) { - PlanItemControl planItemControl = (PlanItemControl) conversionHelper.getCurrentCmmnElement(); + if (conversionHelper.getCurrentCmmnElement() instanceof PlanItemControl planItemControl) { planItemControl.setReactivationRule(readReactivationRule(xtr)); } } protected void readDefaultReactivationRule(XMLStreamReader xtr, ConversionHelper conversionHelper) { - if (conversionHelper.getCurrentCmmnElement() instanceof ReactivateEventListener) { - ReactivateEventListener reactivateEventListener = (ReactivateEventListener) conversionHelper.getCurrentCmmnElement(); + if (conversionHelper.getCurrentCmmnElement() instanceof ReactivateEventListener reactivateEventListener) { reactivateEventListener.setDefaultReactivationRule(readReactivationRule(xtr)); } } @@ -360,8 +356,7 @@ protected void readTaskListener(XMLStreamReader xtr, ConversionHelper conversion FlowableListener flowableListener = ListenerXmlConverterUtil.convertToListener(xtr); if (flowableListener != null) { - if (currentCmmnElement instanceof HumanTask) { - HumanTask humanTask = (HumanTask) currentCmmnElement; + if (currentCmmnElement instanceof HumanTask humanTask) { humanTask.getTaskListeners().add(flowableListener); } else { throw new FlowableException("Programmatic error: task listener added to an element that is not a human task, but a " + currentCmmnElement.getClass()); @@ -376,8 +371,7 @@ protected void readLifecycleListener(XMLStreamReader xtr, ConversionHelper conve FlowableListener flowableListener = ListenerXmlConverterUtil.convertToListener(xtr); if (flowableListener != null) { - if (currentCmmnElement instanceof HasLifecycleListeners) { - HasLifecycleListeners lifecycleListenersElement = (HasLifecycleListeners) currentCmmnElement; + if (currentCmmnElement instanceof HasLifecycleListeners lifecycleListenersElement) { lifecycleListenersElement.getLifecycleListeners().add(flowableListener); } else { throw new FlowableException("Programmatic error: lifecycle listener added to an element that is not a plan item definition, but a " + currentCmmnElement.getClass()); @@ -413,16 +407,13 @@ protected void readEventType(XMLStreamReader xtr, ConversionHelper conversionHel throw new FlowableException("Error while reading eventType element", e); } - if (currentCmmnElement instanceof Case) { - Case caze = (Case) currentCmmnElement; + if (currentCmmnElement instanceof Case caze) { caze.setStartEventType(eventType); - } else if (currentCmmnElement instanceof SendEventServiceTask) { - SendEventServiceTask sendEventServiceTask = (SendEventServiceTask) currentCmmnElement; + } else if (currentCmmnElement instanceof SendEventServiceTask sendEventServiceTask) { sendEventServiceTask.setEventType(eventType); - } else if (currentCmmnElement instanceof GenericEventListener) { - GenericEventListener genericEventListener = (GenericEventListener) currentCmmnElement; + } else if (currentCmmnElement instanceof GenericEventListener genericEventListener) { genericEventListener.setEventType(eventType); } else { @@ -433,8 +424,7 @@ protected void readEventType(XMLStreamReader xtr, ConversionHelper conversionHel protected void readVariableAggregationDefinition(XMLStreamReader xtr, ConversionHelper conversionHelper) { CmmnElement currentCmmnElement = conversionHelper.getCurrentCmmnElement(); - if (currentCmmnElement instanceof RepetitionRule) { - RepetitionRule repetitionRule = (RepetitionRule) currentCmmnElement; + if (currentCmmnElement instanceof RepetitionRule repetitionRule) { VariableAggregationDefinition aggregationDefinition = new VariableAggregationDefinition(); diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/ManualActivationRuleXmlConverter.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/ManualActivationRuleXmlConverter.java index b892301569f..c5ea1217e27 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/ManualActivationRuleXmlConverter.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/ManualActivationRuleXmlConverter.java @@ -35,12 +35,11 @@ public boolean hasChildElements() { @Override protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHelper) { - if (conversionHelper.getCurrentCmmnElement() instanceof PlanItemControl) { + if (conversionHelper.getCurrentCmmnElement() instanceof PlanItemControl planItemControl) { ManualActivationRule manualActivationRule = new ManualActivationRule(); manualActivationRule.setName(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_NAME)); - - PlanItemControl planItemControl = (PlanItemControl) conversionHelper.getCurrentCmmnElement(); + planItemControl.setManualActivationRule(manualActivationRule); return manualActivationRule; @@ -48,4 +47,4 @@ protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHe return null; } -} \ No newline at end of file +} diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/PlanItemStartTriggerXmlConverter.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/PlanItemStartTriggerXmlConverter.java index e2c5d163ea5..b09a7ad0a2d 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/PlanItemStartTriggerXmlConverter.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/PlanItemStartTriggerXmlConverter.java @@ -34,11 +34,10 @@ public boolean hasChildElements() { @Override protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHelper) { - if (conversionHelper.getCurrentCmmnElement() instanceof TimerEventListener) { - TimerEventListener timerEventListener = (TimerEventListener) conversionHelper.getCurrentCmmnElement(); + if (conversionHelper.getCurrentCmmnElement() instanceof TimerEventListener timerEventListener) { timerEventListener.setTimerStartTriggerSourceRef(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_PLAN_ITEM_START_TRIGGER_SRC_REF)); } return null; } -} \ No newline at end of file +} diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/ProcessRefExpressionXmlConverter.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/ProcessRefExpressionXmlConverter.java index 24d70be2230..0dcba456206 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/ProcessRefExpressionXmlConverter.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/ProcessRefExpressionXmlConverter.java @@ -39,8 +39,7 @@ public boolean hasChildElements() { protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHelper) { try { String expression = xtr.getElementText(); - if (StringUtils.isNotEmpty(expression) && conversionHelper.getCurrentCmmnElement() instanceof ProcessTask) { - ProcessTask processTask = (ProcessTask) conversionHelper.getCurrentCmmnElement(); + if (StringUtils.isNotEmpty(expression) && conversionHelper.getCurrentCmmnElement() instanceof ProcessTask processTask) { processTask.setProcessRefExpression(expression); } } catch (XMLStreamException e) { @@ -49,4 +48,4 @@ protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHe return null; } -} \ No newline at end of file +} diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/RepetitionRuleXmlConverter.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/RepetitionRuleXmlConverter.java index 2b2835971de..5c5bac0c979 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/RepetitionRuleXmlConverter.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/RepetitionRuleXmlConverter.java @@ -37,7 +37,7 @@ public boolean hasChildElements() { @Override protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHelper) { - if (conversionHelper.getCurrentCmmnElement() instanceof PlanItemControl) { + if (conversionHelper.getCurrentCmmnElement() instanceof PlanItemControl planItemControl) { RepetitionRule repetitionRule = new RepetitionRule(); repetitionRule.setName(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_NAME)); @@ -74,8 +74,7 @@ protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHe repetitionRule.setElementIndexVariableName(xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_REPETITION_ELEMENT_INDEX_VARIABLE_NAME)); - - PlanItemControl planItemControl = (PlanItemControl) conversionHelper.getCurrentCmmnElement(); + planItemControl.setRepetitionRule(repetitionRule); return repetitionRule; @@ -90,4 +89,4 @@ protected Integer parseInt(String value) { return Integer.parseInt(value); } -} \ No newline at end of file +} diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/RequiredRuleXmlConverter.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/RequiredRuleXmlConverter.java index ed3e4ca6bf8..b561fbe0910 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/RequiredRuleXmlConverter.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/RequiredRuleXmlConverter.java @@ -35,12 +35,11 @@ public boolean hasChildElements() { @Override protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHelper) { - if (conversionHelper.getCurrentCmmnElement() instanceof PlanItemControl) { + if (conversionHelper.getCurrentCmmnElement() instanceof PlanItemControl planItemControl) { RequiredRule requiredRule = new RequiredRule(); requiredRule.setName(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_NAME)); - - PlanItemControl planItemControl = (PlanItemControl) conversionHelper.getCurrentCmmnElement(); + planItemControl.setRequiredRule(requiredRule); return requiredRule; @@ -48,4 +47,4 @@ protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHe return null; } -} \ No newline at end of file +} diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/StandardEventXmlConverter.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/StandardEventXmlConverter.java index 1577516949d..25c8173732d 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/StandardEventXmlConverter.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/StandardEventXmlConverter.java @@ -38,8 +38,7 @@ public boolean hasChildElements() { protected BaseElement convert(XMLStreamReader xtr, ConversionHelper conversionHelper) { try { String event = xtr.getElementText(); - if (conversionHelper.getCurrentCmmnElement() instanceof TimerEventListener) { - TimerEventListener timerEventListener = (TimerEventListener) conversionHelper.getCurrentCmmnElement(); + if (conversionHelper.getCurrentCmmnElement() instanceof TimerEventListener timerEventListener) { timerEventListener.setTimerStartTriggerStandardEvent(event); } else { conversionHelper.getCurrentSentryOnPart().setStandardEvent(event); @@ -50,4 +49,4 @@ protected BaseElement convert(XMLStreamReader xtr, ConversionHelper conversionHe return null; } -} \ No newline at end of file +} diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/TextXmlConverter.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/TextXmlConverter.java index 62133358156..7b10e0304de 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/TextXmlConverter.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/TextXmlConverter.java @@ -38,8 +38,7 @@ public boolean hasChildElements() { protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHelper) { CmmnElement currentCmmnElement = conversionHelper.getCurrentCmmnElement(); try { - if (currentCmmnElement instanceof TextAnnotation) { - TextAnnotation textAnnotation = (TextAnnotation) currentCmmnElement; + if (currentCmmnElement instanceof TextAnnotation textAnnotation) { textAnnotation.setText(xtr.getElementText()); } } catch (XMLStreamException e) { @@ -49,4 +48,4 @@ protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHe return null; } -} \ No newline at end of file +} diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/TimerExpressionXmlConverter.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/TimerExpressionXmlConverter.java index 0d079f1f621..4b827a22ade 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/TimerExpressionXmlConverter.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/TimerExpressionXmlConverter.java @@ -39,8 +39,7 @@ public boolean hasChildElements() { protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHelper) { try { String expression = xtr.getElementText(); - if (StringUtils.isNotEmpty(expression) && conversionHelper.getCurrentCmmnElement() instanceof TimerEventListener) { - TimerEventListener timerEventListener = (TimerEventListener) conversionHelper.getCurrentCmmnElement(); + if (StringUtils.isNotEmpty(expression) && conversionHelper.getCurrentCmmnElement() instanceof TimerEventListener timerEventListener) { timerEventListener.setTimerExpression(expression); } } catch (XMLStreamException e) { @@ -49,4 +48,4 @@ protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHe return null; } -} \ No newline at end of file +} diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/export/TaskExport.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/export/TaskExport.java index 9cc503f257e..7612e575f33 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/export/TaskExport.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/export/TaskExport.java @@ -55,8 +55,7 @@ protected static void writeCommonTaskAttributes(T task, XMLStre xtw.writeAttribute(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE, ATTRIBUTE_IS_ASYNCHRONOUS_LEAVE_EXCLUSIVE, String.valueOf(asyncLeaveExclusive)); } - if (task instanceof SendEventServiceTask) { - SendEventServiceTask sendEventServiceTask = (SendEventServiceTask) task; + if (task instanceof SendEventServiceTask sendEventServiceTask) { if (StringUtils.isNotEmpty(sendEventServiceTask.getEventType()) && sendEventServiceTask.getExtensionElements().get("eventType") == null) { ExtensionElement extensionElement = new ExtensionElement(); extensionElement.setNamespace(FLOWABLE_EXTENSIONS_NAMESPACE); diff --git a/modules/flowable-cmmn-converter/src/test/java/org/flowable/test/cmmn/converter/PlanFragmentCmmnXmlConverterTest.java b/modules/flowable-cmmn-converter/src/test/java/org/flowable/test/cmmn/converter/PlanFragmentCmmnXmlConverterTest.java index c7ae6e70638..adb5d3bbdf3 100644 --- a/modules/flowable-cmmn-converter/src/test/java/org/flowable/test/cmmn/converter/PlanFragmentCmmnXmlConverterTest.java +++ b/modules/flowable-cmmn-converter/src/test/java/org/flowable/test/cmmn/converter/PlanFragmentCmmnXmlConverterTest.java @@ -134,8 +134,7 @@ protected void assertNoChildPlanItems(List planItems, String name) { assertThat(planItem).isNotNull(); PlanItemDefinition planItemDefinition = planItem.getPlanItemDefinition(); - if (planItemDefinition instanceof PlanFragment) { - PlanFragment planFragment = (PlanFragment) planItemDefinition; + if (planItemDefinition instanceof PlanFragment planFragment) { assertThat(planFragment.getPlanItems()).isEmpty(); } } diff --git a/modules/flowable-cmmn-engine-configurator/src/main/java/org/flowable/cmmn/engine/configurator/impl/process/DefaultProcessInstanceService.java b/modules/flowable-cmmn-engine-configurator/src/main/java/org/flowable/cmmn/engine/configurator/impl/process/DefaultProcessInstanceService.java index f74fd3b3504..d7738ae1d21 100644 --- a/modules/flowable-cmmn-engine-configurator/src/main/java/org/flowable/cmmn/engine/configurator/impl/process/DefaultProcessInstanceService.java +++ b/modules/flowable-cmmn-engine-configurator/src/main/java/org/flowable/cmmn/engine/configurator/impl/process/DefaultProcessInstanceService.java @@ -125,15 +125,14 @@ public List getOutputParametersOfCaseTask(String executionId) { } FlowElement flowElement = execution.getCurrentFlowElement(); - if (!(flowElement instanceof CaseServiceTask)) { + if (!(flowElement instanceof CaseServiceTask caseServiceTask)) { // The execution already processed this stage, there is no need to copy parameters anymore. // One possible reason for this is that the case task was terminated by a boundary event. return Collections.emptyList(); } List cmmnParameters = new ArrayList<>(); - - CaseServiceTask caseServiceTask = (CaseServiceTask) flowElement; + List parameters = caseServiceTask.getOutParameters(); for (org.flowable.bpmn.model.IOParameter ioParameter : parameters) { IOParameter parameter = new IOParameter(); diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/agenda/operation/AbstractEvaluationCriteriaOperation.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/agenda/operation/AbstractEvaluationCriteriaOperation.java index 164e815a6ed..5092a64f71b 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/agenda/operation/AbstractEvaluationCriteriaOperation.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/agenda/operation/AbstractEvaluationCriteriaOperation.java @@ -143,7 +143,7 @@ public boolean evaluateForCompletion(PlanItemInstanceEntity planItemInstanceEnti CommandContextUtil.getAgenda(commandContext).planExitPlanItemInstanceOperation(planItemInstanceEntity, satisfiedExitCriterion.getId(), satisfiedExitCriterion.getExitType(), satisfiedExitCriterion.getExitEventType()); - } else if (planItem.getPlanItemDefinition() instanceof Stage) { + } else if (planItem.getPlanItemDefinition() instanceof Stage stage) { if (PlanItemInstanceState.ACTIVE.equals(state)) { @@ -153,7 +153,6 @@ public boolean evaluateForCompletion(PlanItemInstanceEntity planItemInstanceEnti evaluationResult.markCriteriaChanged(); planItemInstanceEntity.setCompletable(false); // an active child = stage cannot be completed anymore } else { - Stage stage = (Stage) planItem.getPlanItemDefinition(); if (isStageCompletable(planItemInstanceEntity, stage)) { evaluationResult.markCriteriaChanged(); CommandContextUtil.getAgenda(commandContext).planCompletePlanItemInstanceOperation(planItemInstanceEntity); @@ -203,11 +202,10 @@ protected boolean evaluatePlanItemsCriteria(PlanItemInstanceContainer planItemIn List planItemInstances = planItemInstanceContainer.getChildPlanItemInstances(); // needed because when doing case instance migration the child plan item instances can be null - if ((planItemInstances == null || (migrationContext != null && migrationContext.isFetchPlanItemInstances())) && - planItemInstanceContainer instanceof CaseInstanceEntity) { + if ((planItemInstances == null || (migrationContext != null && migrationContext.isFetchPlanItemInstances())) && + planItemInstanceContainer instanceof CaseInstanceEntity caseInstance) { PlanItemInstanceEntityManager planItemInstanceEntityManager = CommandContextUtil.getPlanItemInstanceEntityManager(commandContext); - CaseInstanceEntity caseInstance = (CaseInstanceEntity) planItemInstanceContainer; planItemInstances = planItemInstanceEntityManager.findByCaseInstanceId(caseInstance.getId()); planItemInstanceContainer.setChildPlanItemInstances(planItemInstances); @@ -693,8 +691,7 @@ protected SentryPartInstanceEntity createSentryPartInstanceEntity(EntityWithSent if (entityWithSentryPartInstances instanceof CaseInstanceEntity) { sentryPartInstanceEntity.setCaseInstanceId(((CaseInstanceEntity) entityWithSentryPartInstances).getId()); sentryPartInstanceEntity.setCaseDefinitionId(((CaseInstanceEntity) entityWithSentryPartInstances).getCaseDefinitionId()); - } else if (entityWithSentryPartInstances instanceof PlanItemInstanceEntity) { - PlanItemInstanceEntity planItemInstanceEntity = (PlanItemInstanceEntity) entityWithSentryPartInstances; + } else if (entityWithSentryPartInstances instanceof PlanItemInstanceEntity planItemInstanceEntity) { sentryPartInstanceEntity.setCaseInstanceId(planItemInstanceEntity.getCaseInstanceId()); sentryPartInstanceEntity.setCaseDefinitionId(planItemInstanceEntity.getCaseDefinitionId()); sentryPartInstanceEntity.setPlanItemInstanceId(planItemInstanceEntity.getId()); diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/agenda/operation/ActivatePlanItemInstanceOperation.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/agenda/operation/ActivatePlanItemInstanceOperation.java index 1587febf1a5..9e812534f8b 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/agenda/operation/ActivatePlanItemInstanceOperation.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/agenda/operation/ActivatePlanItemInstanceOperation.java @@ -71,8 +71,7 @@ protected boolean evaluateManualActivationRule() { } public boolean isAsync() { - if (planItemInstanceEntity.getPlanItem().getPlanItemDefinition() instanceof Task) { - Task task = (Task) planItemInstanceEntity.getPlanItem().getPlanItemDefinition(); + if (planItemInstanceEntity.getPlanItem().getPlanItemDefinition() instanceof Task task) { if (task.isAsync()) { return true; } diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/agenda/operation/CmmnOperation.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/agenda/operation/CmmnOperation.java index e4f8f2e6fbf..8c0a709244d 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/agenda/operation/CmmnOperation.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/agenda/operation/CmmnOperation.java @@ -128,9 +128,8 @@ protected List createPlanItemInstancesForNewOrReactivate stagePlanItemInstanceEntity, tenantId, newPlanItemInstances); } - } else if (planItem.getPlanItemDefinition() != null && planItem.getPlanItemDefinition() instanceof PlanFragment) { + } else if (planItem.getPlanItemDefinition() != null && planItem.getPlanItemDefinition() instanceof PlanFragment planFragment) { // Some plan items (plan fragments) exist as plan item, but not as plan item instance - PlanFragment planFragment = (PlanFragment) planItem.getPlanItemDefinition(); List planFragmentPlanItems = planFragment.getDirectChildPlanItemsWithLifecycleEnabled(); for (PlanItem planFragmentPlanItem : planFragmentPlanItems) { createPlanItemInstanceIfNeeded(commandContext, planFragmentPlanItem, caseModel, caseInstanceEntity, @@ -224,8 +223,7 @@ protected boolean childPlanItemInstanceForPlanItemExists(PlanItemInstanceContain } public boolean isEventListenerWithAvailableCondition(PlanItem planItem) { - if (planItem != null && planItem.getPlanItemDefinition() != null && planItem.getPlanItemDefinition() instanceof EventListener) { - EventListener eventListener = (EventListener) planItem.getPlanItemDefinition(); + if (planItem != null && planItem.getPlanItemDefinition() != null && planItem.getPlanItemDefinition() instanceof EventListener eventListener) { return StringUtils.isNotEmpty(eventListener.getAvailableConditionExpression()); } return false; @@ -350,4 +348,4 @@ public boolean isNoop() { return isNoop; } -} \ No newline at end of file +} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/DecisionTaskActivityBehavior.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/DecisionTaskActivityBehavior.java index e09897e8e98..63915019371 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/DecisionTaskActivityBehavior.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/DecisionTaskActivityBehavior.java @@ -135,8 +135,7 @@ public void execute(CommandContext commandContext, PlanItemInstanceEntity planIt } if (cmmnEngineConfiguration.getDecisionTableVariableManager() != null) { - if (decisionExecutionAuditContainer instanceof DecisionServiceExecutionAuditContainer) { - DecisionServiceExecutionAuditContainer decisionServiceExecutionAuditContainer = (DecisionServiceExecutionAuditContainer) decisionExecutionAuditContainer; + if (decisionExecutionAuditContainer instanceof DecisionServiceExecutionAuditContainer decisionServiceExecutionAuditContainer) { cmmnEngineConfiguration.getDecisionTableVariableManager().setDecisionServiceVariablesOnPlanItemInstance(decisionServiceExecutionAuditContainer.getDecisionServiceResult(), externalRef, planItemInstanceEntity, cmmnEngineConfiguration.getObjectMapper(), decisionExecutionAuditContainer.isMultipleResults()); } else { @@ -146,8 +145,7 @@ public void execute(CommandContext commandContext, PlanItemInstanceEntity planIt } else { boolean multipleResults = decisionExecutionAuditContainer.isMultipleResults() && cmmnEngineConfiguration.isAlwaysUseArraysForDmnMultiHitPolicies(); - if (decisionExecutionAuditContainer instanceof DecisionServiceExecutionAuditContainer) { - DecisionServiceExecutionAuditContainer decisionServiceExecutionAuditContainer = (DecisionServiceExecutionAuditContainer) decisionExecutionAuditContainer; + if (decisionExecutionAuditContainer instanceof DecisionServiceExecutionAuditContainer decisionServiceExecutionAuditContainer) { setDecisionServiceVariablesOnPlanItemInstance(decisionServiceExecutionAuditContainer.getDecisionServiceResult(), externalRef, planItemInstanceEntity, cmmnEngineConfiguration.getObjectMapper(), multipleResults); } else { diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/HumanTaskActivityBehavior.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/HumanTaskActivityBehavior.java index d393296bb7a..36c74598645 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/HumanTaskActivityBehavior.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/HumanTaskActivityBehavior.java @@ -290,8 +290,7 @@ protected void handleDueDate(CommandContext commandContext, PlanItemInstanceEnti if (dueDate instanceof Date) { taskEntity.setDueDate((Date) dueDate); - } else if (dueDate instanceof String) { - String dueDateString = (String) dueDate; + } else if (dueDate instanceof String dueDateString) { Date resolvedDuedate = CommandContextUtil.getCmmnEngineConfiguration(commandContext).getBusinessCalendarManager() .getBusinessCalendar(DueDateBusinessCalendar.NAME) .resolveDuedate(dueDateString); diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/TimerEventListenerActivityBehaviour.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/TimerEventListenerActivityBehaviour.java index 6cd56ddecbb..7e02ee55e04 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/TimerEventListenerActivityBehaviour.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/TimerEventListenerActivityBehaviour.java @@ -101,15 +101,13 @@ protected void handleCreateTransition(CommandContext commandContext, PlanItemIns if (timerValue instanceof Date) { timerDueDate = (Date) timerValue; - } else if (timerValue instanceof DateTime) { + } else if (timerValue instanceof DateTime timerDateTime) { JodaDeprecationLogger.LOGGER.warn( "Using Joda-Time DateTime has been deprecated and will be removed in a future version. Timer event listener expression {} in {} resolved to a Joda-Time DateTime. ", timerEventListener.getTimerExpression(), planItemInstance); - DateTime timerDateTime = (DateTime) timerValue; timerDueDate = timerDateTime.toDate(); - } else if (timerValue instanceof String) { - String timerString = (String) timerValue; + } else if (timerValue instanceof String timerString) { BusinessCalendarManager businessCalendarManager = CommandContextUtil.getCmmnEngineConfiguration(commandContext).getBusinessCalendarManager(); if (isDurationString(timerString)) { diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/callback/DefaultInternalCmmnJobManager.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/callback/DefaultInternalCmmnJobManager.java index c2fffa80610..b43019f9d1e 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/callback/DefaultInternalCmmnJobManager.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/callback/DefaultInternalCmmnJobManager.java @@ -164,8 +164,7 @@ protected void preRepeatedTimerScheduleInternal(TimerJobEntity timerJobEntity, V // In CMMN (and contrary to BPMN), when a timer is repeated a new plan item instance needs to be created // as the original one is removed when the timer event has occurred. - if (variableScope instanceof PlanItemInstanceEntity) { - PlanItemInstanceEntity planItemInstanceEntity = (PlanItemInstanceEntity) variableScope; + if (variableScope instanceof PlanItemInstanceEntity planItemInstanceEntity) { PlanItemInstance stagePlanItem = planItemInstanceEntity.getStagePlanItemInstanceEntity(); if (stagePlanItem == null && planItemInstanceEntity.getStageInstanceId() != null) { @@ -199,8 +198,7 @@ protected void preRepeatedTimerScheduleInternal(TimerJobEntity timerJobEntity, V // Switch job references to new plan item instance timerJobEntity.setSubScopeId(newPlanItemInstanceEntity.getId()); - if (planItem != null && planItem.getPlanItemDefinition() != null && planItem.getPlanItemDefinition() instanceof TimerEventListener) { - TimerEventListener timerEventListener = (TimerEventListener) planItem.getPlanItemDefinition(); + if (planItem != null && planItem.getPlanItemDefinition() != null && planItem.getPlanItemDefinition() instanceof TimerEventListener timerEventListener) { timerJobEntity.setElementId(timerEventListener.getId()); timerJobEntity.setElementName(timerEventListener.getName()); } diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/el/PlanItemInstancesWrapper.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/el/PlanItemInstancesWrapper.java index 8a09bf510be..e9828de3d06 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/el/PlanItemInstancesWrapper.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/el/PlanItemInstancesWrapper.java @@ -43,8 +43,7 @@ public class PlanItemInstancesWrapper { public PlanItemInstancesWrapper(VariableContainer variableContainer) { this.variableContainer = variableContainer; - if (variableContainer instanceof PlanItemInstanceEntity) { - PlanItemInstanceEntity planItemInstanceEntity = (PlanItemInstanceEntity) variableContainer; + if (variableContainer instanceof PlanItemInstanceEntity planItemInstanceEntity) { caseInstanceEntity = CommandContextUtil.getCaseInstanceEntityManager().findById(planItemInstanceEntity.getCaseInstanceId()); } else if (variableContainer instanceof CaseInstanceEntity) { @@ -128,8 +127,7 @@ public List getDefinitionNames() { public PlanItemInstancesWrapper currentStage() { PlanItemInstanceContainer stageContainer = null; - if (variableContainer instanceof PlanItemInstanceEntity) { - PlanItemInstanceEntity planItemInstanceEntity = (PlanItemInstanceEntity) variableContainer; + if (variableContainer instanceof PlanItemInstanceEntity planItemInstanceEntity) { PlanItemInstanceEntity stagePlanItemInstanceEntity = planItemInstanceEntity.getStagePlanItemInstanceEntity(); if (stagePlanItemInstanceEntity != null) { stageContainer = stagePlanItemInstanceEntity; diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/function/IsPlanItemCompletedExpressionFunction.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/function/IsPlanItemCompletedExpressionFunction.java index ae391a8e024..db7e3fdb822 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/function/IsPlanItemCompletedExpressionFunction.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/function/IsPlanItemCompletedExpressionFunction.java @@ -71,8 +71,7 @@ public AstFunction createFunction(String name, int index, AstParameters paramete } public static boolean isPlanItemCompleted(Object object) { - if (object instanceof PlanItemInstanceEntity) { - PlanItemInstanceEntity planItemInstanceEntity = (PlanItemInstanceEntity) object; + if (object instanceof PlanItemInstanceEntity planItemInstanceEntity) { CaseInstanceEntity caseInstanceEntity = CommandContextUtil.getCaseInstanceEntityManager().findById(planItemInstanceEntity.getCaseInstanceId()); List planItemInstances = caseInstanceEntity.getChildPlanItemInstances(); if (planItemInstances == null) { diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/function/IsStageCompletableExpressionFunction.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/function/IsStageCompletableExpressionFunction.java index e90f86524e1..b9e54f552dc 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/function/IsStageCompletableExpressionFunction.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/function/IsStageCompletableExpressionFunction.java @@ -73,8 +73,7 @@ public AstFunction createFunction(String name, int index, AstParameters paramete } public static boolean isStageCompletable(Object object) { - if (object instanceof PlanItemInstanceEntity) { - PlanItemInstanceEntity planItemInstanceEntity = (PlanItemInstanceEntity) object; + if (object instanceof PlanItemInstanceEntity planItemInstanceEntity) { if (planItemInstanceEntity.isStage()) { return planItemInstanceEntity.isCompletable(); @@ -104,8 +103,7 @@ public static boolean isStageCompletable(Object object) { } - } else if (object instanceof CaseInstanceEntity) { - CaseInstanceEntity caseInstanceEntity = (CaseInstanceEntity) object; + } else if (object instanceof CaseInstanceEntity caseInstanceEntity) { return caseInstanceEntity.isCompletable(); } diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/DefaultCmmnHistoryManager.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/DefaultCmmnHistoryManager.java index ef6320023f8..06ec4abb9b5 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/DefaultCmmnHistoryManager.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/DefaultCmmnHistoryManager.java @@ -492,13 +492,11 @@ public boolean evaluateShowInOverview(PlanItemInstanceEntity planItemInstanceEnt PlanItemDefinition planItemDefinition = planItemInstanceEntity.getPlanItem().getPlanItemDefinition(); String includeInStageOverviewValue = null; if (planItemInstanceEntity.isStage()) { - if (planItemDefinition instanceof Stage) { - Stage stage = (Stage) planItemDefinition; + if (planItemDefinition instanceof Stage stage) { includeInStageOverviewValue = stage.getIncludeInStageOverview(); } - } else if (planItemDefinition instanceof Milestone) { - Milestone milestone = (Milestone) planItemDefinition; + } else if (planItemDefinition instanceof Milestone milestone) { includeInStageOverviewValue = milestone.getIncludeInStageOverview(); } diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/interceptor/CmmnCommandInvoker.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/interceptor/CmmnCommandInvoker.java index bad5fa0f2b7..b4b347d0ccd 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/interceptor/CmmnCommandInvoker.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/interceptor/CmmnCommandInvoker.java @@ -137,8 +137,7 @@ protected void executeExecutionListenersAfterException(CommandContext commandCon protected void executeOperation(CommandContext commandContext, boolean isStoreCaseInstanceIdOfNoOperation, Runnable runnable) { - if (runnable instanceof CmmnOperation) { - CmmnOperation operation = (CmmnOperation) runnable; + if (runnable instanceof CmmnOperation operation) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Executing agenda operation {}", runnable); diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/job/AsyncActivatePlanItemInstanceJobHandler.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/job/AsyncActivatePlanItemInstanceJobHandler.java index 634e0b1b477..011bf89653d 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/job/AsyncActivatePlanItemInstanceJobHandler.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/job/AsyncActivatePlanItemInstanceJobHandler.java @@ -37,8 +37,7 @@ public String getType() { @Override public void execute(JobEntity job, String configuration, VariableScope variableScope, CommandContext commandContext) { - if (variableScope instanceof PlanItemInstanceEntity) { - PlanItemInstanceEntity planItemInstanceEntity = (PlanItemInstanceEntity) variableScope; + if (variableScope instanceof PlanItemInstanceEntity planItemInstanceEntity) { CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext); if (cmmnEngineConfiguration.isLoggingSessionEnabled()) { CmmnLoggingSessionUtil.addAsyncActivityLoggingData("Executing async job for " + planItemInstanceEntity.getPlanItemDefinitionId() + ", with job id " + job.getId(), diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/job/AsyncLeaveActivePlanItemInstanceJobHandler.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/job/AsyncLeaveActivePlanItemInstanceJobHandler.java index fe239023118..289a7b63601 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/job/AsyncLeaveActivePlanItemInstanceJobHandler.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/job/AsyncLeaveActivePlanItemInstanceJobHandler.java @@ -41,8 +41,7 @@ public String getType() { @Override public void execute(JobEntity job, String configuration, VariableScope variableScope, CommandContext commandContext) { - if (variableScope instanceof PlanItemInstanceEntity) { - PlanItemInstanceEntity planItemInstanceEntity = (PlanItemInstanceEntity) variableScope; + if (variableScope instanceof PlanItemInstanceEntity planItemInstanceEntity) { CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext); if (cmmnEngineConfiguration.isLoggingSessionEnabled()) { CmmnLoggingSessionUtil.addAsyncActivityLoggingData("Executing async job for " + planItemInstanceEntity.getPlanItemDefinitionId() + ", with job id " + job.getId(), diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/listener/CmmnListenerNotificationHelper.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/listener/CmmnListenerNotificationHelper.java index cc3ee3465bb..e9d7b9856af 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/listener/CmmnListenerNotificationHelper.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/listener/CmmnListenerNotificationHelper.java @@ -41,8 +41,7 @@ public void executeTaskListeners(TaskEntity taskEntity, String eventType) { if (taskEntity.getScopeDefinitionId() != null) { CmmnModel cmmnModel = CaseDefinitionUtil.getCmmnModel(taskEntity.getScopeDefinitionId()); CaseElement caseElement = cmmnModel.getPrimaryCase().getAllCaseElements().get(taskEntity.getTaskDefinitionKey()); - if (caseElement instanceof HumanTask) { - HumanTask humanTask = (HumanTask) caseElement; + if (caseElement instanceof HumanTask humanTask) { executeTaskListeners(humanTask, taskEntity, eventType); } } diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/listener/DelegateExpressionCaseLifecycleListener.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/listener/DelegateExpressionCaseLifecycleListener.java index e209e714fc0..506b0f53f4a 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/listener/DelegateExpressionCaseLifecycleListener.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/listener/DelegateExpressionCaseLifecycleListener.java @@ -55,8 +55,7 @@ public void stateChanged(CaseInstance caseInstance, String oldState, String newS CaseInstanceEntity caseInstanceEntity = (CaseInstanceEntity) caseInstance; Object delegate = DelegateExpressionUtil.resolveDelegateExpression(expression, caseInstanceEntity, fieldExtensions); - if (delegate instanceof CaseInstanceLifecycleListener) { - CaseInstanceLifecycleListener listener = (CaseInstanceLifecycleListener) delegate; + if (delegate instanceof CaseInstanceLifecycleListener listener) { listener.stateChanged(caseInstanceEntity, oldState, newState); } else { throw new FlowableIllegalArgumentException("Delegate expression " + expression + " did not resolve to an implementation of " + CaseInstanceLifecycleListener.class); diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/listener/DelegateExpressionPlanItemLifecycleListener.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/listener/DelegateExpressionPlanItemLifecycleListener.java index bc518da3986..59b3664c928 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/listener/DelegateExpressionPlanItemLifecycleListener.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/listener/DelegateExpressionPlanItemLifecycleListener.java @@ -53,8 +53,7 @@ public String getTargetState() { public void stateChanged(DelegatePlanItemInstance planItemInstance, String oldState, String newState) { Object delegate = DelegateExpressionUtil.resolveDelegateExpression(expression, planItemInstance, fieldExtensions); - if (delegate instanceof PlanItemInstanceLifecycleListener) { - PlanItemInstanceLifecycleListener listener = (PlanItemInstanceLifecycleListener) delegate; + if (delegate instanceof PlanItemInstanceLifecycleListener listener) { listener.stateChanged(planItemInstance, oldState, newState); } else { throw new FlowableIllegalArgumentException("Delegate expression " + expression + " did not resolve to an implementation of " + PlanItemInstanceLifecycleListener.class); diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/listener/DelegateExpressionTaskListener.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/listener/DelegateExpressionTaskListener.java index 7dac0780ae5..5755c5a638a 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/listener/DelegateExpressionTaskListener.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/listener/DelegateExpressionTaskListener.java @@ -38,8 +38,7 @@ public DelegateExpressionTaskListener(Expression expression, List handlers = null; - if (baseElement instanceof PlanItem) { + if (baseElement instanceof PlanItem planItem) { // The plan item definition defines the actual behavior - PlanItem planItem = (PlanItem) baseElement; handlers = parseHandlers.get(planItem.getPlanItemDefinition().getClass()); if (handlers == null) { diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/parser/handler/AbstractPlanItemParseHandler.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/parser/handler/AbstractPlanItemParseHandler.java index f5dd71c1254..2e74f918dc5 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/parser/handler/AbstractPlanItemParseHandler.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/parser/handler/AbstractPlanItemParseHandler.java @@ -25,11 +25,10 @@ public abstract class AbstractPlanItemParseHandler extend @Override protected void executeParse(CmmnParserImpl cmmnParser, CmmnParseResult cmmnParseResult, T element) { - if (!(element instanceof PlanItem)) { + if (!(element instanceof PlanItem planItem)) { throw new FlowableException("Programmatic error: passed element is not a PlanItem instance, but an instance of " + element.getClass()); } - PlanItem planItem = (PlanItem) element; executePlanItemParse(cmmnParser, cmmnParseResult, planItem, (T) planItem.getPlanItemDefinition()); } diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/runtime/AbstractCmmnDynamicStateManager.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/runtime/AbstractCmmnDynamicStateManager.java index 13d2fe3a322..2362a4acb5a 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/runtime/AbstractCmmnDynamicStateManager.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/runtime/AbstractCmmnDynamicStateManager.java @@ -908,10 +908,8 @@ protected void navigatePlanItemInstances(Map events = new ArrayList<>(); listener.eventConsumer = (flowableEvent) -> { - if (flowableEvent instanceof FlowableCaseEndedEvent) { - FlowableCaseEndedEvent caseEndedEvent = (FlowableCaseEndedEvent) flowableEvent; + if (flowableEvent instanceof FlowableCaseEndedEvent caseEndedEvent) { CaseInstance eventCaseInstance = caseEndedEvent.getEntity(); assertThat(eventCaseInstance.getBusinessKey()).isEqualTo("business key"); assertThat(eventCaseInstance.getName()).isEqualTo("name"); @@ -105,8 +104,7 @@ public void testCaseInstanceEndedEvent() { public void testCaseInstanceEndWithTerminationEvent() { List events = new ArrayList<>(); listener.eventConsumer = (flowableEvent) -> { - if (flowableEvent instanceof FlowableCaseEndedEvent) { - FlowableCaseEndedEvent caseEndedEvent = (FlowableCaseEndedEvent) flowableEvent; + if (flowableEvent instanceof FlowableCaseEndedEvent caseEndedEvent) { CaseInstance eventCaseInstance = caseEndedEvent.getEntity(); assertThat(eventCaseInstance.getBusinessKey()).isEqualTo("business key"); assertThat(eventCaseInstance.getName()).isEqualTo("name"); @@ -151,8 +149,7 @@ public void testCaseInstanceEndWithTerminationEvent() { public void testSubCaseEndedEvents() { List events = new ArrayList<>(); listener.eventConsumer = (flowableEvent) -> { - if (flowableEvent instanceof FlowableCaseEndedEvent) { - FlowableCaseEndedEvent caseEndedEvent = (FlowableCaseEndedEvent) flowableEvent; + if (flowableEvent instanceof FlowableCaseEndedEvent caseEndedEvent) { CaseInstance eventCaseInstance = caseEndedEvent.getEntity(); assertThat(caseEndedEvent.getProcessInstanceId()).isNull(); assertThat(caseEndedEvent.getExecutionId()).isNull(); @@ -213,8 +210,7 @@ public void testSubCaseEndedEvents() { public void testSubCaseEndedWithManualTriggerEvents() { List events = new ArrayList<>(); listener.eventConsumer = (flowableEvent) -> { - if (flowableEvent instanceof FlowableCaseEndedEvent) { - FlowableCaseEndedEvent caseEndedEvent = (FlowableCaseEndedEvent) flowableEvent; + if (flowableEvent instanceof FlowableCaseEndedEvent caseEndedEvent) { CaseInstance eventCaseInstance = caseEndedEvent.getEntity(); assertThat(caseEndedEvent.getProcessInstanceId()).isNull(); assertThat(caseEndedEvent.getExecutionId()).isNull(); @@ -269,8 +265,7 @@ public void testSubCaseEndedWithManualTriggerEvents() { public void testSubCaseEndedWithTerminationEvents() { List events = new ArrayList<>(); listener.eventConsumer = (flowableEvent) -> { - if (flowableEvent instanceof FlowableCaseEndedEvent) { - FlowableCaseEndedEvent caseEndedEvent = (FlowableCaseEndedEvent) flowableEvent; + if (flowableEvent instanceof FlowableCaseEndedEvent caseEndedEvent) { CaseInstance eventCaseInstance = caseEndedEvent.getEntity(); assertThat(caseEndedEvent.getProcessInstanceId()).isNull(); assertThat(caseEndedEvent.getExecutionId()).isNull(); diff --git a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/event/CaseStageEndedEventTest.java b/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/event/CaseStageEndedEventTest.java index 65df6e063f5..142039af32c 100644 --- a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/event/CaseStageEndedEventTest.java +++ b/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/event/CaseStageEndedEventTest.java @@ -56,8 +56,7 @@ public void tearDown() { public void testCaseStageCompletedEvents() { List events = new ArrayList<>(); stageListener.eventConsumer = (flowableEvent) -> { - if (flowableEvent instanceof FlowableCaseStageEndedEvent) { - FlowableCaseStageEndedEvent caseStageEndedEvent = (FlowableCaseStageEndedEvent) flowableEvent; + if (flowableEvent instanceof FlowableCaseStageEndedEvent caseStageEndedEvent) { CaseInstance eventCaseInstance = caseStageEndedEvent.getCaseInstance(); assertThat(caseStageEndedEvent.getProcessInstanceId()).isNull(); assertThat(caseStageEndedEvent.getExecutionId()).isNull(); @@ -102,8 +101,7 @@ public void testCaseStageCompletedEvents() { public void testCaseStageForceCompletedEvents() { List events = new ArrayList<>(); stageListener.eventConsumer = (flowableEvent) -> { - if (flowableEvent instanceof FlowableCaseStageEndedEvent) { - FlowableCaseStageEndedEvent caseStageEndedEvent = (FlowableCaseStageEndedEvent) flowableEvent; + if (flowableEvent instanceof FlowableCaseStageEndedEvent caseStageEndedEvent) { CaseInstance eventCaseInstance = caseStageEndedEvent.getCaseInstance(); assertThat(caseStageEndedEvent.getProcessInstanceId()).isNull(); assertThat(caseStageEndedEvent.getExecutionId()).isNull(); @@ -145,8 +143,7 @@ public void testCaseStageForceCompletedEvents() { public void testCaseStageForceCompletedAfterSubStageCompletedEvents() { List events = new ArrayList<>(); stageListener.eventConsumer = (flowableEvent) -> { - if (flowableEvent instanceof FlowableCaseStageEndedEvent) { - FlowableCaseStageEndedEvent caseStageEndedEvent = (FlowableCaseStageEndedEvent) flowableEvent; + if (flowableEvent instanceof FlowableCaseStageEndedEvent caseStageEndedEvent) { CaseInstance eventCaseInstance = caseStageEndedEvent.getCaseInstance(); assertThat(caseStageEndedEvent.getProcessInstanceId()).isNull(); assertThat(caseStageEndedEvent.getExecutionId()).isNull(); @@ -191,8 +188,7 @@ public void testCaseStageForceCompletedAfterSubStageCompletedEvents() { public void testCaseStageForceExitEvents() { List events = new ArrayList<>(); stageListener.eventConsumer = (flowableEvent) -> { - if (flowableEvent instanceof FlowableCaseStageEndedEvent) { - FlowableCaseStageEndedEvent caseStageEndedEvent = (FlowableCaseStageEndedEvent) flowableEvent; + if (flowableEvent instanceof FlowableCaseStageEndedEvent caseStageEndedEvent) { CaseInstance eventCaseInstance = caseStageEndedEvent.getCaseInstance(); assertThat(caseStageEndedEvent.getProcessInstanceId()).isNull(); assertThat(caseStageEndedEvent.getExecutionId()).isNull(); @@ -234,8 +230,7 @@ public void testCaseStageForceExitEvents() { public void testCaseStageForceExitAfterSubStageCompletedEvents() { List events = new ArrayList<>(); stageListener.eventConsumer = (flowableEvent) -> { - if (flowableEvent instanceof FlowableCaseStageEndedEvent) { - FlowableCaseStageEndedEvent caseStageEndedEvent = (FlowableCaseStageEndedEvent) flowableEvent; + if (flowableEvent instanceof FlowableCaseStageEndedEvent caseStageEndedEvent) { CaseInstance eventCaseInstance = caseStageEndedEvent.getCaseInstance(); assertThat(caseStageEndedEvent.getProcessInstanceId()).isNull(); assertThat(caseStageEndedEvent.getExecutionId()).isNull(); diff --git a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/event/CaseStageStartedEventTest.java b/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/event/CaseStageStartedEventTest.java index 3794bc94952..24342368aa4 100644 --- a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/event/CaseStageStartedEventTest.java +++ b/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/event/CaseStageStartedEventTest.java @@ -56,8 +56,7 @@ public void tearDown() { public void testCaseStageStartedEvents() { List events = new ArrayList<>(); stageListener.eventConsumer = (flowableEvent) -> { - if (flowableEvent instanceof FlowableCaseStageStartedEvent) { - FlowableCaseStageStartedEvent caseStageStartedEvent = (FlowableCaseStageStartedEvent) flowableEvent; + if (flowableEvent instanceof FlowableCaseStageStartedEvent caseStageStartedEvent) { CaseInstance eventCaseInstance = caseStageStartedEvent.getCaseInstance(); assertThat(caseStageStartedEvent.getProcessInstanceId()).isNull(); assertThat(caseStageStartedEvent.getExecutionId()).isNull(); diff --git a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/event/CaseStartedEventTest.java b/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/event/CaseStartedEventTest.java index 77c5da142c5..4c1cfdc683e 100644 --- a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/event/CaseStartedEventTest.java +++ b/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/event/CaseStartedEventTest.java @@ -55,8 +55,7 @@ public void tearDown() { public void testCaseInstanceEvents() { List events = new ArrayList<>(); listener.eventConsumer = (flowableEvent) -> { - if (flowableEvent instanceof FlowableCaseStartedEvent) { - FlowableCaseStartedEvent caseStartedEvent = (FlowableCaseStartedEvent) flowableEvent; + if (flowableEvent instanceof FlowableCaseStartedEvent caseStartedEvent) { CaseInstance eventCaseInstance = caseStartedEvent.getEntity(); assertThat(eventCaseInstance.getBusinessKey()).isEqualTo("business key"); assertThat(eventCaseInstance.getName()).isEqualTo("name"); @@ -95,8 +94,7 @@ public void testCaseInstanceEvents() { public void testSubCaseStartedEvents() { List events = new ArrayList<>(); listener.eventConsumer = (flowableEvent) -> { - if (flowableEvent instanceof FlowableCaseStartedEvent) { - FlowableCaseStartedEvent caseStartedEvent = (FlowableCaseStartedEvent) flowableEvent; + if (flowableEvent instanceof FlowableCaseStartedEvent caseStartedEvent) { CaseInstance eventCaseInstance = caseStartedEvent.getEntity(); assertThat(caseStartedEvent.getProcessInstanceId()).isNull(); assertThat(caseStartedEvent.getExecutionId()).isNull(); diff --git a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/itemcontrol/RepetitionVariableAggregationTest.java b/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/itemcontrol/RepetitionVariableAggregationTest.java index c0928ec334b..b1e01cb5566 100644 --- a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/itemcontrol/RepetitionVariableAggregationTest.java +++ b/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/itemcontrol/RepetitionVariableAggregationTest.java @@ -1415,8 +1415,7 @@ public Object aggregateSingleVariable(DelegatePlanItemInstance planItemInstance, ArrayNode arrayNode = CommandContextUtil.getCmmnEngineConfiguration().getObjectMapper().createArrayNode(); for (VariableAggregationDefinition.Variable variable : context.getDefinition().getDefinitions()) { Object sourceVariable = planItemInstance.getVariable(variable.getSource()); - if (sourceVariable instanceof ArrayNode) { - ArrayNode sourceArrayNode = (ArrayNode) sourceVariable; + if (sourceVariable instanceof ArrayNode sourceArrayNode) { for (int i = 0; i < sourceArrayNode.size(); i++) { JsonNode node = arrayNode.get(i); JsonNode sourceNode = sourceArrayNode.get(i); diff --git a/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/FieldExtension.java b/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/FieldExtension.java index d96f5195637..3600911228a 100644 --- a/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/FieldExtension.java +++ b/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/FieldExtension.java @@ -67,12 +67,10 @@ public boolean equals(Object o) { if (this == o) { return true; } - if (!(o instanceof FieldExtension)) { + if (!(o instanceof FieldExtension that)) { return false; } - FieldExtension that = (FieldExtension) o; - if (!getFieldName().equals(that.getFieldName())) { return false; } diff --git a/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/PlanFragment.java b/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/PlanFragment.java index c938b07bddd..d9ff3ffdb09 100644 --- a/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/PlanFragment.java +++ b/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/PlanFragment.java @@ -136,8 +136,7 @@ public List getDirectChildPlanItemsWithLifecycleEnabled() { planItemIterator.remove(); PlanItemDefinition planItemDefinition = planItem.getPlanItemDefinition(); - if (planItemDefinition instanceof PlanFragment) { - PlanFragment planFragment = (PlanFragment) planItemDefinition; + if (planItemDefinition instanceof PlanFragment planFragment) { for (PlanItem planFragmentPlanItem : planFragment.getPlanItems()) { planItemIterator.add(planFragmentPlanItem); diff --git a/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/DmnDecisionServiceImpl.java b/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/DmnDecisionServiceImpl.java index b0f0318aa45..d7b288a9d11 100644 --- a/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/DmnDecisionServiceImpl.java +++ b/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/DmnDecisionServiceImpl.java @@ -213,9 +213,8 @@ protected List> composeDecisionResult(ExecuteDecisionContext protected Map>> composeDecisionServiceResult(ExecuteDecisionContext executeDecisionContext) { // check if execution was Decision or DecisionService - if (executeDecisionContext.getDmnElement() instanceof DecisionService) { + if (executeDecisionContext.getDmnElement() instanceof DecisionService decisionService) { Map>> decisionServiceResult = new HashMap<>(); - DecisionService decisionService = (DecisionService) executeDecisionContext.getDmnElement(); DecisionServiceExecutionAuditContainer decisionServiceExecutionAuditContainer = (DecisionServiceExecutionAuditContainer) executeDecisionContext.getDecisionExecution(); boolean multipleResults = decisionService.getOutputDecisions().size() > 1; diff --git a/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/RuleEngineExecutorImpl.java b/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/RuleEngineExecutorImpl.java index fb237ac1c5e..511509a396c 100644 --- a/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/RuleEngineExecutorImpl.java +++ b/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/RuleEngineExecutorImpl.java @@ -78,12 +78,10 @@ public DecisionExecutionAuditContainer execute(Decision decision, ExecuteDecisio throw new IllegalArgumentException("no decision provided"); } - if (decision.getExpression() == null || !(decision.getExpression() instanceof DecisionTable)) { + if (decision.getExpression() == null || !(decision.getExpression() instanceof DecisionTable currentDecisionTable)) { throw new IllegalArgumentException("no decision table present in decision"); } - DecisionTable currentDecisionTable = (DecisionTable) decision.getExpression(); - // create execution context and audit trail ELExecutionContext executionContext = ELExecutionContextBuilder.build(decision, executeDecisionInfo); diff --git a/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/el/util/DMNParseUtil.java b/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/el/util/DMNParseUtil.java index 488613f31ea..8571ffdfb6f 100644 --- a/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/el/util/DMNParseUtil.java +++ b/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/el/util/DMNParseUtil.java @@ -116,8 +116,7 @@ protected static Object getFormattedValue(Object value, Object inputCollection) } protected static Object formatElementValue(Object value, Class collectionType) { - if (value instanceof String) { - String stringValue = (String) value; + if (value instanceof String stringValue) { if (stringValue.isEmpty()) { return null; } diff --git a/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/AllowedValuesParser.java b/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/AllowedValuesParser.java index 32d6081782a..f62bd8ab950 100644 --- a/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/AllowedValuesParser.java +++ b/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/AllowedValuesParser.java @@ -31,11 +31,10 @@ public String getElementName() { @Override public void parseChildElement(XMLStreamReader xtr, DmnElement parentElement, Decision decision) throws Exception { - if (!(parentElement instanceof ItemDefinition)) { + if (!(parentElement instanceof ItemDefinition itemDefinition)) { return; } - ItemDefinition itemDefinition = (ItemDefinition) parentElement; UnaryTests allowedValues = new UnaryTests(); boolean readyWithAllowedValues = false; diff --git a/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/InputEntryParser.java b/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/InputEntryParser.java index 00c6126dbed..ce40e502069 100644 --- a/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/InputEntryParser.java +++ b/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/InputEntryParser.java @@ -37,11 +37,10 @@ public String getElementName() { @Override public void parseChildElement(XMLStreamReader xtr, DmnElement parentElement, Decision decision) throws Exception { - if (!(parentElement instanceof DecisionRule)) { + if (!(parentElement instanceof DecisionRule rule)) { return; } - DecisionRule rule = (DecisionRule) parentElement; UnaryTests inputEntry = new UnaryTests(); inputEntry.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID)); diff --git a/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/InputExpressionParser.java b/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/InputExpressionParser.java index daeafc76f58..0fe14c7b33d 100644 --- a/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/InputExpressionParser.java +++ b/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/InputExpressionParser.java @@ -31,11 +31,10 @@ public String getElementName() { @Override public void parseChildElement(XMLStreamReader xtr, DmnElement parentElement, Decision decision) throws Exception { - if (!(parentElement instanceof InputClause)) { + if (!(parentElement instanceof InputClause clause)) { return; } - InputClause clause = (InputClause) parentElement; LiteralExpression inputExpression = new LiteralExpression(); inputExpression.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID)); inputExpression.setTypeRef(xtr.getAttributeValue(null, ATTRIBUTE_TYPE_REF)); diff --git a/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/InputValuesParser.java b/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/InputValuesParser.java index 983121753bb..47cb9ca9a3e 100644 --- a/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/InputValuesParser.java +++ b/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/InputValuesParser.java @@ -33,11 +33,10 @@ public String getElementName() { @Override public void parseChildElement(XMLStreamReader xtr, DmnElement parentElement, Decision decision) throws Exception { - if (!(parentElement instanceof InputClause)) { + if (!(parentElement instanceof InputClause clause)) { return; } - InputClause clause = (InputClause) parentElement; UnaryTests inputValues = new UnaryTests(); boolean readyWithInputValues = false; diff --git a/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/ItemComponentParser.java b/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/ItemComponentParser.java index 70f3b3b3871..8a8420861c2 100644 --- a/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/ItemComponentParser.java +++ b/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/ItemComponentParser.java @@ -31,11 +31,10 @@ public String getElementName() { @Override public void parseChildElement(XMLStreamReader xtr, DmnElement parentElement, Decision decision) throws Exception { - if (!(parentElement instanceof ItemDefinition)) { + if (!(parentElement instanceof ItemDefinition itemDefinition)) { return; } - ItemDefinition itemDefinition = (ItemDefinition) parentElement; ItemDefinition itemComponent = new ItemDefinition(); itemDefinition.addItemComponent(itemComponent); diff --git a/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/OutputEntryParser.java b/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/OutputEntryParser.java index 156fe135aa9..ffd48e70b6e 100644 --- a/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/OutputEntryParser.java +++ b/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/OutputEntryParser.java @@ -35,11 +35,10 @@ public String getElementName() { @Override public void parseChildElement(XMLStreamReader xtr, DmnElement parentElement, Decision decision) throws Exception { - if (!(parentElement instanceof DecisionRule)) { + if (!(parentElement instanceof DecisionRule rule)) { return; } - DecisionRule rule = (DecisionRule) parentElement; LiteralExpression outputEntry = new LiteralExpression(); outputEntry.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID)); diff --git a/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/OutputValuesParser.java b/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/OutputValuesParser.java index 4590304fce2..f93701b6929 100644 --- a/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/OutputValuesParser.java +++ b/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/OutputValuesParser.java @@ -31,11 +31,10 @@ public String getElementName() { @Override public void parseChildElement(XMLStreamReader xtr, DmnElement parentElement, Decision decision) throws Exception { - if (!(parentElement instanceof OutputClause)) { + if (!(parentElement instanceof OutputClause clause)) { return; } - OutputClause clause = (OutputClause) parentElement; UnaryTests outputValues = new UnaryTests(); boolean readyWithOutputValues = false; diff --git a/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/TypeRefParser.java b/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/TypeRefParser.java index 47ba0363beb..96a478dd125 100644 --- a/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/TypeRefParser.java +++ b/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/TypeRefParser.java @@ -30,11 +30,10 @@ public String getElementName() { @Override public void parseChildElement(XMLStreamReader xtr, DmnElement parentElement, Decision decision) throws Exception { - if (!(parentElement instanceof ItemDefinition)) { + if (!(parentElement instanceof ItemDefinition itemDefinition)) { return; } - ItemDefinition itemDefinition = (ItemDefinition) parentElement; itemDefinition.setTypeRef(xtr.getElementText()); } } diff --git a/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/VariableParser.java b/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/VariableParser.java index 5a78a27b848..a261c002bb6 100644 --- a/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/VariableParser.java +++ b/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/converter/child/VariableParser.java @@ -31,11 +31,10 @@ public String getElementName() { @Override public void parseChildElement(XMLStreamReader xtr, DmnElement parentElement, Decision decision) throws Exception { - if (!(parentElement instanceof InputData)) { + if (!(parentElement instanceof InputData inputData)) { return; } - InputData inputData = (InputData) parentElement; InformationItem variable = new InformationItem(); variable.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID)); variable.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME)); diff --git a/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/xml/converter/BaseDmnXMLConverter.java b/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/xml/converter/BaseDmnXMLConverter.java index d39d48b5e3d..3bcfe3d65c9 100644 --- a/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/xml/converter/BaseDmnXMLConverter.java +++ b/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/xml/converter/BaseDmnXMLConverter.java @@ -58,52 +58,45 @@ public void convertToDmnModel(XMLStreamReader xtr, ConversionHelper conversionHe decisionTable = Optional.of(decisionTableExpression); } - if (parsedElement instanceof InputClause) { + if (parsedElement instanceof InputClause inputClause) { decisionTable.ifPresent(dt -> { - InputClause inputClause = (InputClause) parsedElement; inputClause.setInputNumber(elementCounter); dt.addInput(inputClause); elementCounter++; }); - } else if (parsedElement instanceof OutputClause) { + } else if (parsedElement instanceof OutputClause outputClause) { decisionTable.ifPresent(dt -> { - OutputClause outputClause = (OutputClause) parsedElement; outputClause.setOutputNumber(elementCounter); dt.addOutput(outputClause); elementCounter++; }); - } else if (parsedElement instanceof DecisionRule) { + } else if (parsedElement instanceof DecisionRule decisionRule) { decisionTable.ifPresent(dt -> { - DecisionRule decisionRule = (DecisionRule) parsedElement; decisionRule.setRuleNumber(elementCounter); dt.addRule(decisionRule); elementCounter++; }); } else if (parsedElement instanceof ItemDefinition) { conversionHelper.getDmnDefinition().addItemDefinition((ItemDefinition) parsedElement); - } else if (parsedElement instanceof InputData) { - InputData inputData = (InputData) parsedElement; + } else if (parsedElement instanceof InputData inputData) { // TODO: handle inputData as href in DecisionService (same tag) if (inputData.getVariable() != null) { conversionHelper.getDmnDefinition().addInputData(inputData); } - } else if (parsedElement instanceof InformationRequirement) { - InformationRequirement informationRequirement = (InformationRequirement) parsedElement; + } else if (parsedElement instanceof InformationRequirement informationRequirement) { if (informationRequirement.getRequiredDecision() != null) { conversionHelper.getCurrentDecision().addRequiredDecision(informationRequirement); } else if (informationRequirement.getRequiredInput() != null) { conversionHelper.getCurrentDecision().addRequiredInput(informationRequirement); } - } else if (parsedElement instanceof AuthorityRequirement) { - AuthorityRequirement authorityRequirement = (AuthorityRequirement) parsedElement; + } else if (parsedElement instanceof AuthorityRequirement authorityRequirement) { conversionHelper.getCurrentDecision().addAuthorityRequirement(authorityRequirement); } else if (parsedElement instanceof InformationItem) { if (conversionHelper.getCurrentDecision().getVariable() == null) { conversionHelper.getCurrentDecision().setVariable((InformationItem) parsedElement); } - } else if (parsedElement instanceof DecisionService) { - DecisionService decisionService = (DecisionService) parsedElement; + } else if (parsedElement instanceof DecisionService decisionService) { decisionService.setDmnDefinition(conversionHelper.getDmnDefinition()); conversionHelper.getDmnDefinition().addDecisionService(decisionService); } diff --git a/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/FlowableVersion.java b/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/FlowableVersion.java index 16a597baf5f..255ae493a01 100644 --- a/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/FlowableVersion.java +++ b/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/FlowableVersion.java @@ -63,10 +63,9 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (!(obj instanceof FlowableVersion)) { + if (!(obj instanceof FlowableVersion other)) { return false; } - FlowableVersion other = (FlowableVersion) obj; boolean mainVersionEqual = mainVersion.equals(other.mainVersion); if (!mainVersionEqual) { return false; diff --git a/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/assignment/CandidateUtil.java b/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/assignment/CandidateUtil.java index e4afd0a9d77..b1b2fd541fe 100644 --- a/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/assignment/CandidateUtil.java +++ b/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/assignment/CandidateUtil.java @@ -27,8 +27,7 @@ public class CandidateUtil { public static Collection extractCandidates(Object value) { if (value instanceof Collection) { return (Collection) value; - } else if (value instanceof ArrayNode) { - ArrayNode valueArrayNode = (ArrayNode) value; + } else if (value instanceof ArrayNode valueArrayNode) { Collection candidates = new ArrayList<>(valueArrayNode.size()); for (JsonNode node : valueArrayNode) { candidates.add(node.asText()); diff --git a/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/db/DbSqlSession.java b/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/db/DbSqlSession.java index 971b5dee4fe..081c37da349 100755 --- a/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/db/DbSqlSession.java +++ b/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/db/DbSqlSession.java @@ -292,8 +292,7 @@ public List selectListWithRawParameter(String statement, Object parameter, boole public Object selectOne(String statement, Object parameter) { statement = dbSqlSessionFactory.mapStatement(statement); Object result = sqlSession.selectOne(statement, parameter); - if (result instanceof Entity) { - Entity loadedObject = (Entity) result; + if (result instanceof Entity loadedObject) { result = cacheLoadOrStore(loadedObject, parameter); } return result; diff --git a/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/de/odysseus/el/tree/Bindings.java b/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/de/odysseus/el/tree/Bindings.java index 5f7a2c6049a..47d71e05bbd 100644 --- a/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/de/odysseus/el/tree/Bindings.java +++ b/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/de/odysseus/el/tree/Bindings.java @@ -140,9 +140,8 @@ public T convert(Object value, Class type) { @Override public boolean equals(Object obj) { - if (obj instanceof Bindings) { - Bindings other = (Bindings)obj; - return Arrays.equals(functions, other.functions) + if (obj instanceof Bindings other) { + return Arrays.equals(functions, other.functions) && Arrays.equals(variables, other.variables) && converter.equals(other.converter); } diff --git a/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/el/FlowableExpressionFactory.java b/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/el/FlowableExpressionFactory.java index db67eda85e1..e7e7054e0d5 100644 --- a/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/el/FlowableExpressionFactory.java +++ b/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/el/FlowableExpressionFactory.java @@ -41,8 +41,7 @@ protected TreeBuilder createDefaultTreeBuilder(Builder.Feature... features) { public void setAstFunctionCreators(Collection astFunctionCreators) { TreeBuilder storeBuilder = this.store.getBuilder(); - if (storeBuilder instanceof FlowableExpressionBuilder) { - FlowableExpressionBuilder expressionBuilder = (FlowableExpressionBuilder) storeBuilder; + if (storeBuilder instanceof FlowableExpressionBuilder expressionBuilder) { expressionBuilder.getAstFunctionCreators().clear(); for (FlowableAstFunctionCreator astFunctionCreator : astFunctionCreators) { diff --git a/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/el/function/VariableContainsAnyExpressionFunction.java b/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/el/function/VariableContainsAnyExpressionFunction.java index 750884e0c99..4e27a85af12 100644 --- a/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/el/function/VariableContainsAnyExpressionFunction.java +++ b/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/el/function/VariableContainsAnyExpressionFunction.java @@ -43,8 +43,7 @@ public VariableContainsAnyExpressionFunction() { public static boolean containsAny(VariableContainer variableContainer, String variableName, Object... values) { Object variableValue = getVariableValue(variableContainer, variableName); if (variableValue != null) { - if (variableValue instanceof String) { - String variableStringValue = (String) variableValue; + if (variableValue instanceof String variableStringValue) { for (Object value : values) { String stringValue = (String) value; if (StringUtils.contains(variableStringValue, stringValue)) { @@ -53,8 +52,7 @@ public static boolean containsAny(VariableContainer variableContainer, String va } return false; - } else if (variableValue instanceof Collection) { - Collection collectionVariableValue = (Collection) variableValue; + } else if (variableValue instanceof Collection collectionVariableValue) { for (Object value : values) { if (VariableContainsExpressionFunction.collectionContains(collectionVariableValue, value)) { return true; @@ -62,8 +60,7 @@ public static boolean containsAny(VariableContainer variableContainer, String va } return false; - } else if (variableValue instanceof ArrayNode) { - ArrayNode arrayNodeVariableValue = (ArrayNode) variableValue; + } else if (variableValue instanceof ArrayNode arrayNodeVariableValue) { for (Object value : values) { if (VariableContainsExpressionFunction.arrayNodeContains(arrayNodeVariableValue, value)) { return true; diff --git a/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/el/function/VariableContainsExpressionFunction.java b/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/el/function/VariableContainsExpressionFunction.java index 92e856f7f43..31c9c95822e 100644 --- a/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/el/function/VariableContainsExpressionFunction.java +++ b/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/el/function/VariableContainsExpressionFunction.java @@ -45,8 +45,7 @@ public VariableContainsExpressionFunction() { public static boolean contains(VariableContainer variableContainer, String variableName, Object... values) { Object variableValue = getVariableValue(variableContainer, variableName); if (variableValue != null) { - if (variableValue instanceof String) { - String variableStringValue = (String) variableValue; + if (variableValue instanceof String variableStringValue) { for (Object value : values) { String stringValue = (String) value; if (!StringUtils.contains(variableStringValue, stringValue)) { @@ -55,8 +54,7 @@ public static boolean contains(VariableContainer variableContainer, String varia } return true; - } else if (variableValue instanceof Collection) { - Collection collectionVariableValue = (Collection) variableValue; + } else if (variableValue instanceof Collection collectionVariableValue) { for (Object value : values) { if (!collectionContains(collectionVariableValue, value)) { return false; @@ -64,8 +62,7 @@ public static boolean contains(VariableContainer variableContainer, String varia } return true; - } else if (variableValue instanceof ArrayNode) { - ArrayNode arrayNodeVariableValue = (ArrayNode) variableValue; + } else if (variableValue instanceof ArrayNode arrayNodeVariableValue) { for (Object value : values) { if (!arrayNodeContains(arrayNodeVariableValue, value)) { return false; diff --git a/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/interceptor/CrDbRetryInterceptor.java b/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/interceptor/CrDbRetryInterceptor.java index c49cc64e2ba..0a6c7713a69 100644 --- a/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/interceptor/CrDbRetryInterceptor.java +++ b/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/interceptor/CrDbRetryInterceptor.java @@ -78,8 +78,7 @@ protected void waitBeforeRetry(long waitTime) { } protected boolean isTransactionRetryException(Throwable exception) { - if (exception instanceof SQLException) { - SQLException sqlException = (SQLException) exception; + if (exception instanceof SQLException sqlException) { if (sqlException.getErrorCode() == 40001 || (sqlException.getMessage() != null && sqlException.getMessage().contains("retry txn"))) { return true; } diff --git a/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/persistence/entity/ByteArrayEntityImpl.java b/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/persistence/entity/ByteArrayEntityImpl.java index 9e809e25ce5..bdeaa790f7f 100644 --- a/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/persistence/entity/ByteArrayEntityImpl.java +++ b/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/persistence/entity/ByteArrayEntityImpl.java @@ -95,8 +95,7 @@ public PersistentState(String name, byte[] bytes) { @Override public boolean equals(Object obj) { - if (obj instanceof PersistentState) { - PersistentState other = (PersistentState) obj; + if (obj instanceof PersistentState other) { return StringUtils.equals(this.name, other.name) && Arrays.equals(this.bytes, other.bytes); } return false; diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/debug/ExecutionTreeNode.java b/modules/flowable-engine/src/main/java/org/flowable/engine/debug/ExecutionTreeNode.java index 9b46b999da6..257ca950181 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/debug/ExecutionTreeNode.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/debug/ExecutionTreeNode.java @@ -109,8 +109,7 @@ protected void internalToString(StringBuilder strb, String prefix, boolean isTai protected String getCurrentFlowElementId() { FlowElement flowElement = getExecutionEntity().getCurrentFlowElement(); - if (flowElement instanceof SequenceFlow) { - SequenceFlow sequenceFlow = (SequenceFlow) flowElement; + if (flowElement instanceof SequenceFlow sequenceFlow) { return sequenceFlow.getSourceRef() + " -> " + sequenceFlow.getTargetRef(); } else if (flowElement != null) { return flowElement.getId() + " (" + flowElement.getClass().getSimpleName(); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/delegate/event/AbstractFlowableEngineEventListener.java b/modules/flowable-engine/src/main/java/org/flowable/engine/delegate/event/AbstractFlowableEngineEventListener.java index 735f5f5060b..ff5ce2da801 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/delegate/event/AbstractFlowableEngineEventListener.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/delegate/event/AbstractFlowableEngineEventListener.java @@ -42,8 +42,7 @@ public AbstractFlowableEngineEventListener(Set types) { @Override public void onEvent(FlowableEvent flowableEvent) { - if (flowableEvent instanceof FlowableEngineEvent) { - FlowableEngineEvent flowableEngineEvent = (FlowableEngineEvent) flowableEvent; + if (flowableEvent instanceof FlowableEngineEvent flowableEngineEvent) { FlowableEngineEventType engineEventType = (FlowableEngineEventType) flowableEvent.getType(); if (types == null || types.contains(engineEventType)) { diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/delegate/event/impl/BpmnModelEventDispatchAction.java b/modules/flowable-engine/src/main/java/org/flowable/engine/delegate/event/impl/BpmnModelEventDispatchAction.java index a3cad334fc1..ae3edd03346 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/delegate/event/impl/BpmnModelEventDispatchAction.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/delegate/event/impl/BpmnModelEventDispatchAction.java @@ -28,8 +28,7 @@ public class BpmnModelEventDispatchAction implements EventDispatchAction { @Override public void dispatchEvent(CommandContext commandContext, FlowableEventSupport eventSupport, FlowableEvent event) { - if (event.getType() == FlowableEngineEventType.ENTITY_DELETED && event instanceof FlowableEntityEvent) { - FlowableEntityEvent entityEvent = (FlowableEntityEvent) event; + if (event.getType() == FlowableEngineEventType.ENTITY_DELETED && event instanceof FlowableEntityEvent entityEvent) { if (entityEvent.getEntity() instanceof ProcessDefinition) { // process definition deleted event doesn't need to be dispatched to event listeners return; diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/delegate/event/impl/FlowableEventBuilder.java b/modules/flowable-engine/src/main/java/org/flowable/engine/delegate/event/impl/FlowableEventBuilder.java index 463ab56b9e8..fdc34d0ccc9 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/delegate/event/impl/FlowableEventBuilder.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/delegate/event/impl/FlowableEventBuilder.java @@ -233,8 +233,7 @@ public static FlowableActivityEvent createActivityEvent(FlowableEngineEventType newEvent.setProcessDefinitionId(processDefinitionId); newEvent.setProcessInstanceId(processInstanceId); - if (flowElement instanceof FlowNode) { - FlowNode flowNode = (FlowNode) flowElement; + if (flowElement instanceof FlowNode flowNode) { newEvent.setActivityType(parseActivityType(flowNode)); Object behaviour = flowNode.getBehavior(); if (behaviour != null) { @@ -255,8 +254,7 @@ public static FlowableMultiInstanceActivityEvent createMultiInstanceActivityEven newEvent.setProcessDefinitionId(processDefinitionId); newEvent.setProcessInstanceId(processInstanceId); - if (flowElement instanceof FlowNode) { - FlowNode flowNode = (FlowNode) flowElement; + if (flowElement instanceof FlowNode flowNode) { newEvent.setActivityType(parseActivityType(flowNode)); Object behaviour = flowNode.getBehavior(); if (behaviour != null) { @@ -283,8 +281,7 @@ public static FlowableMultiInstanceActivityCompletedEvent createMultiInstanceAct newEvent.setProcessDefinitionId(processDefinitionId); newEvent.setProcessInstanceId(processInstanceId); - if (flowElement instanceof FlowNode) { - FlowNode flowNode = (FlowNode) flowElement; + if (flowElement instanceof FlowNode flowNode) { newEvent.setActivityType(parseActivityType(flowNode)); Object behaviour = flowNode.getBehavior(); if (behaviour != null) { @@ -432,8 +429,7 @@ protected static void populateEventWithCurrentContext(FlowableEngineEventImpl ev event.setProcessInstanceId(((DelegateExecution) persistedObject).getProcessInstanceId()); event.setProcessDefinitionId(((DelegateExecution) persistedObject).getProcessDefinitionId()); - } else if (persistedObject instanceof IdentityLinkEntity) { - IdentityLinkEntity idLink = (IdentityLinkEntity) persistedObject; + } else if (persistedObject instanceof IdentityLinkEntity idLink) { if (idLink.getProcessDefinitionId() != null) { event.setProcessDefinitionId(idLink.getProcessDefId()); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/delegate/event/impl/FlowableProcessStartedEventImpl.java b/modules/flowable-engine/src/main/java/org/flowable/engine/delegate/event/impl/FlowableProcessStartedEventImpl.java index a456b8ae602..cfc68510b8d 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/delegate/event/impl/FlowableProcessStartedEventImpl.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/delegate/event/impl/FlowableProcessStartedEventImpl.java @@ -31,8 +31,7 @@ public class FlowableProcessStartedEventImpl extends FlowableEntityWithVariables public FlowableProcessStartedEventImpl(final Object entity, final Map variables, final boolean localScope) { super(entity, variables, localScope, FlowableEngineEventType.PROCESS_STARTED); - if (entity instanceof ExecutionEntity) { - ExecutionEntity executionEntity = (ExecutionEntity) entity; + if (entity instanceof ExecutionEntity executionEntity) { if (!executionEntity.isProcessInstanceType()) { executionEntity = executionEntity.getParent(); } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/agenda/ContinueMultiInstanceOperation.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/agenda/ContinueMultiInstanceOperation.java index edbc86b452a..b9124e81695 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/agenda/ContinueMultiInstanceOperation.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/agenda/ContinueMultiInstanceOperation.java @@ -127,10 +127,9 @@ protected void executeAsynchronous(FlowNode flowNode) { protected ActivityBehavior setLoopCounterVariable(FlowNode flowNode) { ActivityBehavior activityBehavior = (ActivityBehavior) flowNode.getBehavior(); - if (!(activityBehavior instanceof MultiInstanceActivityBehavior)) { + if (!(activityBehavior instanceof MultiInstanceActivityBehavior multiInstanceActivityBehavior)) { throw new FlowableException("Programmatic error: expected multi instance activity behavior, but got " + activityBehavior.getClass()); } - MultiInstanceActivityBehavior multiInstanceActivityBehavior = (MultiInstanceActivityBehavior) activityBehavior; String elementIndexVariable = multiInstanceActivityBehavior.getCollectionElementIndexVariable(); execution.setVariableLocal(elementIndexVariable, loopCounter); return activityBehavior; diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/agenda/ContinueProcessOperation.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/agenda/ContinueProcessOperation.java index b97b9fa9ac3..3be9e830b77 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/agenda/ContinueProcessOperation.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/agenda/ContinueProcessOperation.java @@ -291,8 +291,7 @@ protected void executeActivityBehavior(ActivityBehavior activityBehavior, FlowNo } try { - if (migrationContext != null && activityBehavior instanceof ActivityWithMigrationContextBehavior) { - ActivityWithMigrationContextBehavior activityWithMigrationContextBehavior = (ActivityWithMigrationContextBehavior) activityBehavior; + if (migrationContext != null && activityBehavior instanceof ActivityWithMigrationContextBehavior activityWithMigrationContextBehavior) { activityWithMigrationContextBehavior.execute(execution, migrationContext); } else { activityBehavior.execute(execution); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/agenda/EndExecutionOperation.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/agenda/EndExecutionOperation.java index 096711fbc8a..4856fa32d50 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/agenda/EndExecutionOperation.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/agenda/EndExecutionOperation.java @@ -148,8 +148,7 @@ protected void handleProcessInstanceExecution(ExecutionEntity processInstanceExe protected boolean isAsyncCompleteCallActivity(ExecutionEntity superExecution) { if (superExecution != null) { FlowNode superExecutionFlowNode = (FlowNode) superExecution.getCurrentFlowElement(); - if (superExecutionFlowNode instanceof CallActivity) { - CallActivity callActivity = (CallActivity) superExecutionFlowNode; + if (superExecutionFlowNode instanceof CallActivity callActivity) { return callActivity.isCompleteAsync(); } } @@ -205,13 +204,11 @@ protected void handleRegularExecution() { SubProcess subProcess = execution.getCurrentFlowElement().getSubProcess(); - if (subProcess instanceof EventSubProcess) { - EventSubProcess eventSubProcess = (EventSubProcess) subProcess; + if (subProcess instanceof EventSubProcess eventSubProcess) { boolean hasNonInterruptingStartEvent = false; for (FlowElement eventSubElement : eventSubProcess.getFlowElements()) { - if (eventSubElement instanceof StartEvent) { - StartEvent subStartEvent = (StartEvent) eventSubElement; + if (eventSubElement instanceof StartEvent subStartEvent) { if (!subStartEvent.isInterrupting()) { hasNonInterruptingStartEvent = true; break; @@ -230,8 +227,7 @@ protected void handleRegularExecution() { ExecutionEntity subProcessParentExecution = parentExecution.getParent(); if (getNumberOfActiveChildExecutionsForExecution(executionEntityManager, subProcessParentExecution.getId()) == 0) { - if (subProcessParentExecution.getCurrentFlowElement() instanceof SubProcess) { - SubProcess parentSubProcess = (SubProcess) subProcessParentExecution.getCurrentFlowElement(); + if (subProcessParentExecution.getCurrentFlowElement() instanceof SubProcess parentSubProcess) { if (parentSubProcess.getOutgoingFlows().size() > 0) { ExecutionEntity executionToContinue = handleSubProcessEnd(executionEntityManager, subProcessParentExecution, parentSubProcess); agenda.planTakeOutgoingSequenceFlowsOperation(executionToContinue, true); @@ -320,8 +316,7 @@ protected ExecutionEntity handleSubProcessEnd(ExecutionEntityManager executionEn hasCompensation = true; } else { for (FlowElement subElement : subProcess.getFlowElements()) { - if (subElement instanceof Activity) { - Activity subActivity = (Activity) subElement; + if (subElement instanceof Activity subActivity) { if (CollectionUtil.isNotEmpty(subActivity.getBoundaryEvents())) { for (BoundaryEvent boundaryEvent : subActivity.getBoundaryEvents()) { if (CollectionUtil.isNotEmpty(boundaryEvent.getEventDefinitions()) && @@ -362,8 +357,7 @@ protected ExecutionEntity handleRegularExecutionEnd(ExecutionEntityManager execu parentExecution.setCurrentFlowElement(execution.getCurrentFlowElement()); } - if (execution.getCurrentFlowElement() instanceof SubProcess) { - SubProcess currentSubProcess = (SubProcess) execution.getCurrentFlowElement(); + if (execution.getCurrentFlowElement() instanceof SubProcess currentSubProcess) { if (currentSubProcess.getOutgoingFlows().size() > 0) { // create a new execution to take the outgoing sequence flows executionToContinue = executionEntityManager.createChildExecution(parentExecution); @@ -394,8 +388,7 @@ protected void handleMultiInstanceSubProcess(ProcessEngineConfigurationImpl proc // Special case: will be handled by the ParallelMultiInstanceWithNoWaitStateCompletionJobHandler asynchronously Object subProcessBehavior = currentExecution.getCurrentFlowElement().getSubProcess().getBehavior(); - if (subProcessBehavior instanceof ParallelMultiInstanceBehavior) { - ParallelMultiInstanceBehavior parallelMultiInstanceBehavior = (ParallelMultiInstanceBehavior) subProcessBehavior; + if (subProcessBehavior instanceof ParallelMultiInstanceBehavior parallelMultiInstanceBehavior) { if (parallelMultiInstanceBehavior.isAsyncWithoutWaitStates(CommandContextUtil.getProcessEngineConfiguration())) { parallelMultiInstanceBehavior.leave(currentExecution); return; @@ -445,8 +438,7 @@ protected boolean isEndEventOrImpliedEndEventInMultiInstanceSubprocess(Execution } protected boolean isFlowNodeWithoutOutgoingSequenceFlow(FlowElement flowElement) { - if (flowElement instanceof FlowNode) { - FlowNode flowNode = (FlowNode) flowElement; + if (flowElement instanceof FlowNode flowNode) { return flowNode.getOutgoingFlows() == null || flowNode.getOutgoingFlows().isEmpty(); } return false; diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/agenda/EvaluateConditionalEventsOperation.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/agenda/EvaluateConditionalEventsOperation.java index 6b1c4fb9989..ec681df378d 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/agenda/EvaluateConditionalEventsOperation.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/agenda/EvaluateConditionalEventsOperation.java @@ -58,8 +58,7 @@ public void run() { for (ExecutionEntity childExecutionEntity : allExecutions) { String activityId = childExecutionEntity.getCurrentActivityId(); FlowElement currentFlowElement = process.getFlowElement(activityId, true); - if (currentFlowElement instanceof Event) { - Event event = (Event) currentFlowElement; + if (currentFlowElement instanceof Event event) { if (!event.getEventDefinitions().isEmpty() && event.getEventDefinitions().get(0) instanceof ConditionalEventDefinition) { ActivityBehavior activityBehavior = (ActivityBehavior) ((FlowNode) currentFlowElement).getBehavior(); @@ -68,8 +67,7 @@ public void run() { } } - } else if (currentFlowElement instanceof SubProcess) { - SubProcess subProcess = (SubProcess) currentFlowElement; + } else if (currentFlowElement instanceof SubProcess subProcess) { List childEventSubProcesses = subProcess.findAllSubFlowElementInFlowMapOfType(EventSubProcess.class); evaluateEventSubProcesses(childEventSubProcesses, childExecutionEntity); } @@ -83,12 +81,11 @@ protected void evaluateEventSubProcesses(List eventSubProcesses if (startEvents != null) { for (StartEvent startEvent : startEvents) { - if (startEvent.getEventDefinitions() != null && !startEvent.getEventDefinitions().isEmpty() && - startEvent.getEventDefinitions().get(0) instanceof ConditionalEventDefinition) { + if (startEvent.getEventDefinitions() != null && !startEvent.getEventDefinitions().isEmpty() && + startEvent.getEventDefinitions().get(0) instanceof ConditionalEventDefinition conditionalEventDefinition) { CommandContext commandContext = CommandContextUtil.getCommandContext(); - ConditionalEventDefinition conditionalEventDefinition = (ConditionalEventDefinition) startEvent.getEventDefinitions().get(0); - + boolean conditionIsTrue = false; String conditionExpression = conditionalEventDefinition.getConditionExpression(); if (StringUtils.isNotEmpty(conditionExpression)) { diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/agenda/TakeOutgoingSequenceFlowsOperation.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/agenda/TakeOutgoingSequenceFlowsOperation.java index 5d378b0c6ac..22841fabc6f 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/agenda/TakeOutgoingSequenceFlowsOperation.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/agenda/TakeOutgoingSequenceFlowsOperation.java @@ -118,8 +118,7 @@ protected FlowNode getFlowNode(FlowElement currentFlowElement) { if (currentFlowElement instanceof FlowNode) { sourceFlowNode = (FlowNode) currentFlowElement; - } else if (currentFlowElement instanceof SequenceFlow){ - SequenceFlow sequenceFlow = (SequenceFlow) currentFlowElement; + } else if (currentFlowElement instanceof SequenceFlow sequenceFlow){ FlowElement sourceFlowElement = sequenceFlow.getSourceFlowElement(); if (sourceFlowElement instanceof FlowNode) { sourceFlowNode = (FlowNode) sourceFlowElement; @@ -370,11 +369,10 @@ protected void cleanupExecutions(FlowElement currentFlowElement) { agenda.planDestroyScopeOperation(execution); - } else if (currentFlowElement instanceof Activity) { + } else if (currentFlowElement instanceof Activity activity) { // If the current activity is an activity, we need to remove any currently active boundary events - Activity activity = (Activity) currentFlowElement; if (CollectionUtil.isNotEmpty(activity.getBoundaryEvents())) { // Cancel events are not removed diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/BoundaryCancelEventActivityBehavior.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/BoundaryCancelEventActivityBehavior.java index db14e88081f..5a548dee454 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/BoundaryCancelEventActivityBehavior.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/BoundaryCancelEventActivityBehavior.java @@ -70,8 +70,7 @@ public void trigger(DelegateExecution execution, String triggerName, Object trig // cancel boundary is always sync ScopeUtil.throwCompensationEvent(eventSubscriptions, execution, false); executionEntityManager.deleteExecutionAndRelatedData(subProcessExecution, deleteReason, false); - if (subProcessExecution.getCurrentFlowElement() instanceof Activity) { - Activity activity = (Activity) subProcessExecution.getCurrentFlowElement(); + if (subProcessExecution.getCurrentFlowElement() instanceof Activity activity) { if (activity.getLoopCharacteristics() != null) { ExecutionEntity miExecution = subProcessExecution.getParent(); List miChildExecutions = executionEntityManager.findChildExecutionsByParentExecutionId(miExecution.getId()); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/BoundaryCompensateEventActivityBehavior.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/BoundaryCompensateEventActivityBehavior.java index 6431b71324b..bf5454484fe 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/BoundaryCompensateEventActivityBehavior.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/BoundaryCompensateEventActivityBehavior.java @@ -62,8 +62,7 @@ public void execute(DelegateExecution execution) { for (Association association : associations) { sourceActivity = boundaryEvent.getAttachedToRef(); FlowElement targetElement = process.getFlowElement(association.getTargetRef(), true); - if (targetElement instanceof Activity) { - Activity activity = (Activity) targetElement; + if (targetElement instanceof Activity activity) { if (activity.isForCompensation()) { compensationActivity = activity; break; @@ -129,4 +128,4 @@ public void trigger(DelegateExecution execution, String triggerName, Object trig super.trigger(executionEntity, triggerName, triggerData); } -} \ No newline at end of file +} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/CancelEndEventActivityBehavior.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/CancelEndEventActivityBehavior.java index 1d9018cb37d..45df7926bb8 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/CancelEndEventActivityBehavior.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/CancelEndEventActivityBehavior.java @@ -50,9 +50,8 @@ public void execute(DelegateExecution execution) { ExecutionEntity parentScopeExecution = null; ExecutionEntity currentlyExaminedExecution = executionEntityManager.findById(executionEntity.getParentId()); while (currentlyExaminedExecution != null && parentScopeExecution == null) { - if (currentlyExaminedExecution.getCurrentFlowElement() instanceof SubProcess) { + if (currentlyExaminedExecution.getCurrentFlowElement() instanceof SubProcess subProcess) { parentScopeExecution = currentlyExaminedExecution; - SubProcess subProcess = (SubProcess) currentlyExaminedExecution.getCurrentFlowElement(); if (subProcess.getLoopCharacteristics() != null) { ExecutionEntity miExecution = parentScopeExecution.getParent(); FlowElement miElement = miExecution.getCurrentFlowElement(); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/DmnActivityBehavior.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/DmnActivityBehavior.java index 020e7503209..ab7c08c4357 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/DmnActivityBehavior.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/DmnActivityBehavior.java @@ -140,8 +140,7 @@ public void execute(DelegateExecution execution) { } if (processEngineConfiguration.getDecisionTableVariableManager() != null) { - if (decisionExecutionAuditContainer instanceof DecisionServiceExecutionAuditContainer) { - DecisionServiceExecutionAuditContainer decisionServiceExecutionAuditContainer = (DecisionServiceExecutionAuditContainer) decisionExecutionAuditContainer; + if (decisionExecutionAuditContainer instanceof DecisionServiceExecutionAuditContainer decisionServiceExecutionAuditContainer) { processEngineConfiguration.getDecisionTableVariableManager().setDecisionServiceVariablesOnExecution(decisionServiceExecutionAuditContainer.getDecisionServiceResult(), finalDecisionKeyValue, execution, processEngineConfiguration.getObjectMapper(), decisionExecutionAuditContainer.isMultipleResults()); } else { @@ -152,8 +151,7 @@ public void execute(DelegateExecution execution) { } else { boolean multipleResults = decisionExecutionAuditContainer.isMultipleResults() && processEngineConfiguration.isAlwaysUseArraysForDmnMultiHitPolicies(); - if (decisionExecutionAuditContainer instanceof DecisionServiceExecutionAuditContainer) { - DecisionServiceExecutionAuditContainer decisionServiceExecutionAuditContainer = (DecisionServiceExecutionAuditContainer) decisionExecutionAuditContainer; + if (decisionExecutionAuditContainer instanceof DecisionServiceExecutionAuditContainer decisionServiceExecutionAuditContainer) { setDecisionServiceVariablesOnExecution(decisionServiceExecutionAuditContainer.getDecisionServiceResult(), finalDecisionKeyValue, execution, processEngineConfiguration.getObjectMapper(), multipleResults); } else { diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/IntermediateCatchEventActivityBehavior.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/IntermediateCatchEventActivityBehavior.java index 374ad1d3159..434441d70a4 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/IntermediateCatchEventActivityBehavior.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/IntermediateCatchEventActivityBehavior.java @@ -65,8 +65,7 @@ public void eventCancelledByEventGateway(DelegateExecution execution) { protected EventGateway getPrecedingEventBasedGateway(DelegateExecution execution) { FlowElement currentFlowElement = execution.getCurrentFlowElement(); - if (currentFlowElement instanceof IntermediateCatchEvent) { - IntermediateCatchEvent intermediateCatchEvent = (IntermediateCatchEvent) currentFlowElement; + if (currentFlowElement instanceof IntermediateCatchEvent intermediateCatchEvent) { List incomingSequenceFlow = intermediateCatchEvent.getIncomingFlows(); // If behind an event based gateway, there is only one incoming sequence flow that originates from said gateway @@ -110,8 +109,7 @@ protected void deleteOtherEventsRelatedToEventBasedGateway(DelegateExecution exe // Execute the cancel behaviour of the IntermediateCatchEvent for (ExecutionEntity executionEntity : executionEntities) { - if (eventActivityIds.contains(executionEntity.getActivityId()) && execution.getCurrentFlowElement() instanceof IntermediateCatchEvent) { - IntermediateCatchEvent intermediateCatchEvent = (IntermediateCatchEvent) execution.getCurrentFlowElement(); + if (eventActivityIds.contains(executionEntity.getActivityId()) && execution.getCurrentFlowElement() instanceof IntermediateCatchEvent intermediateCatchEvent) { if (intermediateCatchEvent.getBehavior() instanceof IntermediateCatchEventActivityBehavior) { ((IntermediateCatchEventActivityBehavior) intermediateCatchEvent.getBehavior()).eventCancelledByEventGateway(executionEntity); eventActivityIds.remove(executionEntity.getActivityId()); // We only need to delete ONE execution at the event. diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/IntermediateThrowCompensationEventActivityBehavior.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/IntermediateThrowCompensationEventActivityBehavior.java index 4f161f14d8e..7ff96ccf92b 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/IntermediateThrowCompensationEventActivityBehavior.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/IntermediateThrowCompensationEventActivityBehavior.java @@ -86,14 +86,12 @@ public void execute(DelegateExecution execution) { String compensationActivityId = null; FlowElement flowElement = process.getFlowElement(activityRef, true); - if (flowElement instanceof Activity) { - Activity activity = (Activity) flowElement; + if (flowElement instanceof Activity activity) { if (activity.isForCompensation()) { List associations = process.findAssociationsWithTargetRefRecursive(activity.getId()); for (Association association : associations) { FlowElement sourceElement = process.getFlowElement(association.getSourceRef(), true); - if (sourceElement instanceof BoundaryEvent) { - BoundaryEvent sourceBoundaryEvent = (BoundaryEvent) sourceElement; + if (sourceElement instanceof BoundaryEvent sourceBoundaryEvent) { if (sourceBoundaryEvent.getAttachedToRefId() != null) { compensationActivityId = sourceBoundaryEvent.getAttachedToRefId(); break; diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/MultiInstanceActivityBehavior.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/MultiInstanceActivityBehavior.java index 12447b2a043..269dbdb5d57 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/MultiInstanceActivityBehavior.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/MultiInstanceActivityBehavior.java @@ -389,11 +389,10 @@ public boolean completionConditionSatisfied(DelegateExecution execution) { Object value = expressionManager.createExpression(activeCompletionCondition).getValue(execution); - if (!(value instanceof Boolean)) { + if (!(value instanceof Boolean booleanValue)) { throw new FlowableIllegalArgumentException("completionCondition '" + activeCompletionCondition + "' does not evaluate to a boolean value"); } - Boolean booleanValue = (Boolean) value; if (LOGGER.isDebugEnabled()) { LOGGER.debug("Completion condition of multi-instance satisfied: {}", booleanValue); } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/ParallelGatewayActivityBehavior.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/ParallelGatewayActivityBehavior.java index 9dcf5630776..2485b5cca81 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/ParallelGatewayActivityBehavior.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/ParallelGatewayActivityBehavior.java @@ -170,8 +170,7 @@ protected DelegateExecution findMultiInstanceParentExecution(DelegateExecution e DelegateExecution parentExecution = execution.getParent(); if (parentExecution != null && parentExecution.getCurrentFlowElement() != null) { FlowElement flowElement = parentExecution.getCurrentFlowElement(); - if (flowElement instanceof Activity) { - Activity activity = (Activity) flowElement; + if (flowElement instanceof Activity activity) { if (activity.getLoopCharacteristics() != null) { multiInstanceExecution = parentExecution; } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/ParallelMultiInstanceBehavior.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/ParallelMultiInstanceBehavior.java index 8e2d22cc98f..429e3f5f766 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/ParallelMultiInstanceBehavior.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/ParallelMultiInstanceBehavior.java @@ -325,11 +325,9 @@ protected Activity verifyCompensation(DelegateExecution execution, ExecutionEnti boolean hasCompensation = false; if (activity instanceof Transaction) { hasCompensation = true; - } else if (activity instanceof SubProcess) { - SubProcess subProcess = (SubProcess) activity; + } else if (activity instanceof SubProcess subProcess) { for (FlowElement subElement : subProcess.getFlowElements()) { - if (subElement instanceof Activity) { - Activity subActivity = (Activity) subElement; + if (subElement instanceof Activity subActivity) { if (CollectionUtil.isNotEmpty(subActivity.getBoundaryEvents())) { for (BoundaryEvent boundaryEvent : subActivity.getBoundaryEvents()) { if (CollectionUtil.isNotEmpty(boundaryEvent.getEventDefinitions()) && diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/SubProcessActivityBehavior.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/SubProcessActivityBehavior.java index d372a0bcc86..9b5b14528a9 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/SubProcessActivityBehavior.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/SubProcessActivityBehavior.java @@ -79,8 +79,7 @@ public void execute(DelegateExecution execution) { protected FlowElement getStartElement(SubProcess subProcess) { if (CollectionUtil.isNotEmpty(subProcess.getFlowElements())) { for (FlowElement subElement : subProcess.getFlowElements()) { - if (subElement instanceof StartEvent) { - StartEvent startEvent = (StartEvent) subElement; + if (subElement instanceof StartEvent startEvent) { if (isOnlyNoneStartEventAllowed) { if (CollectionUtil.isEmpty(startEvent.getEventDefinitions())) { return startEvent; diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/TerminateEndEventActivityBehavior.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/TerminateEndEventActivityBehavior.java index 6457e92ba25..05436356403 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/TerminateEndEventActivityBehavior.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/TerminateEndEventActivityBehavior.java @@ -105,10 +105,8 @@ protected void defaultTerminateEndEventBehaviour(ExecutionEntity execution, Comm CommandContextUtil.getProcessEngineConfiguration(commandContext).getClock().getCurrentTime()); } else if (scopeExecutionEntity.getCurrentFlowElement() != null - && scopeExecutionEntity.getCurrentFlowElement() instanceof SubProcess) { // SubProcess + && scopeExecutionEntity.getCurrentFlowElement() instanceof SubProcess subProcess) { // SubProcess - SubProcess subProcess = (SubProcess) scopeExecutionEntity.getCurrentFlowElement(); - scopeExecutionEntity.setDeleteReason(deleteReason); if (subProcess.hasMultiInstanceLoopCharacteristics()) { CommandContextUtil.getAgenda(commandContext).planDestroyScopeOperation(scopeExecutionEntity); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/UserTaskActivityBehavior.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/UserTaskActivityBehavior.java index e99bcb89666..f3547bfa46e 100755 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/UserTaskActivityBehavior.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/UserTaskActivityBehavior.java @@ -491,8 +491,7 @@ protected void handleAssignments(TaskService taskService, String assignee, Strin protected Collection extractCandidates(Object value) { if (value instanceof Collection) { return (Collection) value; - } else if (value instanceof ArrayNode) { - ArrayNode valueArrayNode = (ArrayNode) value; + } else if (value instanceof ArrayNode valueArrayNode) { Collection candidates = new ArrayList<>(valueArrayNode.size()); for (JsonNode node : valueArrayNode) { candidates.add(node.asText()); @@ -533,4 +532,4 @@ protected String getOwnerValue(UserTask userTask, MigrationContext migrationCont return userTask.getOwner(); } } -} \ No newline at end of file +} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/WebServiceActivityBehavior.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/WebServiceActivityBehavior.java index f7b353df30e..9b492138853 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/WebServiceActivityBehavior.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/WebServiceActivityBehavior.java @@ -92,15 +92,13 @@ public void execute(DelegateExecution execution) { List dataInputAssociations = null; List dataOutputAssociations = null; - if (flowElement instanceof SendTask) { - SendTask sendTask = (SendTask) flowElement; + if (flowElement instanceof SendTask sendTask) { ioSpecification = sendTask.getIoSpecification(); operationRef = sendTask.getOperationRef(); dataInputAssociations = sendTask.getDataInputAssociations(); dataOutputAssociations = sendTask.getDataOutputAssociations(); - } else if (flowElement instanceof ServiceTask) { - ServiceTask serviceTask = (ServiceTask) flowElement; + } else if (flowElement instanceof ServiceTask serviceTask) { ioSpecification = serviceTask.getIoSpecification(); operationRef = serviceTask.getOperationRef(); dataInputAssociations = serviceTask.getDataInputAssociations(); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/data/FieldBaseStructureInstance.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/data/FieldBaseStructureInstance.java index 88618bb62d9..93196ea794e 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/data/FieldBaseStructureInstance.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/data/FieldBaseStructureInstance.java @@ -74,9 +74,8 @@ public Object[] toArray() { private Object getFieldValue(int index) { final String fieldName = this.getFieldNameAt(index); final Object fieldValueObject = this.getFieldValue(fieldName); - if (fieldValueObject instanceof ArrayNode) { + if (fieldValueObject instanceof ArrayNode fieldArrayNodeValueObject) { // The field is a Json Array - final ArrayNode fieldArrayNodeValueObject = (ArrayNode) fieldValueObject; final Class fieldParameterType = this.structureDefinition.getFieldParameterTypeAt(index); final ObjectMapper objectMapper = CommandContextUtil.getProcessEngineConfiguration().getObjectMapper(); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/deployer/BpmnDeployer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/deployer/BpmnDeployer.java index 4fc34faded2..fc3d45a3cbc 100755 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/deployer/BpmnDeployer.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/deployer/BpmnDeployer.java @@ -216,8 +216,7 @@ protected void setProcessDefinitionVersionsAndIds(ParsedDeployment parsedDeploym processDefinition.setId(getIdForNewProcessDefinition(processDefinition)); Process process = parsedDeployment.getProcessModelForProcessDefinition(processDefinition); FlowElement initialElement = process.getInitialFlowElement(); - if (initialElement instanceof StartEvent) { - StartEvent startEvent = (StartEvent) initialElement; + if (initialElement instanceof StartEvent startEvent) { if (startEvent.getFormKey() != null) { processDefinition.setHasStartFormKey(true); } @@ -260,8 +259,7 @@ protected void setDerivedProcessDefinitionVersionsAndIds(ParsedDeployment parsed Process process = parsedDeployment.getProcessModelForProcessDefinition(processDefinition); FlowElement initialElement = process.getInitialFlowElement(); - if (initialElement instanceof StartEvent) { - StartEvent startEvent = (StartEvent) initialElement; + if (initialElement instanceof StartEvent startEvent) { if (startEvent.getFormKey() != null) { processDefinition.setHasStartFormKey(true); } @@ -449,8 +447,7 @@ protected boolean localizeFlowElements(Collection flowElements, Obj } } - if (flowElement instanceof SubProcess) { - SubProcess subprocess = (SubProcess) flowElement; + if (flowElement instanceof SubProcess subprocess) { boolean isFlowElementLocalizationChanged = localizeFlowElements(subprocess.getFlowElements(), infoNode); boolean isDataObjectLocalizationChanged = localizeDataObjectElements(subprocess.getDataObjects(), infoNode); if (isFlowElementLocalizationChanged || isDataObjectLocalizationChanged) { diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/deployer/EventSubscriptionManager.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/deployer/EventSubscriptionManager.java index 79e8faf7113..f3abf83f729 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/deployer/EventSubscriptionManager.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/deployer/EventSubscriptionManager.java @@ -143,16 +143,13 @@ protected void updateOldEventSubscriptions(ProcessDefinitionEntity previousProce protected void addEventSubscriptions(ProcessDefinitionEntity processDefinition, org.flowable.bpmn.model.Process process, BpmnModel bpmnModel) { if (CollectionUtil.isNotEmpty(process.getFlowElements())) { for (FlowElement element : process.getFlowElements()) { - if (element instanceof StartEvent) { - StartEvent startEvent = (StartEvent) element; + if (element instanceof StartEvent startEvent) { if (CollectionUtil.isNotEmpty(startEvent.getEventDefinitions())) { EventDefinition eventDefinition = startEvent.getEventDefinitions().get(0); - if (eventDefinition instanceof SignalEventDefinition) { - SignalEventDefinition signalEventDefinition = (SignalEventDefinition) eventDefinition; + if (eventDefinition instanceof SignalEventDefinition signalEventDefinition) { insertSignalEvent(signalEventDefinition, startEvent, processDefinition, bpmnModel); - } else if (eventDefinition instanceof MessageEventDefinition) { - MessageEventDefinition messageEventDefinition = (MessageEventDefinition) eventDefinition; + } else if (eventDefinition instanceof MessageEventDefinition messageEventDefinition) { insertMessageEvent(messageEventDefinition, startEvent, processDefinition, bpmnModel); } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/deployer/TimerManager.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/deployer/TimerManager.java index 76e8b083bbd..e3966f87a64 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/deployer/TimerManager.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/deployer/TimerManager.java @@ -69,12 +69,10 @@ protected List getTimerDeclarations(ProcessDefinitionEntity proc List timers = new ArrayList<>(); if (CollectionUtil.isNotEmpty(process.getFlowElements())) { for (FlowElement element : process.getFlowElements()) { - if (element instanceof StartEvent) { - StartEvent startEvent = (StartEvent) element; + if (element instanceof StartEvent startEvent) { if (CollectionUtil.isNotEmpty(startEvent.getEventDefinitions())) { EventDefinition eventDefinition = startEvent.getEventDefinitions().get(0); - if (eventDefinition instanceof TimerEventDefinition) { - TimerEventDefinition timerEventDefinition = (TimerEventDefinition) eventDefinition; + if (eventDefinition instanceof TimerEventDefinition timerEventDefinition) { TimerJobEntity timerJob = TimerUtil.createTimerEntityForTimerEventDefinition(timerEventDefinition, startEvent, false, null, TimerStartEventJobHandler.TYPE, TimerEventHandler.createConfiguration(startEvent.getId(), timerEventDefinition.getEndDate(), timerEventDefinition.getCalendarName())); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/ErrorPropagation.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/ErrorPropagation.java index 4e98afbd9f4..aada03d1ba6 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/ErrorPropagation.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/ErrorPropagation.java @@ -319,10 +319,9 @@ protected static Map> findCatchingEventsForProcess(String pr List subProcesses = process.findFlowElementsOfType(EventSubProcess.class, true); for (EventSubProcess eventSubProcess : subProcesses) { for (FlowElement flowElement : eventSubProcess.getFlowElements()) { - if (flowElement instanceof StartEvent) { - StartEvent startEvent = (StartEvent) flowElement; - if (CollectionUtil.isNotEmpty(startEvent.getEventDefinitions()) && startEvent.getEventDefinitions().get(0) instanceof ErrorEventDefinition) { - ErrorEventDefinition errorEventDef = (ErrorEventDefinition) startEvent.getEventDefinitions().get(0); + if (flowElement instanceof StartEvent startEvent) { + if (CollectionUtil.isNotEmpty(startEvent.getEventDefinitions()) && startEvent.getEventDefinitions() + .get(0) instanceof ErrorEventDefinition errorEventDef) { String eventErrorCode = retrieveErrorCode(bpmnModel, errorEventDef.getErrorCode()); if (eventErrorCode == null || compareErrorCode == null || eventErrorCode.equals(compareErrorCode)) { @@ -338,9 +337,8 @@ protected static Map> findCatchingEventsForProcess(String pr List boundaryEvents = process.findFlowElementsOfType(BoundaryEvent.class, true); for (BoundaryEvent boundaryEvent : boundaryEvents) { if (boundaryEvent.getAttachedToRefId() != null && CollectionUtil.isNotEmpty(boundaryEvent.getEventDefinitions()) && boundaryEvent - .getEventDefinitions().get(0) instanceof ErrorEventDefinition && !(boundaryEvent.getAttachedToRef() instanceof EventSubProcess)) { + .getEventDefinitions().get(0) instanceof ErrorEventDefinition errorEventDef && !(boundaryEvent.getAttachedToRef() instanceof EventSubProcess)) { - ErrorEventDefinition errorEventDef = (ErrorEventDefinition) boundaryEvent.getEventDefinitions().get(0); String eventErrorCode = retrieveErrorCode(bpmnModel, errorEventDef.getErrorCode()); if (eventErrorCode == null || compareErrorCode == null || eventErrorCode.equals(compareErrorCode)) { @@ -513,11 +511,10 @@ protected static void injectErrorContext(Event event, ExecutionEntity execution, ExpressionManager expressionManager) { for (EventDefinition eventDefinition : event.getEventDefinitions()) { - if (!(eventDefinition instanceof ErrorEventDefinition)) { + if (!(eventDefinition instanceof ErrorEventDefinition definition)) { continue; } - ErrorEventDefinition definition = (ErrorEventDefinition) eventDefinition; IOParameterUtil.processInParameters(event.getInParameters(), errorSourceContainer, execution, expressionManager); String variableName = definition.getErrorVariableName(); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/ErrorThrowingEventListener.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/ErrorThrowingEventListener.java index 52977637f85..b22a5398397 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/ErrorThrowingEventListener.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/ErrorThrowingEventListener.java @@ -35,9 +35,8 @@ public class ErrorThrowingEventListener extends BaseDelegateEventListener { @Override public void onEvent(FlowableEvent event) { - if (isValidEvent(event) && event instanceof FlowableEngineEvent) { + if (isValidEvent(event) && event instanceof FlowableEngineEvent engineEvent) { - FlowableEngineEvent engineEvent = (FlowableEngineEvent) event; CommandContext commandContext = Context.getCommandContext(); if (engineEvent.getProcessDefinitionId() != null && diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/EscalationPropagation.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/EscalationPropagation.java index a4624b37194..06fe05e20d2 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/EscalationPropagation.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/EscalationPropagation.java @@ -231,10 +231,9 @@ protected static Map> findCatchingEventsForProcess(String pr List subProcesses = process.findFlowElementsOfType(EventSubProcess.class, true); for (EventSubProcess eventSubProcess : subProcesses) { for (FlowElement flowElement : eventSubProcess.getFlowElements()) { - if (flowElement instanceof StartEvent) { - StartEvent startEvent = (StartEvent) flowElement; - if (CollectionUtil.isNotEmpty(startEvent.getEventDefinitions()) && startEvent.getEventDefinitions().get(0) instanceof EscalationEventDefinition) { - EscalationEventDefinition escalationEventDef = (EscalationEventDefinition) startEvent.getEventDefinitions().get(0); + if (flowElement instanceof StartEvent startEvent) { + if (CollectionUtil.isNotEmpty(startEvent.getEventDefinitions()) && startEvent.getEventDefinitions() + .get(0) instanceof EscalationEventDefinition escalationEventDef) { String eventEscalationCode = null; if (StringUtils.isNotEmpty(escalationEventDef.getEscalationCode()) && bpmnModel.containsEscalationRef(escalationEventDef.getEscalationCode())) { eventEscalationCode = bpmnModel.getEscalation(escalationEventDef.getEscalationCode()).getEscalationCode(); @@ -254,9 +253,9 @@ protected static Map> findCatchingEventsForProcess(String pr List boundaryEvents = process.findFlowElementsOfType(BoundaryEvent.class, true); for (BoundaryEvent boundaryEvent : boundaryEvents) { - if (boundaryEvent.getAttachedToRefId() != null && CollectionUtil.isNotEmpty(boundaryEvent.getEventDefinitions()) && boundaryEvent.getEventDefinitions().get(0) instanceof EscalationEventDefinition) { + if (boundaryEvent.getAttachedToRefId() != null && CollectionUtil.isNotEmpty(boundaryEvent.getEventDefinitions()) && boundaryEvent.getEventDefinitions() + .get(0) instanceof EscalationEventDefinition escalationEventDef) { - EscalationEventDefinition escalationEventDef = (EscalationEventDefinition) boundaryEvent.getEventDefinitions().get(0); String eventEscalationCode = null; if (StringUtils.isNotEmpty(escalationEventDef.getEscalationCode()) && bpmnModel.containsEscalationRef(escalationEventDef.getEscalationCode())) { eventEscalationCode = bpmnModel.getEscalation(escalationEventDef.getEscalationCode()).getEscalationCode(); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/MessageThrowingEventListener.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/MessageThrowingEventListener.java index a2067960c2f..f380ac00c62 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/MessageThrowingEventListener.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/MessageThrowingEventListener.java @@ -38,9 +38,7 @@ public class MessageThrowingEventListener extends BaseDelegateEventListener { @Override public void onEvent(FlowableEvent event) { - if (isValidEvent(event) && event instanceof FlowableEngineEvent) { - - FlowableEngineEvent engineEvent = (FlowableEngineEvent) event; + if (isValidEvent(event) && event instanceof FlowableEngineEvent engineEvent) { if (engineEvent.getProcessInstanceId() == null) { throw new FlowableIllegalArgumentException("Cannot throw process-instance scoped message, since the dispatched event is not part of an ongoing process instance"); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/SignalThrowingEventListener.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/SignalThrowingEventListener.java index 1b997302c47..e7f082922bd 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/SignalThrowingEventListener.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/SignalThrowingEventListener.java @@ -40,9 +40,7 @@ public class SignalThrowingEventListener extends BaseDelegateEventListener { @Override public void onEvent(FlowableEvent event) { - if (isValidEvent(event) && event instanceof FlowableEngineEvent) { - - FlowableEngineEvent engineEvent = (FlowableEngineEvent) event; + if (isValidEvent(event) && event instanceof FlowableEngineEvent engineEvent) { if (engineEvent.getProcessInstanceId() == null && processInstanceScope) { throw new FlowableIllegalArgumentException("Cannot throw process-instance scoped signal, since the dispatched event is not part of an ongoing process instance"); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/listener/ListenerNotificationHelper.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/listener/ListenerNotificationHelper.java index 15ea1941d64..f1a97e7c880 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/listener/ListenerNotificationHelper.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/listener/ListenerNotificationHelper.java @@ -106,8 +106,7 @@ public void executeTaskListeners(TaskEntity taskEntity, String eventType) { if (taskEntity.getProcessDefinitionId() != null) { org.flowable.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(taskEntity.getProcessDefinitionId()); FlowElement flowElement = process.getFlowElement(taskEntity.getTaskDefinitionKey(), true); - if (flowElement instanceof UserTask) { - UserTask userTask = (UserTask) flowElement; + if (flowElement instanceof UserTask userTask) { executeTaskListeners(userTask, taskEntity, eventType); } } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/BpmnParse.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/BpmnParse.java index fef4e620540..a00f26f1ac4 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/BpmnParse.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/BpmnParse.java @@ -389,8 +389,7 @@ public void processDI() { public void createBPMNEdge(String key, List graphicList) { FlowElement flowElement = bpmnModel.getFlowElement(key); - if (flowElement instanceof SequenceFlow) { - SequenceFlow sequenceFlow = (SequenceFlow) flowElement; + if (flowElement instanceof SequenceFlow sequenceFlow) { List waypoints = new ArrayList<>(); for (GraphicInfo waypointInfo : graphicList) { waypoints.add((int) waypointInfo.getX()); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/CancelEventDefinitionParseHandler.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/CancelEventDefinitionParseHandler.java index 40fbc7c5c2f..d129188b6fb 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/CancelEventDefinitionParseHandler.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/CancelEventDefinitionParseHandler.java @@ -30,8 +30,7 @@ public Class getHandledType() { @Override protected void executeParse(BpmnParse bpmnParse, CancelEventDefinition cancelEventDefinition) { - if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) { - BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement(); + if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent boundaryEvent) { boundaryEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryCancelEventActivityBehavior(cancelEventDefinition)); } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/CompensateEventDefinitionParseHandler.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/CompensateEventDefinitionParseHandler.java index 686c71f9fc0..0cf6fe49600 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/CompensateEventDefinitionParseHandler.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/CompensateEventDefinitionParseHandler.java @@ -32,13 +32,11 @@ public Class getHandledType() { @Override protected void executeParse(BpmnParse bpmnParse, CompensateEventDefinition eventDefinition) { - if (bpmnParse.getCurrentFlowElement() instanceof ThrowEvent) { - ThrowEvent throwEvent = (ThrowEvent) bpmnParse.getCurrentFlowElement(); + if (bpmnParse.getCurrentFlowElement() instanceof ThrowEvent throwEvent) { throwEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateThrowCompensationEventActivityBehavior( throwEvent, eventDefinition)); - } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) { - BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement(); + } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent boundaryEvent) { boundaryEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryCompensateEventActivityBehavior(boundaryEvent, eventDefinition, boundaryEvent.isCancelActivity())); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/ConditionalEventDefinitionParseHandler.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/ConditionalEventDefinitionParseHandler.java index 53cec91430e..29920bf6169 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/ConditionalEventDefinitionParseHandler.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/ConditionalEventDefinitionParseHandler.java @@ -30,14 +30,12 @@ public Class getHandledType() { @Override protected void executeParse(BpmnParse bpmnParse, ConditionalEventDefinition eventDefinition) { - if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) { - IntermediateCatchEvent intermediateCatchEvent = (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement(); + if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent intermediateCatchEvent) { intermediateCatchEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateCatchConditionalEventActivityBehavior( intermediateCatchEvent, eventDefinition, eventDefinition.getConditionExpression(), eventDefinition.getConditionLanguage())); - } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) { - BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement(); - + } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent boundaryEvent) { + boundaryEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryConditionalEventActivityBehavior(boundaryEvent, eventDefinition, eventDefinition.getConditionExpression(), eventDefinition.getConditionLanguage(), boundaryEvent.isCancelActivity())); } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/EndEventParseHandler.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/EndEventParseHandler.java index 631f0807b1b..f4295bba2cb 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/EndEventParseHandler.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/EndEventParseHandler.java @@ -45,8 +45,7 @@ protected void executeParse(BpmnParse bpmnParse, EndEvent endEvent) { if (endEvent.getEventDefinitions().size() > 0) { eventDefinition = endEvent.getEventDefinitions().get(0); - if (eventDefinition instanceof ErrorEventDefinition) { - ErrorEventDefinition errorDefinition = (ErrorEventDefinition) eventDefinition; + if (eventDefinition instanceof ErrorEventDefinition errorDefinition) { if (bpmnParse.getBpmnModel().containsErrorRef(errorDefinition.getErrorCode())) { String errorCode = bpmnParse.getBpmnModel().getErrors().get(errorDefinition.getErrorCode()); if (StringUtils.isEmpty(errorCode)) { @@ -55,8 +54,7 @@ protected void executeParse(BpmnParse bpmnParse, EndEvent endEvent) { } endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createErrorEndEventActivityBehavior(endEvent, errorDefinition)); - } else if (eventDefinition instanceof EscalationEventDefinition) { - EscalationEventDefinition escalationDefinition = (EscalationEventDefinition) eventDefinition; + } else if (eventDefinition instanceof EscalationEventDefinition escalationDefinition) { Escalation escalation = null; if (bpmnParse.getBpmnModel().containsEscalationRef(escalationDefinition.getEscalationCode())) { escalation = bpmnParse.getBpmnModel().getEscalation(escalationDefinition.getEscalationCode()); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/ErrorEventDefinitionParseHandler.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/ErrorEventDefinitionParseHandler.java index 6744832023c..7800ea28cb8 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/ErrorEventDefinitionParseHandler.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/ErrorEventDefinitionParseHandler.java @@ -30,8 +30,7 @@ public Class getHandledType() { @Override protected void executeParse(BpmnParse bpmnParse, ErrorEventDefinition eventDefinition) { - if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) { - BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement(); + if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent boundaryEvent) { boundaryEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior(boundaryEvent, true)); } } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/EscalationEventDefinitionParseHandler.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/EscalationEventDefinitionParseHandler.java index 453dd3c526f..cbbf7861b58 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/EscalationEventDefinitionParseHandler.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/EscalationEventDefinitionParseHandler.java @@ -30,9 +30,8 @@ public Class getHandledType() { @Override protected void executeParse(BpmnParse bpmnParse, EscalationEventDefinition eventDefinition) { - if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) { - BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement(); - + if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent boundaryEvent) { + Escalation escalation = null; if (bpmnParse.getBpmnModel().containsEscalationRef(eventDefinition.getEscalationCode())) { escalation = bpmnParse.getBpmnModel().getEscalation(eventDefinition.getEscalationCode()); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/IntermediateThrowEventParseHandler.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/IntermediateThrowEventParseHandler.java index 0bf711b7fcb..cf66fb990b5 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/IntermediateThrowEventParseHandler.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/IntermediateThrowEventParseHandler.java @@ -42,18 +42,15 @@ protected void executeParse(BpmnParse bpmnParse, ThrowEvent intermediateEvent) { eventDefinition = intermediateEvent.getEventDefinitions().get(0); } - if (eventDefinition instanceof SignalEventDefinition) { - SignalEventDefinition signalEventDefinition = (SignalEventDefinition) eventDefinition; + if (eventDefinition instanceof SignalEventDefinition signalEventDefinition) { intermediateEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateThrowSignalEventActivityBehavior(intermediateEvent, signalEventDefinition, bpmnParse.getBpmnModel().getSignal(signalEventDefinition.getSignalRef()))); - } else if (eventDefinition instanceof EscalationEventDefinition) { - EscalationEventDefinition escalationEventDefinition = (EscalationEventDefinition) eventDefinition; + } else if (eventDefinition instanceof EscalationEventDefinition escalationEventDefinition) { intermediateEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateThrowEscalationEventActivityBehavior(intermediateEvent, escalationEventDefinition, bpmnParse.getBpmnModel().getEscalation(escalationEventDefinition.getEscalationCode()))); - } else if (eventDefinition instanceof CompensateEventDefinition) { - CompensateEventDefinition compensateEventDefinition = (CompensateEventDefinition) eventDefinition; + } else if (eventDefinition instanceof CompensateEventDefinition compensateEventDefinition) { intermediateEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateThrowCompensationEventActivityBehavior(intermediateEvent, compensateEventDefinition)); } else if (eventDefinition == null) { diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/MessageEventDefinitionParseHandler.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/MessageEventDefinitionParseHandler.java index 5747c30948b..4840a1d58ce 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/MessageEventDefinitionParseHandler.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/MessageEventDefinitionParseHandler.java @@ -49,12 +49,10 @@ protected void executeParse(BpmnParse bpmnParse, MessageEventDefinition messageD } } - if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) { - IntermediateCatchEvent intermediateCatchEvent = (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement(); + if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent intermediateCatchEvent) { intermediateCatchEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateCatchMessageEventActivityBehavior(intermediateCatchEvent, messageDefinition)); - } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) { - BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement(); + } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent boundaryEvent) { boundaryEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryMessageEventActivityBehavior(boundaryEvent, messageDefinition, boundaryEvent.isCancelActivity())); } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/SignalEventDefinitionParseHandler.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/SignalEventDefinitionParseHandler.java index 45a45795ceb..dd5b2277dc7 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/SignalEventDefinitionParseHandler.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/SignalEventDefinitionParseHandler.java @@ -35,12 +35,10 @@ protected void executeParse(BpmnParse bpmnParse, SignalEventDefinition signalDef Signal signal = bpmnParse.getBpmnModel().getSignal(signalDefinition.getSignalRef()); - if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) { - IntermediateCatchEvent intermediateCatchEvent = (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement(); + if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent intermediateCatchEvent) { intermediateCatchEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateCatchSignalEventActivityBehavior(intermediateCatchEvent, signalDefinition, signal)); - } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) { - BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement(); + } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent boundaryEvent) { boundaryEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createBoundarySignalEventActivityBehavior(boundaryEvent, signalDefinition, signal, boundaryEvent.isCancelActivity())); } } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/StartEventParseHandler.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/StartEventParseHandler.java index dfb268b5f97..69074187b77 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/StartEventParseHandler.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/StartEventParseHandler.java @@ -53,15 +53,13 @@ protected void executeParse(BpmnParse bpmnParse, StartEvent element) { MessageEventDefinition messageDefinition = fillMessageRef(bpmnParse, eventDefinition); element.setBehavior(bpmnParse.getActivityBehaviorFactory().createEventSubProcessMessageStartEventActivityBehavior(element, messageDefinition)); - } else if (eventDefinition instanceof SignalEventDefinition) { - SignalEventDefinition signalDefinition = (SignalEventDefinition) eventDefinition; + } else if (eventDefinition instanceof SignalEventDefinition signalDefinition) { Signal signal = bpmnParse.getBpmnModel().getSignal(signalDefinition.getSignalRef()); element.setBehavior(bpmnParse.getActivityBehaviorFactory().createEventSubProcessSignalStartEventActivityBehavior( element, signalDefinition, signal)); - } else if (eventDefinition instanceof TimerEventDefinition) { - TimerEventDefinition timerEventDefinition = (TimerEventDefinition) eventDefinition; + } else if (eventDefinition instanceof TimerEventDefinition timerEventDefinition) { element.setBehavior(bpmnParse.getActivityBehaviorFactory().createEventSubProcessTimerStartEventActivityBehavior( element, timerEventDefinition)); @@ -71,8 +69,7 @@ protected void executeParse(BpmnParse bpmnParse, StartEvent element) { } else if (eventDefinition instanceof EscalationEventDefinition) { element.setBehavior(bpmnParse.getActivityBehaviorFactory().createEventSubProcessEscalationStartEventActivityBehavior(element)); - } else if (eventDefinition instanceof VariableListenerEventDefinition) { - VariableListenerEventDefinition variableListenerEventDefinition = (VariableListenerEventDefinition) eventDefinition; + } else if (eventDefinition instanceof VariableListenerEventDefinition variableListenerEventDefinition) { element.setBehavior(bpmnParse.getActivityBehaviorFactory().createEventSubProcessVariableListenerlStartEventActivityBehavior(element, variableListenerEventDefinition)); } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/TimerEventDefinitionParseHandler.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/TimerEventDefinitionParseHandler.java index 57fcbc34245..c314f7e84c8 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/TimerEventDefinitionParseHandler.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/TimerEventDefinitionParseHandler.java @@ -31,14 +31,12 @@ public Class getHandledType() { @Override protected void executeParse(BpmnParse bpmnParse, TimerEventDefinition timerEventDefinition) { - if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) { + if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent intermediateCatchEvent) { - IntermediateCatchEvent intermediateCatchEvent = (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement(); intermediateCatchEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateCatchTimerEventActivityBehavior(intermediateCatchEvent, timerEventDefinition)); - } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) { + } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent boundaryEvent) { - BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement(); boundaryEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryTimerEventActivityBehavior(boundaryEvent, timerEventDefinition, boundaryEvent.isCancelActivity())); } } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/VariableListenerEventDefinitionParseHandler.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/VariableListenerEventDefinitionParseHandler.java index f9e95efc4cd..e3a4252caac 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/VariableListenerEventDefinitionParseHandler.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/VariableListenerEventDefinitionParseHandler.java @@ -32,12 +32,10 @@ public Class getHandledType() { @Override protected void executeParse(BpmnParse bpmnParse, VariableListenerEventDefinition variableListenerEventDefinition) { - if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) { - IntermediateCatchEvent intermediateCatchEvent = (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement(); + if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent intermediateCatchEvent) { intermediateCatchEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateCatchVariableListenerEventActivityBehavior(intermediateCatchEvent, variableListenerEventDefinition)); - } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) { - BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement(); + } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent boundaryEvent) { boundaryEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryVariableListenerEventActivityBehavior(boundaryEvent, variableListenerEventDefinition, boundaryEvent.isCancelActivity())); } } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/webservice/MessageImplicitDataInputAssociation.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/webservice/MessageImplicitDataInputAssociation.java index 2f2ee54db90..3f7125d7538 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/webservice/MessageImplicitDataInputAssociation.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/webservice/MessageImplicitDataInputAssociation.java @@ -36,8 +36,7 @@ public void evaluate(DelegateExecution execution) { if (StringUtils.isNotEmpty(this.source)) { Object value = execution.getVariable(this.source); MessageInstance message = (MessageInstance) execution.getTransientVariable(WebServiceActivityBehavior.CURRENT_MESSAGE); - if (message.getStructureInstance() instanceof FieldBaseStructureInstance) { - FieldBaseStructureInstance structure = (FieldBaseStructureInstance) message.getStructureInstance(); + if (message.getStructureInstance() instanceof FieldBaseStructureInstance structure) { structure.setFieldValue(this.target, value); } } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/webservice/MessageImplicitDataOutputAssociation.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/webservice/MessageImplicitDataOutputAssociation.java index 48db89200fd..fb260008531 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/webservice/MessageImplicitDataOutputAssociation.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/webservice/MessageImplicitDataOutputAssociation.java @@ -38,8 +38,7 @@ public MessageImplicitDataOutputAssociation(String targetRef, String sourceRef) @Override public void evaluate(DelegateExecution execution) { MessageInstance message = (MessageInstance) execution.getTransientVariable(WebServiceActivityBehavior.CURRENT_MESSAGE); - if (message.getStructureInstance() instanceof FieldBaseStructureInstance) { - FieldBaseStructureInstance structure = (FieldBaseStructureInstance) message.getStructureInstance(); + if (message.getStructureInstance() instanceof FieldBaseStructureInstance structure) { execution.setVariable(this.getTarget(), structure.getFieldValue(this.getSource())); } } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cfg/DefaultInternalJobManager.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cfg/DefaultInternalJobManager.java index bb7253aac6c..7d987856caa 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cfg/DefaultInternalJobManager.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cfg/DefaultInternalJobManager.java @@ -122,14 +122,12 @@ protected boolean handleJobInsertInternal(Job job) { CountingExecutionEntity countingExecutionEntity = (CountingExecutionEntity) execution; - if (job instanceof TimerJobEntity) { - TimerJobEntity timerJobEntity = (TimerJobEntity) job; + if (job instanceof TimerJobEntity timerJobEntity) { if (CountingEntityUtil.isExecutionRelatedEntityCountEnabled(execution)) { countingExecutionEntity.setTimerJobCount(countingExecutionEntity.getTimerJobCount() + 1); } - } else if (job instanceof JobEntity) { - JobEntity jobEntity = (JobEntity) job; + } else if (job instanceof JobEntity jobEntity) { if (CountingEntityUtil.isExecutionRelatedEntityCountEnabled(execution)) { countingExecutionEntity.setJobCount(countingExecutionEntity.getJobCount() + 1); @@ -287,16 +285,14 @@ protected void preRepeatedTimerScheduleInternal(TimerJobEntity ti, VariableScope protected int getMaxIterations(org.flowable.bpmn.model.Process process, String activityId) { FlowElement flowElement = process.getFlowElement(activityId, true); if (flowElement != null) { - if (flowElement instanceof Event) { + if (flowElement instanceof Event event) { - Event event = (Event) flowElement; List eventDefinitions = event.getEventDefinitions(); if (eventDefinitions != null) { for (EventDefinition eventDefinition : eventDefinitions) { - if (eventDefinition instanceof TimerEventDefinition) { - TimerEventDefinition timerEventDefinition = (TimerEventDefinition) eventDefinition; + if (eventDefinition instanceof TimerEventDefinition timerEventDefinition) { if (timerEventDefinition.getTimeCycle() != null) { return calculateMaxIterationsValue(timerEventDefinition.getTimeCycle()); } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cfg/ProcessEngineConfigurationImpl.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cfg/ProcessEngineConfigurationImpl.java index d34069382b9..965235093b0 100755 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cfg/ProcessEngineConfigurationImpl.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cfg/ProcessEngineConfigurationImpl.java @@ -2126,8 +2126,7 @@ public void initIdGenerator() { idGenerator = dbIdGenerator; } - if (idGenerator instanceof DbIdGenerator) { - DbIdGenerator dbIdGenerator = (DbIdGenerator) idGenerator; + if (idGenerator instanceof DbIdGenerator dbIdGenerator) { if (dbIdGenerator.getIdBlockSize() == 0) { dbIdGenerator.setIdBlockSize(idBlockSize); } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/ExecuteActivityForAdhocSubProcessCmd.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/ExecuteActivityForAdhocSubProcessCmd.java index a64653ce2a7..e545db77a0e 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/ExecuteActivityForAdhocSubProcessCmd.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/ExecuteActivityForAdhocSubProcessCmd.java @@ -47,12 +47,11 @@ public Execution execute(CommandContext commandContext) { throw new FlowableObjectNotFoundException("No execution found for id '" + executionId + "'", ExecutionEntity.class); } - if (!(execution.getCurrentFlowElement() instanceof AdhocSubProcess)) { + if (!(execution.getCurrentFlowElement() instanceof AdhocSubProcess adhocSubProcess)) { throw new FlowableException("The current flow element of the requested " + execution + " is not an ad-hoc sub process"); } FlowNode foundNode = null; - AdhocSubProcess adhocSubProcess = (AdhocSubProcess) execution.getCurrentFlowElement(); // if sequential ordering, only one child execution can be active if (adhocSubProcess.hasSequentialOrdering()) { @@ -62,8 +61,7 @@ public Execution execute(CommandContext commandContext) { } for (FlowElement flowElement : adhocSubProcess.getFlowElements()) { - if (activityId.equals(flowElement.getId()) && flowElement instanceof FlowNode) { - FlowNode flowNode = (FlowNode) flowElement; + if (activityId.equals(flowElement.getId()) && flowElement instanceof FlowNode flowNode) { if (flowNode.getIncomingFlows().size() == 0) { foundNode = flowNode; } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetEnabledActivitiesForAdhocSubProcessCmd.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetEnabledActivitiesForAdhocSubProcessCmd.java index 5124ebaac3b..44a45296241 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetEnabledActivitiesForAdhocSubProcessCmd.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetEnabledActivitiesForAdhocSubProcessCmd.java @@ -46,14 +46,12 @@ public List execute(CommandContext commandContext) { throw new FlowableObjectNotFoundException("No execution found for id '" + executionId + "'", ExecutionEntity.class); } - if (!(execution.getCurrentFlowElement() instanceof AdhocSubProcess)) { + if (!(execution.getCurrentFlowElement() instanceof AdhocSubProcess adhocSubProcess)) { throw new FlowableException("The current flow element of the requested " + execution + " is not an ad-hoc sub process"); } List enabledFlowNodes = new ArrayList<>(); - AdhocSubProcess adhocSubProcess = (AdhocSubProcess) execution.getCurrentFlowElement(); - // if sequential ordering, only one child execution can be active, so no enabled activities if (adhocSubProcess.hasSequentialOrdering()) { if (execution.getExecutions().size() > 0) { @@ -62,8 +60,7 @@ public List execute(CommandContext commandContext) { } for (FlowElement flowElement : adhocSubProcess.getFlowElements()) { - if (flowElement instanceof FlowNode) { - FlowNode flowNode = (FlowNode) flowElement; + if (flowElement instanceof FlowNode flowNode) { if (flowNode.getIncomingFlows().size() == 0) { enabledFlowNodes.add(flowNode); } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetStartFormModelCmd.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetStartFormModelCmd.java index 651b02793bd..b9310d41c71 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetStartFormModelCmd.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetStartFormModelCmd.java @@ -60,8 +60,7 @@ public FormInfo execute(CommandContext commandContext) { BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionId); Process process = bpmnModel.getProcessById(processDefinition.getKey()); FlowElement startElement = process.getInitialFlowElement(); - if (startElement instanceof StartEvent) { - StartEvent startEvent = (StartEvent) startElement; + if (startElement instanceof StartEvent startEvent) { if (StringUtils.isNotEmpty(startEvent.getFormKey())) { Deployment deployment = CommandContextUtil.getDeploymentEntityManager(commandContext).findById(processDefinition.getDeploymentId()); formInfo = formService.getFormInstanceModelByKeyAndParentDeploymentId(startEvent.getFormKey(), deployment.getParentDeploymentId(), diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/InjectEmbeddedSubProcessInProcessInstanceCmd.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/InjectEmbeddedSubProcessInProcessInstanceCmd.java index c2915a038b3..0e5fa7b5710 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/InjectEmbeddedSubProcessInProcessInstanceCmd.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/InjectEmbeddedSubProcessInProcessInstanceCmd.java @@ -73,8 +73,7 @@ protected void updateExecutions(CommandContext commandContext, ProcessDefinition StartEvent initialEvent = null; for (FlowElement subElement : subProcess.getFlowElements()) { - if (subElement instanceof StartEvent) { - StartEvent startEvent = (StartEvent) subElement; + if (subElement instanceof StartEvent startEvent) { if (startEvent.getEventDefinitions().size() == 0) { initialEvent = startEvent; break; @@ -91,4 +90,4 @@ protected void updateExecutions(CommandContext commandContext, ProcessDefinition Context.getAgenda().planContinueProcessOperation(childExecution); } -} \ No newline at end of file +} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/InjectParallelUserTaskCmd.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/InjectParallelUserTaskCmd.java index 27bb8d969e1..37dfa058bcf 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/InjectParallelUserTaskCmd.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/InjectParallelUserTaskCmd.java @@ -65,11 +65,9 @@ protected void updateBpmnProcess(CommandContext commandContext, Process process, ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext); TaskEntity taskEntity = processEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId); FlowElement flowElement = process.getFlowElement(taskEntity.getTaskDefinitionKey(), true); - if (!(flowElement instanceof UserTask)) { + if (!(flowElement instanceof UserTask userTask)) { throw new FlowableException("No UserTask instance found for " + taskEntity); } - - UserTask userTask = (UserTask) flowElement; SubProcess subProcess = new SubProcess(); String subProcessId = dynamicUserTaskBuilder.nextSubProcessId(process.getFlowElementMap()); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/StartProcessInstanceCmd.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/StartProcessInstanceCmd.java index 34caec43b0d..b9a281af6c7 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/StartProcessInstanceCmd.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/StartProcessInstanceCmd.java @@ -152,8 +152,7 @@ protected ProcessInstance handleProcessInstanceWithForm(CommandContext commandCo FormInfo formInfo = null; Map processVariables = null; if (hasStartFormData()) { - if (startElement instanceof StartEvent) { - StartEvent startEvent = (StartEvent) startElement; + if (startElement instanceof StartEvent startEvent) { String startFormKey = startEvent.getFormKey(); if (StringUtils.isNotEmpty(startFormKey)) { FormRepositoryService formRepositoryService = CommandContextUtil.getFormRepositoryService(commandContext); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/TriggerCaseTaskCmd.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/TriggerCaseTaskCmd.java index bcca0eba245..7fa049776ee 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/TriggerCaseTaskCmd.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/TriggerCaseTaskCmd.java @@ -57,11 +57,9 @@ public Void execute(CommandContext commandContext) { } FlowElement flowElement = execution.getCurrentFlowElement(); - if (!(flowElement instanceof CaseServiceTask)) { + if (!(flowElement instanceof CaseServiceTask caseServiceTask)) { throw new FlowableException("No execution could be found with a case service task for " + execution); } - - CaseServiceTask caseServiceTask = (CaseServiceTask) flowElement; Object behavior = caseServiceTask.getBehavior(); if (behavior instanceof CaseTaskActivityBehavior) { diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/AbstractDynamicStateManager.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/AbstractDynamicStateManager.java index 463ff28aa45..20c77cee8f2 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/AbstractDynamicStateManager.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/AbstractDynamicStateManager.java @@ -511,8 +511,7 @@ protected void doMoveExecutionState(ProcessInstanceChangeState processInstanceCh List boundaryEvents = ((Activity) execution.getCurrentFlowElement()).getBoundaryEvents(); if (boundaryEvents != null && !boundaryEvents.isEmpty()) { for (ExecutionEntity executionEntity : executionEntityManager.collectChildren(execution)) { - if (executionEntity.getCurrentFlowElement() != null && executionEntity.getCurrentFlowElement() instanceof BoundaryEvent) { - BoundaryEvent boundaryEvent = (BoundaryEvent) executionEntity.getCurrentFlowElement(); + if (executionEntity.getCurrentFlowElement() instanceof BoundaryEvent boundaryEvent) { if (newBoundaryEventMap.containsKey(boundaryEvent.getId()) && sameBoundaryEventDefinition(boundaryEvent, newBoundaryEventMap.get(boundaryEvent.getId()))) { boolean hasEventSubscriptions = false; @@ -632,12 +631,11 @@ protected void doMoveExecutionState(ProcessInstanceChangeState processInstanceCh continue; } - if (newChildExecution.getCurrentFlowElement() instanceof Task && ((Task) newChildExecution.getCurrentFlowElement()).isAsynchronous()) { + if (newChildExecution.getCurrentFlowElement() instanceof Task task && task.isAsynchronous()) { JobService jobService = CommandContextUtil.getJobService(commandContext); JobEntity job = JobUtil.createJob(newChildExecution, newChildExecution.getCurrentFlowElement(), AsyncContinuationJobHandler.TYPE, CommandContextUtil.getProcessEngineConfiguration(commandContext)); - - Task task = (Task) newChildExecution.getCurrentFlowElement(); + jobService.createAsyncJob(job, task.isExclusive()); jobService.scheduleAsyncJob(job); @@ -741,8 +739,7 @@ protected ExecutionEntity deleteParentExecutions(String parentExecutionId, Colle ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(commandContext); ExecutionEntity parentExecution = executionEntityManager.findById(parentExecutionId); - if (parentExecution != null && parentExecution.getCurrentFlowElement() instanceof SubProcess) { - SubProcess parentSubProcess = (SubProcess) parentExecution.getCurrentFlowElement(); + if (parentExecution != null && parentExecution.getCurrentFlowElement() instanceof SubProcess parentSubProcess) { if (!isSubProcessAncestorOfAnyNewFlowElements(parentSubProcess.getId(), moveToFlowElements)) { ExecutionEntity toDeleteParentExecution = resolveParentExecutionToDelete(parentExecution, moveToFlowElements); ExecutionEntity finalDeleteExecution = null; @@ -770,8 +767,7 @@ protected ExecutionEntity deleteDirectParentExecutions(String parentExecutionId, ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(commandContext); ExecutionEntity parentExecution = executionEntityManager.findById(parentExecutionId); - if (parentExecution.getCurrentFlowElement() instanceof SubProcess) { - SubProcess parentSubProcess = (SubProcess) parentExecution.getCurrentFlowElement(); + if (parentExecution.getCurrentFlowElement() instanceof SubProcess parentSubProcess) { if (!isSubProcessContainerOfAnyFlowElement(parentSubProcess.getId(), moveToFlowElements)) { if (parentSubProcess.getLoopCharacteristics() == null || moveExecutionContainer.getMoveToFlowElement(parentSubProcess.getId()) != null) { ExecutionEntity toDeleteParentExecution = resolveParentExecutionToDelete(parentExecution, moveToFlowElements); @@ -926,7 +922,7 @@ protected List createEmbeddedSubProcessAndExecutions(Collection } - if (newFlowElement instanceof CallActivity && !moveExecutionEntityContainer.isDirectExecutionMigration()) { + if (newFlowElement instanceof CallActivity callActivity && !moveExecutionEntityContainer.isDirectExecutionMigration()) { if (!newChildExecution.isMultiInstanceRoot()) { processEngineConfiguration.getActivityInstanceEntityManager().recordActivityStart(newChildExecution); @@ -941,7 +937,6 @@ protected List createEmbeddedSubProcessAndExecutions(Collection } // start boundary events of new call activity - CallActivity callActivity = (CallActivity) newFlowElement; List boundaryEvents = callActivity.getBoundaryEvents(); if (CollectionUtil.isNotEmpty(boundaryEvents)) { executeBoundaryEvents(boundaryEvents, newChildExecution); @@ -1569,8 +1564,7 @@ protected void processCreatedEventSubProcess(EventSubProcess eventSubProcess, Ex } } else { // For non-interrupting, we register a subscription and startEvent execution if they don't exist already - if (eventDefinition instanceof MessageEventDefinition && (eventSubscriptions == null || eventSubscriptions.isEmpty())) { - MessageEventDefinition messageEventDefinition = (MessageEventDefinition) eventDefinition; + if (eventDefinition instanceof MessageEventDefinition messageEventDefinition && (eventSubscriptions == null || eventSubscriptions.isEmpty())) { BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(eventSubProcessExecution.getProcessDefinitionId()); if (bpmnModel.containsMessageId(messageEventDefinition.getMessageRef())) { messageEventDefinition.setMessageRef(bpmnModel.getMessage(messageEventDefinition.getMessageRef()).getName()); @@ -1602,8 +1596,7 @@ protected void processCreatedEventSubProcess(EventSubProcess eventSubProcess, Ex processEngineConfiguration.getEngineCfgKey()); } - if (eventDefinition instanceof SignalEventDefinition && (eventSubscriptions == null || eventSubscriptions.isEmpty())) { - SignalEventDefinition signalEventDefinition = (SignalEventDefinition) eventDefinition; + if (eventDefinition instanceof SignalEventDefinition signalEventDefinition && (eventSubscriptions == null || eventSubscriptions.isEmpty())) { BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(eventSubProcessExecution.getProcessDefinitionId()); Signal signal = bpmnModel.getSignal(signalEventDefinition.getSignalRef()); if (signal != null) { @@ -1639,10 +1632,9 @@ protected void processCreatedEventSubProcess(EventSubProcess eventSubProcess, Ex } - if (eventDefinition instanceof TimerEventDefinition) { + if (eventDefinition instanceof TimerEventDefinition timerEventDefinition) { if (!startEventExecution.isPresent()) { - TimerEventDefinition timerEventDefinition = (TimerEventDefinition) eventDefinition; ExecutionEntity timerExecution = processEngineConfiguration.getExecutionEntityManager().createChildExecution(eventSubProcessExecution.getParent()); timerExecution.setCurrentFlowElement(startEvent); timerExecution.setEventScope(true); @@ -1679,8 +1671,7 @@ protected boolean sameBoundaryEventDefinition(BoundaryEvent sourceEvent, Boundar return false; } - if (sourceEventDef instanceof SignalEventDefinition) { - SignalEventDefinition signalSourceDef = (SignalEventDefinition) sourceEventDef; + if (sourceEventDef instanceof SignalEventDefinition signalSourceDef) { SignalEventDefinition signalTargetDef = (SignalEventDefinition) targetEventDef; if (StringUtils.isNotEmpty(signalSourceDef.getSignalRef()) && signalSourceDef.getSignalRef().equals(signalTargetDef.getSignalRef())) { @@ -1691,8 +1682,7 @@ protected boolean sameBoundaryEventDefinition(BoundaryEvent sourceEvent, Boundar return true; } - } else if (sourceEventDef instanceof MessageEventDefinition) { - MessageEventDefinition messageSourceDef = (MessageEventDefinition) sourceEventDef; + } else if (sourceEventDef instanceof MessageEventDefinition messageSourceDef) { MessageEventDefinition messageTargetDef = (MessageEventDefinition) targetEventDef; if (StringUtils.isNotEmpty(messageSourceDef.getMessageRef()) && messageSourceDef.getMessageRef().equals(messageTargetDef.getMessageRef())) { @@ -1703,8 +1693,7 @@ protected boolean sameBoundaryEventDefinition(BoundaryEvent sourceEvent, Boundar return true; } - } else if (sourceEventDef instanceof TimerEventDefinition) { - TimerEventDefinition timerSourceDef = (TimerEventDefinition) sourceEventDef; + } else if (sourceEventDef instanceof TimerEventDefinition timerSourceDef) { TimerEventDefinition timerTargetDef = (TimerEventDefinition) targetEventDef; if (StringUtils.isNotEmpty(timerSourceDef.getTimeCycle()) && timerSourceDef.getTimeCycle().equals(timerTargetDef.getTimeCycle())) { diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/BaseDynamicSubProcessInjectUtil.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/BaseDynamicSubProcessInjectUtil.java index af75701f8f4..2762e222d38 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/BaseDynamicSubProcessInjectUtil.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/BaseDynamicSubProcessInjectUtil.java @@ -136,8 +136,7 @@ protected static void generateIdForDuplicateFlowElement(String prefix, org.flowa } for (FlowElement flowElement : duplicateFlowElement.getParentContainer().getFlowElements()) { - if (flowElement instanceof SequenceFlow) { - SequenceFlow sequenceFlow = (SequenceFlow) flowElement; + if (flowElement instanceof SequenceFlow sequenceFlow) { if (sequenceFlow.getSourceRef().equals(originalFlowElementId)) { sequenceFlow.setSourceRef(newFlowElementId); } @@ -145,16 +144,14 @@ protected static void generateIdForDuplicateFlowElement(String prefix, org.flowa sequenceFlow.setTargetRef(newFlowElementId); } - } else if (flowElement instanceof BoundaryEvent) { - BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement; + } else if (flowElement instanceof BoundaryEvent boundaryEvent) { if (boundaryEvent.getAttachedToRefId().equals(originalFlowElementId)) { boundaryEvent.setAttachedToRefId(newFlowElementId); } if (boundaryEvent.getEventDefinitions() != null && boundaryEvent.getEventDefinitions().size() > 0 - && (boundaryEvent.getEventDefinitions().get(0) instanceof CompensateEventDefinition)) { - - CompensateEventDefinition compensateEventDefinition = (CompensateEventDefinition) boundaryEvent.getEventDefinitions().get(0); + && (boundaryEvent.getEventDefinitions().get(0) instanceof CompensateEventDefinition compensateEventDefinition)) { + if (compensateEventDefinition.getActivityRef().equals(originalFlowElementId)) { compensateEventDefinition.setActivityRef(newFlowElementId); } @@ -165,8 +162,7 @@ protected static void generateIdForDuplicateFlowElement(String prefix, org.flowa } - if (duplicateFlowElement instanceof FlowElementsContainer) { - FlowElementsContainer flowElementsContainer = (FlowElementsContainer) duplicateFlowElement; + if (duplicateFlowElement instanceof FlowElementsContainer flowElementsContainer) { for (FlowElement childFlowElement : flowElementsContainer.getFlowElements()) { generateIdForDuplicateFlowElement(prefix, process, bpmnModel, subProcessBpmnModel, childFlowElement, generatedIds, includeDiInfo); } @@ -176,10 +172,9 @@ protected static void generateIdForDuplicateFlowElement(String prefix, org.flowa protected static void processUserTask(FlowElement flowElement, ProcessDefinition originalProcessDefinitionEntity, DeploymentEntity newDeploymentEntity, CommandContext commandContext) { - if (flowElement instanceof UserTask) { + if (flowElement instanceof UserTask userTask) { FormRepositoryService formRepositoryService = CommandContextUtil.getFormRepositoryService(); if (formRepositoryService != null) { - UserTask userTask = (UserTask) flowElement; if (StringUtils.isNotEmpty(userTask.getFormKey())) { Deployment deployment = CommandContextUtil.getDeploymentEntityManager().findById(originalProcessDefinitionEntity.getDeploymentId()); if (deployment.getParentDeploymentId() != null) { @@ -205,11 +200,10 @@ protected static void processUserTask(FlowElement flowElement, ProcessDefinition protected static void processDecisionTask(FlowElement flowElement, ProcessDefinition originalProcessDefinitionEntity, DeploymentEntity newDeploymentEntity, CommandContext commandContext) { - if (flowElement instanceof ServiceTask && ServiceTask.DMN_TASK.equals(((ServiceTask) flowElement).getType())) { + if (flowElement instanceof ServiceTask serviceTask && ServiceTask.DMN_TASK.equals(serviceTask.getType())) { DmnRepositoryService dmnRepositoryService = CommandContextUtil.getDmnRepositoryService(); if (dmnRepositoryService != null) { - ServiceTask serviceTask = (ServiceTask) flowElement; if (serviceTask.getFieldExtensions() != null && serviceTask.getFieldExtensions().size() > 0) { String decisionTableReferenceKey = null; for (FieldExtension fieldExtension : serviceTask.getFieldExtensions()) { diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/DynamicSubProcessJoinInjectUtil.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/DynamicSubProcessJoinInjectUtil.java index bf53e2d00e6..e1dbfb338fd 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/DynamicSubProcessJoinInjectUtil.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/DynamicSubProcessJoinInjectUtil.java @@ -52,10 +52,9 @@ public static void injectSubProcessWithJoin(String taskId, Process process, Bpmn ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext); TaskEntity taskEntity = processEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId); FlowElement taskFlowElement = process.getFlowElement(taskEntity.getTaskDefinitionKey(), true); - if (!(taskFlowElement instanceof UserTask)) { + if (!(taskFlowElement instanceof UserTask userTask)) { throw new FlowableException("No UserTask instance found for task definition key " + taskEntity.getTaskDefinitionKey()); } - UserTask userTask = (UserTask) taskFlowElement; if (dynamicEmbeddedSubProcessBuilder.getId() != null && process.getFlowElement(dynamicEmbeddedSubProcessBuilder.getId(), true) != null) { throw new FlowableIllegalArgumentException("Invalid sub-process identifier: identifier already exists in host process definition"); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/el/DateUtil.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/el/DateUtil.java index 31ef9b43c74..2b08f6d6998 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/el/DateUtil.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/el/DateUtil.java @@ -18,8 +18,7 @@ public class DateUtil { public static String format(Object value) { String formattedString = null; - if (value instanceof Date) { - Date date = (Date) value; + if (value instanceof Date date) { formattedString = date.toInstant().toString(); } else { formattedString = value.toString(); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/event/CompensationEventHandler.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/event/CompensationEventHandler.java index 3507c18b4d0..10c57cac3d0 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/event/CompensationEventHandler.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/event/CompensationEventHandler.java @@ -92,8 +92,7 @@ public void handleEvent(EventSubscriptionEntity eventSubscription, Object payloa List associations = process.findAssociationsWithSourceRefRecursive(boundaryEvent.getId()); for (Association association : associations) { FlowElement targetElement = process.getFlowElement(association.getTargetRef(), true); - if (targetElement instanceof Activity) { - Activity targetActivity = (Activity) targetElement; + if (targetElement instanceof Activity targetActivity) { if (targetActivity.isForCompensation()) { compensationActivity = targetActivity; break; diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/event/logger/EventLogger.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/event/logger/EventLogger.java index 90057d1046f..d09eced4ea1 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/event/logger/EventLogger.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/event/logger/EventLogger.java @@ -162,16 +162,14 @@ protected EventLoggerEventHandler getEventHandler(FlowableEvent event) { Class eventHandlerClass = null; if (event.getType().equals(FlowableEngineEventType.ENTITY_INITIALIZED)) { Object entity = ((FlowableEntityEvent) event).getEntity(); - if (entity instanceof ExecutionEntity) { - ExecutionEntity executionEntity = (ExecutionEntity) entity; + if (entity instanceof ExecutionEntity executionEntity) { if (executionEntity.getProcessInstanceId().equals(executionEntity.getId())) { eventHandlerClass = ProcessInstanceStartedEventHandler.class; } } } else if (event.getType().equals(FlowableEngineEventType.ENTITY_DELETED)) { Object entity = ((FlowableEntityEvent) event).getEntity(); - if (entity instanceof ExecutionEntity) { - ExecutionEntity executionEntity = (ExecutionEntity) entity; + if (entity instanceof ExecutionEntity executionEntity) { if (executionEntity.getProcessInstanceId().equals(executionEntity.getId())) { eventHandlerClass = ProcessInstanceEndedEventHandler.class; } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/event/logger/handler/ProcessInstanceStartedEventHandler.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/event/logger/handler/ProcessInstanceStartedEventHandler.java index 556f11e5555..02385c0349d 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/event/logger/handler/ProcessInstanceStartedEventHandler.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/event/logger/handler/ProcessInstanceStartedEventHandler.java @@ -41,8 +41,7 @@ public EventLogEntryEntity generateEventLogEntry(CommandContext commandContext) putInMapIfNotNull(data, Fields.NAME, processInstanceEntity.getName()); putInMapIfNotNull(data, Fields.CREATE_TIME, timeStamp); - if (event instanceof FlowableEntityWithVariablesEvent) { - FlowableEntityWithVariablesEvent eventWithVariables = (FlowableEntityWithVariablesEvent) event; + if (event instanceof FlowableEntityWithVariablesEvent eventWithVariables) { if (eventWithVariables.getVariables() != null && !eventWithVariables.getVariables().isEmpty()) { Map variableMap = new HashMap<>(); for (Object variableName : eventWithVariables.getVariables().keySet()) { diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/event/logger/handler/TaskCompletedEventHandler.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/event/logger/handler/TaskCompletedEventHandler.java index 8d1b218045c..97f7053e962 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/event/logger/handler/TaskCompletedEventHandler.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/event/logger/handler/TaskCompletedEventHandler.java @@ -37,8 +37,7 @@ public EventLogEntryEntity generateEventLogEntry(CommandContext commandContext) long duration = timeStamp.getTime() - task.getCreateTime().getTime(); putInMapIfNotNull(data, Fields.DURATION, duration); - if (event instanceof FlowableEntityWithVariablesEvent) { - FlowableEntityWithVariablesEvent activitiEntityWithVariablesEvent = (FlowableEntityWithVariablesEvent) event; + if (event instanceof FlowableEntityWithVariablesEvent activitiEntityWithVariablesEvent) { if (activitiEntityWithVariablesEvent.getVariables() != null && !activitiEntityWithVariablesEvent.getVariables().isEmpty()) { Map variableMap = new HashMap<>(); for (Object variableName : activitiEntityWithVariablesEvent.getVariables().keySet()) { diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/form/FormHandlerHelper.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/form/FormHandlerHelper.java index 9000d4bf4ea..f0764f9b33b 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/form/FormHandlerHelper.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/form/FormHandlerHelper.java @@ -35,9 +35,7 @@ public StartFormHandler getStartFormHandler(CommandContext commandContext, Proce org.flowable.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinition.getId()); FlowElement initialFlowElement = process.getInitialFlowElement(); - if (initialFlowElement instanceof StartEvent) { - - StartEvent startEvent = (StartEvent) initialFlowElement; + if (initialFlowElement instanceof StartEvent startEvent) { List formProperties = startEvent.getFormProperties(); String formKey = startEvent.getFormKey(); @@ -54,8 +52,7 @@ public StartFormHandler getStartFormHandler(CommandContext commandContext, Proce public TaskFormHandler getTaskFormHandlder(String processDefinitionId, String taskId) { org.flowable.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinitionId); FlowElement flowElement = process.getFlowElement(taskId, true); - if (flowElement instanceof UserTask) { - UserTask userTask = (UserTask) flowElement; + if (flowElement instanceof UserTask userTask) { ProcessDefinition processDefinitionEntity = ProcessDefinitionUtil.getProcessDefinition(processDefinitionId); DeploymentEntity deploymentEntity = CommandContextUtil.getProcessEngineConfiguration() diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/interceptor/CommandInvoker.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/interceptor/CommandInvoker.java index 23638b1e23a..d3dc59104b0 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/interceptor/CommandInvoker.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/interceptor/CommandInvoker.java @@ -175,8 +175,7 @@ protected void executeExecutionListenersAfterException(CommandContext commandCon } public void executeOperation(CommandContext commandContext, Runnable runnable) { - if (runnable instanceof AbstractOperation) { - AbstractOperation operation = (AbstractOperation) runnable; + if (runnable instanceof AbstractOperation operation) { // Execute the operation if the operation has no execution (i.e. it's an operation not working on a process instance) // or the operation has an execution and it is not ended diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/jobexecutor/AsyncSendEventJobHandler.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/jobexecutor/AsyncSendEventJobHandler.java index 7c9e5199c1b..e2f770ebf87 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/jobexecutor/AsyncSendEventJobHandler.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/jobexecutor/AsyncSendEventJobHandler.java @@ -45,13 +45,12 @@ public void execute(JobEntity job, String configuration, VariableScope variableS } Object behavior = ((SendEventServiceTask) flowElement).getBehavior(); - if (!(behavior instanceof ActivityBehavior)) { + if (!(behavior instanceof ActivityBehavior activityBehavior)) { throw new FlowableException( "Unexpected activity behavior (" + behavior.getClass() + ") found for " + job + " at " + executionEntity); } try { - ActivityBehavior activityBehavior = (ActivityBehavior) behavior; commandContext.addAttribute(TYPE, true); // Will be read in the SendEventTaskActivityBehavior activityBehavior.execute(executionEntity); } finally { diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/jobexecutor/ParallelMultiInstanceActivityCompletionJobHandler.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/jobexecutor/ParallelMultiInstanceActivityCompletionJobHandler.java index 080ad5cbb82..eca0a7365e0 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/jobexecutor/ParallelMultiInstanceActivityCompletionJobHandler.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/jobexecutor/ParallelMultiInstanceActivityCompletionJobHandler.java @@ -45,8 +45,7 @@ public void execute(JobEntity job, String configuration, VariableScope variableS FlowElement currentFlowElement = completingExecution.getCurrentFlowElement(); if (currentFlowElement instanceof Activity) { Object behavior = ((Activity) currentFlowElement).getBehavior(); - if (behavior instanceof ParallelMultiInstanceBehavior) { - ParallelMultiInstanceBehavior parallelMultiInstanceBehavior = (ParallelMultiInstanceBehavior) behavior; + if (behavior instanceof ParallelMultiInstanceBehavior parallelMultiInstanceBehavior) { parallelMultiInstanceBehavior.leaveAsync(completingExecution); } } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/jobexecutor/ParallelMultiInstanceWithNoWaitStatesAsyncLeaveJobHandler.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/jobexecutor/ParallelMultiInstanceWithNoWaitStatesAsyncLeaveJobHandler.java index e18cb6f1e9b..e431a7f3344 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/jobexecutor/ParallelMultiInstanceWithNoWaitStatesAsyncLeaveJobHandler.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/jobexecutor/ParallelMultiInstanceWithNoWaitStatesAsyncLeaveJobHandler.java @@ -52,8 +52,7 @@ public void execute(JobEntity job, String configuration, VariableScope variableS FlowElement currentFlowElement = execution.getCurrentFlowElement(); if (currentFlowElement instanceof Activity) { Object behavior = ((Activity) currentFlowElement).getBehavior(); - if (behavior instanceof ParallelMultiInstanceBehavior) { - ParallelMultiInstanceBehavior parallelMultiInstanceBehavior = (ParallelMultiInstanceBehavior) behavior; + if (behavior instanceof ParallelMultiInstanceBehavior parallelMultiInstanceBehavior) { DelegateExecution multiInstanceRootExecution = ExecutionGraphUtil.getMultiInstanceRootExecution(execution); if (multiInstanceRootExecution != null) { @@ -112,4 +111,4 @@ protected void leaveMultiInstance(ProcessEngineConfigurationImpl processEngineCo } -} \ No newline at end of file +} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/migration/ProcessInstanceMigrationManagerImpl.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/migration/ProcessInstanceMigrationManagerImpl.java index d5887b71677..3e15a6f3f8e 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/migration/ProcessInstanceMigrationManagerImpl.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/migration/ProcessInstanceMigrationManagerImpl.java @@ -266,8 +266,7 @@ protected void doValidateActivityMappings(String processInstanceId, List variableByteArrayRefs = new ArrayList<>(); for (VariableInstance variableInstance : executionVariables) { - if (variableInstance instanceof VariableInstanceEntity) { - VariableInstanceEntity variableInstanceEntity = (VariableInstanceEntity) variableInstance; - + if (variableInstance instanceof VariableInstanceEntity variableInstanceEntity) { + if (variableInstanceEntity.getByteArrayRef() != null && variableInstanceEntity.getByteArrayRef().getId() != null) { variableByteArrayRefs.add(variableInstanceEntity.getByteArrayRef()); } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/persistence/entity/HistoricDetailEntityManagerImpl.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/persistence/entity/HistoricDetailEntityManagerImpl.java index bf88a425a20..4157c4c0822 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/persistence/entity/HistoricDetailEntityManagerImpl.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/persistence/entity/HistoricDetailEntityManagerImpl.java @@ -92,8 +92,7 @@ public HistoricDetailVariableInstanceUpdateEntity copyAndInsertHistoricDetailVar public void delete(HistoricDetailEntity entity, boolean fireDeleteEvent) { super.delete(entity, fireDeleteEvent); - if (entity instanceof HistoricDetailVariableInstanceUpdateEntity) { - HistoricDetailVariableInstanceUpdateEntity historicDetailVariableInstanceUpdateEntity = ((HistoricDetailVariableInstanceUpdateEntity) entity); + if (entity instanceof HistoricDetailVariableInstanceUpdateEntity historicDetailVariableInstanceUpdateEntity) { if (historicDetailVariableInstanceUpdateEntity.getByteArrayRef() != null) { historicDetailVariableInstanceUpdateEntity.getByteArrayRef().delete(engineConfiguration.getEngineCfgKey()); } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/scripting/ProcessEngineScriptTraceEnhancer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/scripting/ProcessEngineScriptTraceEnhancer.java index 2d649565fa3..32ac3eb21e5 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/scripting/ProcessEngineScriptTraceEnhancer.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/scripting/ProcessEngineScriptTraceEnhancer.java @@ -35,14 +35,12 @@ public void enhanceScriptTrace(ScriptTraceContext context) { } protected void enhanceScriptTrace(ScriptTraceContext context, VariableContainer container) { - if (container instanceof DelegateExecution) { + if (container instanceof DelegateExecution execution) { context.addTraceTag("scopeType", ScopeTypes.BPMN); - DelegateExecution execution = (DelegateExecution) container; addScopeTags(execution.getProcessDefinitionId(), context); context.addTraceTag("subScopeDefinitionKey", execution.getCurrentActivityId()); addTenantId(context, execution.getTenantId()); - } else if (container instanceof DelegateTask) { - DelegateTask task = (DelegateTask) container; + } else if (container instanceof DelegateTask task) { if (task.getProcessInstanceId() != null) { context.addTraceTag("scopeType", ScopeTypes.BPMN); addScopeTags(task.getProcessDefinitionId(), context); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/test/PluggableFlowableExtension.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/test/PluggableFlowableExtension.java index 20eb372d966..596ec722e41 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/test/PluggableFlowableExtension.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/test/PluggableFlowableExtension.java @@ -90,8 +90,7 @@ protected String getConfigurationResource(ExtensionContext context) { protected void swapCommandInvoker(ProcessEngine processEngine, boolean debug) { CommandExecutor commandExecutor = processEngine.getProcessEngineConfiguration().getCommandExecutor(); - if (commandExecutor instanceof CommandExecutorImpl) { - CommandExecutorImpl commandExecutorImpl = (CommandExecutorImpl) commandExecutor; + if (commandExecutor instanceof CommandExecutorImpl commandExecutorImpl) { CommandInterceptor previousCommandInterceptor = null; CommandInterceptor commandInterceptor = commandExecutorImpl.getFirst(); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/BpmnLoggingSessionUtil.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/BpmnLoggingSessionUtil.java index 6945daf8a54..a15f86b9c3e 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/BpmnLoggingSessionUtil.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/BpmnLoggingSessionUtil.java @@ -255,18 +255,15 @@ public static String getBoundaryEventType(BoundaryEvent boundaryEvent) { protected static String getActivitySubType(FlowElement flowElement) { String activitySubType = null; - if (flowElement instanceof Event) { - Event event = (Event) flowElement; + if (flowElement instanceof Event event) { List eventDefinitions = event.getEventDefinitions(); if (eventDefinitions != null && !eventDefinitions.isEmpty()) { EventDefinition eventDefinition = eventDefinitions.get(0); activitySubType = eventDefinition.getClass().getSimpleName(); } - } else if (flowElement instanceof ServiceTask) { - ServiceTask serviceTask = (ServiceTask) flowElement; - if (serviceTask.getBehavior() != null && serviceTask.getBehavior() instanceof ClassDelegate) { - ClassDelegate classDelegate = (ClassDelegate) serviceTask.getBehavior(); + } else if (flowElement instanceof ServiceTask serviceTask) { + if (serviceTask.getBehavior() != null && serviceTask.getBehavior() instanceof ClassDelegate classDelegate) { activitySubType = classDelegate.getClassName(); } else if (serviceTask.getBehavior() != null && serviceTask.getBehavior() instanceof ServiceTaskExpressionActivityBehavior) { diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/EventInstanceBpmnUtil.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/EventInstanceBpmnUtil.java index 213535fd41f..65158d11820 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/EventInstanceBpmnUtil.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/EventInstanceBpmnUtil.java @@ -47,8 +47,7 @@ public static void handleEventInstanceOutParameters(VariableScope variableScope, .stream() .collect(Collectors.toMap(EventPayloadInstance::getDefinitionName, Function.identity())); - if (baseElement instanceof SendEventServiceTask) { - SendEventServiceTask eventServiceTask = (SendEventServiceTask) baseElement; + if (baseElement instanceof SendEventServiceTask eventServiceTask) { if (!eventServiceTask.getEventOutParameters().isEmpty()) { for (IOParameter parameter : eventServiceTask.getEventOutParameters()) { setEventParameterVariable(parameter.getSource(), parameter.getTarget(), @@ -79,8 +78,7 @@ public static Collection createEventPayloadInstances(Varia BaseElement baseElement, EventModel eventDefinition) { List eventPayloadInstances = new ArrayList<>(); - if (baseElement instanceof SendEventServiceTask) { - SendEventServiceTask eventServiceTask = (SendEventServiceTask) baseElement; + if (baseElement instanceof SendEventServiceTask eventServiceTask) { if (!eventServiceTask.getEventInParameters().isEmpty()) { for (IOParameter parameter : eventServiceTask.getEventInParameters()) { String sourceValue = null; diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/EventSubscriptionUtil.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/EventSubscriptionUtil.java index bc6da8795ed..63d3f55397a 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/EventSubscriptionUtil.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/EventSubscriptionUtil.java @@ -49,8 +49,7 @@ public static void processPayloadMap(Object payload, ExecutionEntity execution, @SuppressWarnings("unchecked") Map payloadMap = (Map) payload; - if (currentFlowElement instanceof Event) { - Event event = (Event) currentFlowElement; + if (currentFlowElement instanceof Event event) { if (event.getInParameters().size() > 0) { VariableContainerWrapper variableWrapper = new VariableContainerWrapper(payloadMap); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/Flowable5Util.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/Flowable5Util.java index 02c2fb076ea..6a5a3364a12 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/Flowable5Util.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/Flowable5Util.java @@ -34,11 +34,10 @@ public class Flowable5Util { public static final String V5_ENGINE_TAG = "v5"; public static boolean isJobHandledByV5Engine(JobInfo jobInfo) { - if (!(jobInfo instanceof Job)) { // v5 only knew one type of jobs + if (!(jobInfo instanceof Job job)) { // v5 only knew one type of jobs return false; } - - final Job job = (Job) jobInfo; + ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(); boolean isFlowable5ProcessDefinition = Flowable5Util.isFlowable5ProcessDefinitionId(processEngineConfiguration, job.getProcessDefinitionId()); if (isFlowable5ProcessDefinition) { diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/ProcessInstanceHelper.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/ProcessInstanceHelper.java index d50533f862a..9977f6ba90e 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/ProcessInstanceHelper.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/ProcessInstanceHelper.java @@ -153,11 +153,10 @@ public ProcessInstance createAndStartProcessInstanceByMessage(ProcessDefinition FlowElement initialFlowElement = null; for (FlowElement flowElement : process.getFlowElements()) { - if (flowElement instanceof StartEvent) { - StartEvent startEvent = (StartEvent) flowElement; - if (CollectionUtil.isNotEmpty(startEvent.getEventDefinitions()) && startEvent.getEventDefinitions().get(0) instanceof MessageEventDefinition) { + if (flowElement instanceof StartEvent startEvent) { + if (CollectionUtil.isNotEmpty(startEvent.getEventDefinitions()) && startEvent.getEventDefinitions() + .get(0) instanceof MessageEventDefinition messageEventDefinition) { - MessageEventDefinition messageEventDefinition = (MessageEventDefinition) startEvent.getEventDefinitions().get(0); String actualMessageName = EventDefinitionExpressionUtil.determineMessageName(commandContext, messageEventDefinition, null); if (Objects.equals(actualMessageName, messageName)) { initialFlowElement = flowElement; diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/TaskHelper.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/TaskHelper.java index fa359be8d8d..3d080dfbcec 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/TaskHelper.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/TaskHelper.java @@ -198,8 +198,7 @@ protected static void logUserTaskCompleted(TaskEntity taskEntity) { protected static void storeTaskCompleter(TaskEntity taskEntity, ExecutionEntity execution, ProcessEngineConfigurationImpl processEngineConfiguration) { if (taskEntity.getProcessDefinitionId() != null) { FlowElement flowElement = execution.getCurrentFlowElement(); - if (flowElement instanceof UserTask) { - UserTask userTask = (UserTask) flowElement; + if (flowElement instanceof UserTask userTask) { String taskCompleterVariableName = userTask.getTaskCompleterVariableName(); if (StringUtils.isNotEmpty(taskCompleterVariableName)) { ExpressionManager expressionManager = processEngineConfiguration.getExpressionManager(); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/variable/BpmnAggregation.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/variable/BpmnAggregation.java index 48fc47831ac..f9519bf392a 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/variable/BpmnAggregation.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/variable/BpmnAggregation.java @@ -156,12 +156,11 @@ public static Object aggregateOverview(String parentExecutionId, String targetVa public static Object aggregateOverviewForMultiInstance(ExecutionEntity parentExecution, String targetVarName, ProcessEngineConfigurationImpl processEngineConfiguration) { FlowElement currentFlowElement = parentExecution.getCurrentFlowElement(); - if (!(currentFlowElement instanceof Activity)) { + if (!(currentFlowElement instanceof Activity activity)) { // This should never happen as the parent execution is a multi instance root, but we are being extra safe return null; } - Activity activity = (Activity) currentFlowElement; MultiInstanceLoopCharacteristics loopCharacteristics = activity.getLoopCharacteristics(); if (loopCharacteristics == null) { // This should never happen as the parent execution is a multi instance root, but we are being extra safe diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/test/impl/logger/DebugInfoEntityEventListener.java b/modules/flowable-engine/src/main/java/org/flowable/engine/test/impl/logger/DebugInfoEntityEventListener.java index 6e58192e1ad..59d2b0512b4 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/test/impl/logger/DebugInfoEntityEventListener.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/test/impl/logger/DebugInfoEntityEventListener.java @@ -49,8 +49,7 @@ protected void onDelete(FlowableEvent event) { protected ExecutionEntity getExecutionEntity(FlowableEvent event) { FlowableEntityEvent entityEvent = (FlowableEntityEvent) event; Object entity = entityEvent.getEntity(); - if (entity instanceof ExecutionEntity) { - ExecutionEntity executionEntity = (ExecutionEntity) entity; + if (entity instanceof ExecutionEntity executionEntity) { return executionEntity; } return null; diff --git a/modules/flowable-engine/src/test/java/org/flowable/engine/test/api/event/ProcessDefinitionEventsTest.java b/modules/flowable-engine/src/test/java/org/flowable/engine/test/api/event/ProcessDefinitionEventsTest.java index 5a1e6803377..5d4e38b2b4f 100644 --- a/modules/flowable-engine/src/test/java/org/flowable/engine/test/api/event/ProcessDefinitionEventsTest.java +++ b/modules/flowable-engine/src/test/java/org/flowable/engine/test/api/event/ProcessDefinitionEventsTest.java @@ -133,8 +133,7 @@ protected void assertSequence(FlowableEntityEvent before, FlowableEntityEvent af * equals is not implemented. */ private boolean isEqual(FlowableEntityEvent event1, FlowableEvent flowableEvent) { - if (flowableEvent instanceof FlowableEntityEvent && event1.getType().equals(flowableEvent.getType())) { - FlowableEntityEvent flowableEntityEvent = (FlowableEntityEvent) flowableEvent; + if (flowableEvent instanceof FlowableEntityEvent flowableEntityEvent && event1.getType().equals(flowableEvent.getType())) { if (flowableEntityEvent.getEntity().getClass().equals(event1.getEntity().getClass())) { return true; } diff --git a/modules/flowable-engine/src/test/java/org/flowable/engine/test/bpmn/multiinstance/MultiInstanceVariableAggregationTest.java b/modules/flowable-engine/src/test/java/org/flowable/engine/test/bpmn/multiinstance/MultiInstanceVariableAggregationTest.java index 6e137fb3f83..19e1143f797 100644 --- a/modules/flowable-engine/src/test/java/org/flowable/engine/test/bpmn/multiinstance/MultiInstanceVariableAggregationTest.java +++ b/modules/flowable-engine/src/test/java/org/flowable/engine/test/bpmn/multiinstance/MultiInstanceVariableAggregationTest.java @@ -1920,8 +1920,7 @@ public Object aggregateSingleVariable(DelegateExecution execution, VariableAggre ArrayNode arrayNode = objectMapper.createArrayNode(); for (VariableAggregationDefinition.Variable variable : context.getDefinition().getDefinitions()) { Object sourceVariable = execution.getVariable(variable.getSource()); - if (sourceVariable instanceof ArrayNode) { - ArrayNode sourceArrayNode = (ArrayNode) sourceVariable; + if (sourceVariable instanceof ArrayNode sourceArrayNode) { for (int i = 0; i < sourceArrayNode.size(); i++) { JsonNode node = arrayNode.get(i); JsonNode sourceNode = sourceArrayNode.get(i); diff --git a/modules/flowable-event-registry-json-converter/src/main/java/org/flowable/eventregistry/json/converter/InboundChannelModelValidator.java b/modules/flowable-event-registry-json-converter/src/main/java/org/flowable/eventregistry/json/converter/InboundChannelModelValidator.java index ffb2065680e..05dc8bb5cff 100644 --- a/modules/flowable-event-registry-json-converter/src/main/java/org/flowable/eventregistry/json/converter/InboundChannelModelValidator.java +++ b/modules/flowable-event-registry-json-converter/src/main/java/org/flowable/eventregistry/json/converter/InboundChannelModelValidator.java @@ -24,8 +24,7 @@ public class InboundChannelModelValidator implements ChannelValidator { @Override public void validateChannel(ChannelModel channelModel) { - if (channelModel instanceof InboundChannelModel) { - InboundChannelModel inboundChannelModel = (InboundChannelModel) channelModel; + if (channelModel instanceof InboundChannelModel inboundChannelModel) { validateChannel(inboundChannelModel); } diff --git a/modules/flowable-event-registry-json-converter/src/main/java/org/flowable/eventregistry/json/converter/OutboundChannelModelValidator.java b/modules/flowable-event-registry-json-converter/src/main/java/org/flowable/eventregistry/json/converter/OutboundChannelModelValidator.java index f0c84a9f378..9f0a8c0bcf5 100644 --- a/modules/flowable-event-registry-json-converter/src/main/java/org/flowable/eventregistry/json/converter/OutboundChannelModelValidator.java +++ b/modules/flowable-event-registry-json-converter/src/main/java/org/flowable/eventregistry/json/converter/OutboundChannelModelValidator.java @@ -40,8 +40,7 @@ public OutboundChannelModelValidator(Collection supportedSerializers) { @Override public void validateChannel(ChannelModel channelModel) { - if (channelModel instanceof OutboundChannelModel) { - OutboundChannelModel outboundChannelModel = (OutboundChannelModel) channelModel; + if (channelModel instanceof OutboundChannelModel outboundChannelModel) { validateChannel(outboundChannelModel); } diff --git a/modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/deployer/CachingAndArtifactsManager.java b/modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/deployer/CachingAndArtifactsManager.java index 6eab9d8c905..84fc68a7374 100644 --- a/modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/deployer/CachingAndArtifactsManager.java +++ b/modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/deployer/CachingAndArtifactsManager.java @@ -82,9 +82,7 @@ public void registerChannelModel(ChannelModel channelModel, ChannelDefinition ch throw new FlowableIllegalArgumentException("No key set for channel model"); } - if (channelModel instanceof InboundChannelModel) { - - InboundChannelModel inboundChannelModel = (InboundChannelModel) channelModel; + if (channelModel instanceof InboundChannelModel inboundChannelModel) { if (inboundChannelModel.getInboundEventChannelAdapter() != null) { InboundEventChannelAdapter inboundEventChannelAdapter = (InboundEventChannelAdapter) inboundChannelModel.getInboundEventChannelAdapter(); diff --git a/modules/flowable-form-model/src/main/java/org/flowable/form/model/SimpleFormModel.java b/modules/flowable-form-model/src/main/java/org/flowable/form/model/SimpleFormModel.java index d0e3a7150e1..b4c4e89f702 100644 --- a/modules/flowable-form-model/src/main/java/org/flowable/form/model/SimpleFormModel.java +++ b/modules/flowable-form-model/src/main/java/org/flowable/form/model/SimpleFormModel.java @@ -128,8 +128,7 @@ protected void collectSubFields(List fields, List listOfAl if (fields != null && fields.size() > 0) { for (FormField field : fields) { listOfAllFields.add(field); - if (field instanceof FormContainer) { - FormContainer container = (FormContainer) field; + if (field instanceof FormContainer container) { List> subFields = container.getFields(); if (subFields != null) { for (List subFieldDefinitions : subFields) { diff --git a/modules/flowable-http-common/src/main/java/org/flowable/http/common/impl/ExpressionUtils.java b/modules/flowable-http-common/src/main/java/org/flowable/http/common/impl/ExpressionUtils.java index 5bdc3b53c7d..1fea72ead1b 100644 --- a/modules/flowable-http-common/src/main/java/org/flowable/http/common/impl/ExpressionUtils.java +++ b/modules/flowable-http-common/src/main/java/org/flowable/http/common/impl/ExpressionUtils.java @@ -49,8 +49,7 @@ public static boolean getBooleanFromField(final Expression expression, final Var protected static boolean parseBoolean(Object value) { if (value != null) { - if (value instanceof String) { - String stringValue = (String) value; + if (value instanceof String stringValue) { if ("true".equalsIgnoreCase(stringValue) || "false".equalsIgnoreCase(stringValue)) { return Boolean.parseBoolean(value.toString()); } diff --git a/modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/persistence/entity/IdmByteArrayEntityImpl.java b/modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/persistence/entity/IdmByteArrayEntityImpl.java index 50c4c4877f8..a74b73d24ae 100644 --- a/modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/persistence/entity/IdmByteArrayEntityImpl.java +++ b/modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/persistence/entity/IdmByteArrayEntityImpl.java @@ -79,8 +79,7 @@ public PersistentState(String name, byte[] bytes) { @Override public boolean equals(Object obj) { - if (obj instanceof PersistentState) { - PersistentState other = (PersistentState) obj; + if (obj instanceof PersistentState other) { return StringUtils.equals(this.name, other.name) && Arrays.equals(this.bytes, other.bytes); } return false; diff --git a/modules/flowable-image-generator/src/main/java/org/flowable/image/impl/DefaultProcessDiagramGenerator.java b/modules/flowable-image-generator/src/main/java/org/flowable/image/impl/DefaultProcessDiagramGenerator.java index 051e3e0a803..f3d9220b8f6 100755 --- a/modules/flowable-image-generator/src/main/java/org/flowable/image/impl/DefaultProcessDiagramGenerator.java +++ b/modules/flowable-image-generator/src/main/java/org/flowable/image/impl/DefaultProcessDiagramGenerator.java @@ -747,8 +747,7 @@ protected void drawActivity(DefaultProcessDiagramCanvas processDiagramCanvas, Bp boolean multiInstanceSequential = false; boolean multiInstanceParallel = false; boolean collapsed = false; - if (flowNode instanceof Activity) { - Activity activity = (Activity) flowNode; + if (flowNode instanceof Activity activity) { MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics = activity.getLoopCharacteristics(); if (multiInstanceLoopCharacteristics != null) { multiInstanceSequential = multiInstanceLoopCharacteristics.isSequential(); diff --git a/modules/flowable-job-service/src/main/java/org/flowable/job/service/event/impl/FlowableJobEventBuilder.java b/modules/flowable-job-service/src/main/java/org/flowable/job/service/event/impl/FlowableJobEventBuilder.java index d6295543a6c..2148ab90c24 100644 --- a/modules/flowable-job-service/src/main/java/org/flowable/job/service/event/impl/FlowableJobEventBuilder.java +++ b/modules/flowable-job-service/src/main/java/org/flowable/job/service/event/impl/FlowableJobEventBuilder.java @@ -64,8 +64,7 @@ public static FlowableEntityEvent createEntityExceptionEvent(FlowableEngineEvent protected static void populateEventWithCurrentContext(FlowableEngineEventImpl event) { if (event instanceof FlowableEntityEvent) { Object persistedObject = ((FlowableEntityEvent) event).getEntity(); - if (persistedObject instanceof Job) { - Job jobObject = (Job) persistedObject; + if (persistedObject instanceof Job jobObject) { if (jobObject.getScopeType() == null) { event.setExecutionId(jobObject.getExecutionId()); event.setProcessInstanceId(jobObject.getProcessInstanceId()); diff --git a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/asyncexecutor/DefaultAsyncRunnableExecutionExceptionHandler.java b/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/asyncexecutor/DefaultAsyncRunnableExecutionExceptionHandler.java index b4e3c1e127c..13275baed88 100644 --- a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/asyncexecutor/DefaultAsyncRunnableExecutionExceptionHandler.java +++ b/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/asyncexecutor/DefaultAsyncRunnableExecutionExceptionHandler.java @@ -43,8 +43,7 @@ public Void execute(CommandContext commandContext) { String message = "Job " + job.getId() + " failed"; LOGGER.error(message, exception); - if (job instanceof AbstractRuntimeJobEntity) { - AbstractRuntimeJobEntity runtimeJob = (AbstractRuntimeJobEntity) job; + if (job instanceof AbstractRuntimeJobEntity runtimeJob) { InternalJobCompatibilityManager internalJobCompatibilityManager = jobServiceConfiguration.getInternalJobCompatibilityManager(); if (internalJobCompatibilityManager != null && internalJobCompatibilityManager.isFlowable5Job(runtimeJob)) { internalJobCompatibilityManager.handleFailedV5Job(runtimeJob, exception); diff --git a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/asyncexecutor/ExecuteAsyncRunnable.java b/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/asyncexecutor/ExecuteAsyncRunnable.java index 9e5853bf5bd..8565be5de32 100644 --- a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/asyncexecutor/ExecuteAsyncRunnable.java +++ b/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/asyncexecutor/ExecuteAsyncRunnable.java @@ -102,8 +102,7 @@ public void run() { protected void runInternally(JobExecutionObservation observation) { - if (job instanceof Job) { - Job jobObject = (Job) job; + if (job instanceof Job jobObject) { InternalJobCompatibilityManager internalJobCompatibilityManager = jobServiceConfiguration.getInternalJobCompatibilityManager(); if (internalJobCompatibilityManager != null && internalJobCompatibilityManager.isFlowable5Job(jobObject)) { internalJobCompatibilityManager.executeV5JobWithLockAndRetry(jobObject); diff --git a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/asyncexecutor/multitenant/ExecutorPerTenantAsyncExecutor.java b/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/asyncexecutor/multitenant/ExecutorPerTenantAsyncExecutor.java index 12d73b76c34..ed2fefdafb5 100644 --- a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/asyncexecutor/multitenant/ExecutorPerTenantAsyncExecutor.java +++ b/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/asyncexecutor/multitenant/ExecutorPerTenantAsyncExecutor.java @@ -74,8 +74,7 @@ public void addTenantAsyncExecutor(String tenantId, boolean startExecutor) { tenantExecutor.setJobServiceConfiguration(jobServiceConfiguration); - if (tenantExecutor instanceof AbstractAsyncExecutor) { - AbstractAsyncExecutor defaultAsyncJobExecutor = (AbstractAsyncExecutor) tenantExecutor; + if (tenantExecutor instanceof AbstractAsyncExecutor defaultAsyncJobExecutor) { defaultAsyncJobExecutor.setAsyncJobsDueRunnable(new TenantAwareAcquireAsyncJobsDueRunnable(defaultAsyncJobExecutor, tenantInfoHolder, tenantId)); defaultAsyncJobExecutor.setTimerJobRunnable(new TenantAwareAcquireTimerJobsRunnable(defaultAsyncJobExecutor, tenantInfoHolder, tenantId, defaultAsyncJobExecutor.getMoveTimerExecutorPoolSize())); defaultAsyncJobExecutor.setExecuteAsyncRunnableFactory(new TenantAwareExecuteAsyncRunnableFactory(tenantInfoHolder, tenantId, defaultAsyncJobExecutor.getJobExecutionObservationProvider())); diff --git a/modules/flowable-mail/src/main/java/org/flowable/mail/common/impl/BaseMailActivityDelegate.java b/modules/flowable-mail/src/main/java/org/flowable/mail/common/impl/BaseMailActivityDelegate.java index 6e633f9a2ad..7e85092f85b 100644 --- a/modules/flowable-mail/src/main/java/org/flowable/mail/common/impl/BaseMailActivityDelegate.java +++ b/modules/flowable-mail/src/main/java/org/flowable/mail/common/impl/BaseMailActivityDelegate.java @@ -235,8 +235,7 @@ protected Collection parseRecipients(Expression expression, V variableCo } if (value instanceof Collection) { return (Collection) value; - } else if (value instanceof ArrayNode) { - ArrayNode arrayNode = (ArrayNode) value; + } else if (value instanceof ArrayNode arrayNode) { Collection recipients = new ArrayList<>(arrayNode.size()); for (JsonNode node : arrayNode) { recipients.add(node.asText()); diff --git a/modules/flowable-process-validation/src/main/java/org/flowable/validation/validator/impl/BoundaryEventValidator.java b/modules/flowable-process-validation/src/main/java/org/flowable/validation/validator/impl/BoundaryEventValidator.java index 343d56e9f7d..5a4bfa0cf3e 100644 --- a/modules/flowable-process-validation/src/main/java/org/flowable/validation/validator/impl/BoundaryEventValidator.java +++ b/modules/flowable-process-validation/src/main/java/org/flowable/validation/validator/impl/BoundaryEventValidator.java @@ -92,7 +92,7 @@ protected void executeValidation(BpmnModel bpmnModel, Process process, List errors) { for (FlowElement flowElement : process.getFlowElements()) { - if (flowElement instanceof Activity) { - Activity activity = (Activity) flowElement; + if (flowElement instanceof Activity activity) { handleConstraints(process, activity, errors); handleMultiInstanceLoopCharacteristics(process, activity, errors); handleDataAssociations(process, activity, errors); diff --git a/modules/flowable-task-service/src/main/java/org/flowable/task/service/event/impl/FlowableTaskEventBuilder.java b/modules/flowable-task-service/src/main/java/org/flowable/task/service/event/impl/FlowableTaskEventBuilder.java index 2cbeb85809e..d87123aceb2 100644 --- a/modules/flowable-task-service/src/main/java/org/flowable/task/service/event/impl/FlowableTaskEventBuilder.java +++ b/modules/flowable-task-service/src/main/java/org/flowable/task/service/event/impl/FlowableTaskEventBuilder.java @@ -42,8 +42,7 @@ public static FlowableEntityEvent createEntityEvent(FlowableEngineEventType type protected static void populateEventWithCurrentContext(FlowableEngineEventImpl event) { if (event instanceof FlowableEntityEvent) { Object persistedObject = ((FlowableEntityEvent) event).getEntity(); - if (persistedObject instanceof Task) { - Task taskObject = (Task) persistedObject; + if (persistedObject instanceof Task taskObject) { if (taskObject.getScopeType() == null) { event.setProcessInstanceId(taskObject.getProcessInstanceId()); event.setExecutionId(taskObject.getExecutionId()); diff --git a/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/DefaultVariableInstanceValueModifier.java b/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/DefaultVariableInstanceValueModifier.java index d94ed56e4a7..e08d97b706f 100644 --- a/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/DefaultVariableInstanceValueModifier.java +++ b/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/DefaultVariableInstanceValueModifier.java @@ -32,8 +32,7 @@ public DefaultVariableInstanceValueModifier(VariableServiceConfiguration service @Override public void setVariableValue(VariableInstance variableInstance, Object value, String tenantId) { - if (variableInstance instanceof VariableInstanceEntity) { - VariableInstanceEntity variableInstanceEntity = (VariableInstanceEntity) variableInstance; + if (variableInstance instanceof VariableInstanceEntity variableInstanceEntity) { VariableType variableType = determineVariableType(value); setVariableType(variableInstanceEntity, variableType); } @@ -45,8 +44,7 @@ public void updateVariableValue(VariableInstance variableInstance, Object value, /* Always check if the type should be altered. It's possible that the previous type is lower in the type * checking chain (e.g. serializable) and will return true on isAbleToStore(), even though another type higher in the chain is eligible for storage. */ - if (variableInstance instanceof VariableInstanceEntity) { - VariableInstanceEntity variableInstanceEntity = (VariableInstanceEntity) variableInstance; + if (variableInstance instanceof VariableInstanceEntity variableInstanceEntity) { VariableType variableType = determineVariableType(value); if (!variableType.equals(variableInstanceEntity.getType())) { updateVariableType(variableInstanceEntity, variableType); diff --git a/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/HistoricVariableInstanceQueryImpl.java b/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/HistoricVariableInstanceQueryImpl.java index 4a04e00addf..d85ec647dcb 100644 --- a/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/HistoricVariableInstanceQueryImpl.java +++ b/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/HistoricVariableInstanceQueryImpl.java @@ -317,8 +317,7 @@ public List executeList(CommandContext commandContext) if (!excludeVariableInitialization) { for (HistoricVariableInstance historicVariableInstance : historicVariableInstances) { - if (historicVariableInstance instanceof HistoricVariableInstanceEntity) { - HistoricVariableInstanceEntity variableEntity = (HistoricVariableInstanceEntity) historicVariableInstance; + if (historicVariableInstance instanceof HistoricVariableInstanceEntity variableEntity) { if (variableEntity.getVariableType() != null) { variableEntity.getValue(); diff --git a/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/VariableInstanceQueryImpl.java b/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/VariableInstanceQueryImpl.java index 168e10033e8..f580f2de1b1 100644 --- a/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/VariableInstanceQueryImpl.java +++ b/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/VariableInstanceQueryImpl.java @@ -295,8 +295,7 @@ public List executeList(CommandContext commandContext) { if (!excludeVariableInitialization) { for (VariableInstance variableInstance : variableInstances) { - if (variableInstance instanceof VariableInstanceEntity) { - VariableInstanceEntity variableEntity = (VariableInstanceEntity) variableInstance; + if (variableInstance instanceof VariableInstanceEntity variableEntity) { if (variableEntity.getType() != null) { variableEntity.getValue(); diff --git a/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/el/VariableScopeExpressionManager.java b/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/el/VariableScopeExpressionManager.java index dd9c70d4fac..97e0ef11d40 100644 --- a/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/el/VariableScopeExpressionManager.java +++ b/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/el/VariableScopeExpressionManager.java @@ -34,8 +34,7 @@ public ELContext getElContext(VariableContainer variableContainer) { // The VariableScopeExpressionManager class adds caching of the ELContext ELContext elContext = null; - if (variableContainer instanceof VariableScopeImpl) { - VariableScopeImpl variableScopeImpl = (VariableScopeImpl) variableContainer; + if (variableContainer instanceof VariableScopeImpl variableScopeImpl) { elContext = variableScopeImpl.getCachedElContext(); } diff --git a/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/types/JPAEntityListVariableType.java b/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/types/JPAEntityListVariableType.java index 25706a5f521..11713c9048b 100644 --- a/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/types/JPAEntityListVariableType.java +++ b/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/types/JPAEntityListVariableType.java @@ -63,8 +63,7 @@ public boolean isCachable() { public boolean isAbleToStore(Object value) { boolean canStore = false; - if (value instanceof List) { - List list = (List) value; + if (value instanceof List list) { if (list.size() > 0) { // We can only store the list if we are sure it's actually a // list of JPA entities. In case the @@ -99,8 +98,7 @@ public void setValue(Object value, ValueFields valueFields) { entityManagerSession.flush(); } - if (value instanceof List && ((List) value).size() > 0) { - List list = (List) value; + if (value instanceof List list && list.size() > 0) { List ids = new ArrayList<>(); String type = mappings.getJPAClassString(list.get(0));