diff --git a/bonita-integration-tests/bonita-integration-tests-client/src/main/java/org/bonitasoft/engine/process/Employee.java b/bonita-integration-tests/bonita-integration-tests-client/src/main/java/org/bonitasoft/engine/process/Employee.java index 9e6688870d2..c408cc7273d 100644 --- a/bonita-integration-tests/bonita-integration-tests-client/src/main/java/org/bonitasoft/engine/process/Employee.java +++ b/bonita-integration-tests/bonita-integration-tests-client/src/main/java/org/bonitasoft/engine/process/Employee.java @@ -79,10 +79,9 @@ public boolean equals(final Object obj) { if (obj == null) { return false; } - if (!(obj instanceof Employee)) { + if (!(obj instanceof Employee other)) { return false; } - final Employee other = (Employee) obj; if (experience != other.experience) { return false; } diff --git a/bpm/bonita-common/src/main/java/org/bonitasoft/engine/bdm/validator/ValidationStatus.java b/bpm/bonita-common/src/main/java/org/bonitasoft/engine/bdm/validator/ValidationStatus.java index c6d11cf2061..e5ba5bfcda3 100644 --- a/bpm/bonita-common/src/main/java/org/bonitasoft/engine/bdm/validator/ValidationStatus.java +++ b/bpm/bonita-common/src/main/java/org/bonitasoft/engine/bdm/validator/ValidationStatus.java @@ -96,9 +96,8 @@ public List getStatuses() { public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof ValidationStatus)) + if (!(o instanceof ValidationStatus that)) return false; - ValidationStatus that = (ValidationStatus) o; return Objects.equals(statusList, that.statusList); } diff --git a/bpm/bonita-common/src/main/java/org/bonitasoft/engine/bdm/validator/rule/MultipleAggregationToItselfValidationRule.java b/bpm/bonita-common/src/main/java/org/bonitasoft/engine/bdm/validator/rule/MultipleAggregationToItselfValidationRule.java index 7e1404e0c49..be56048d7a8 100644 --- a/bpm/bonita-common/src/main/java/org/bonitasoft/engine/bdm/validator/rule/MultipleAggregationToItselfValidationRule.java +++ b/bpm/bonita-common/src/main/java/org/bonitasoft/engine/bdm/validator/rule/MultipleAggregationToItselfValidationRule.java @@ -41,8 +41,7 @@ protected ValidationStatus validate(BusinessObjectModel bom) { for (BusinessObject bo : bom.getBusinessObjects()) { List boFields = bo.getFields(); for (Field boField : boFields) { - if (boField instanceof RelationField) { - RelationField relationField = (RelationField) boField; + if (boField instanceof RelationField relationField) { String fieldReferenceQualifiedName = relationField.getReference().getQualifiedName(); String boQualifiedName = bo.getQualifiedName(); if (relationField.getType() == AGGREGATION && fieldReferenceQualifiedName.equals(boQualifiedName) diff --git a/bpm/bonita-common/src/main/java/org/bonitasoft/engine/bdm/validator/rule/composition/AggregationAndCompositionValidationRule.java b/bpm/bonita-common/src/main/java/org/bonitasoft/engine/bdm/validator/rule/composition/AggregationAndCompositionValidationRule.java index 20b88d165c8..807d354eb42 100644 --- a/bpm/bonita-common/src/main/java/org/bonitasoft/engine/bdm/validator/rule/composition/AggregationAndCompositionValidationRule.java +++ b/bpm/bonita-common/src/main/java/org/bonitasoft/engine/bdm/validator/rule/composition/AggregationAndCompositionValidationRule.java @@ -47,8 +47,7 @@ protected ValidationStatus validate(BusinessObjectModel bom) { for (BusinessObject bo : businessObjects) fieldList.addAll(bo.getFields()); for (Field field : fieldList) { - if (field instanceof RelationField) { - RelationField relationField = (RelationField) field; + if (field instanceof RelationField relationField) { if (relationField.getType() == AGGREGATION) { aggregatedBusinessObjects.add(relationField.getReference()); } diff --git a/bpm/bonita-common/src/main/java/org/bonitasoft/engine/bpm/flownode/impl/internal/ArchivedFlowNodeInstanceImpl.java b/bpm/bonita-common/src/main/java/org/bonitasoft/engine/bpm/flownode/impl/internal/ArchivedFlowNodeInstanceImpl.java index 6ffe9d2fc19..1e5e604ba62 100644 --- a/bpm/bonita-common/src/main/java/org/bonitasoft/engine/bpm/flownode/impl/internal/ArchivedFlowNodeInstanceImpl.java +++ b/bpm/bonita-common/src/main/java/org/bonitasoft/engine/bpm/flownode/impl/internal/ArchivedFlowNodeInstanceImpl.java @@ -222,11 +222,10 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof ArchivedFlowNodeInstanceImpl)) + if (!(o instanceof ArchivedFlowNodeInstanceImpl that)) return false; if (!super.equals(o)) return false; - ArchivedFlowNodeInstanceImpl that = (ArchivedFlowNodeInstanceImpl) o; return Objects.equals(parentContainerId, that.parentContainerId) && Objects.equals(rootContainerId, that.rootContainerId) && Objects.equals(processDefinitionId, that.processDefinitionId) && diff --git a/bpm/bonita-common/src/main/java/org/bonitasoft/engine/bpm/flownode/impl/internal/FlowNodeInstanceImpl.java b/bpm/bonita-common/src/main/java/org/bonitasoft/engine/bpm/flownode/impl/internal/FlowNodeInstanceImpl.java index d19117b2813..1e4028f0242 100644 --- a/bpm/bonita-common/src/main/java/org/bonitasoft/engine/bpm/flownode/impl/internal/FlowNodeInstanceImpl.java +++ b/bpm/bonita-common/src/main/java/org/bonitasoft/engine/bpm/flownode/impl/internal/FlowNodeInstanceImpl.java @@ -202,11 +202,10 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof FlowNodeInstanceImpl)) + if (!(o instanceof FlowNodeInstanceImpl that)) return false; if (!super.equals(o)) return false; - FlowNodeInstanceImpl that = (FlowNodeInstanceImpl) o; return Objects.equals(parentContainerId, that.parentContainerId) && Objects.equals(rootContainerId, that.rootContainerId) && Objects.equals(processDefinitionId, that.processDefinitionId) && diff --git a/bpm/bonita-common/src/main/java/org/bonitasoft/engine/form/FormMapping.java b/bpm/bonita-common/src/main/java/org/bonitasoft/engine/form/FormMapping.java index c88f74ffa8f..d4814d1d738 100644 --- a/bpm/bonita-common/src/main/java/org/bonitasoft/engine/form/FormMapping.java +++ b/bpm/bonita-common/src/main/java/org/bonitasoft/engine/form/FormMapping.java @@ -146,9 +146,8 @@ public void setFormRequired(boolean required) { public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof FormMapping)) + if (!(o instanceof FormMapping that)) return false; - FormMapping that = (FormMapping) o; return Objects.equals(id, that.id) && Objects.equals(processDefinitionId, that.processDefinitionId) && Objects.equals(lastUpdatedBy, that.lastUpdatedBy) && diff --git a/bpm/bonita-core/bonita-contract-data/src/test/java/org/bonitasoft/engine/core/contract/data/MyPojo.java b/bpm/bonita-core/bonita-contract-data/src/test/java/org/bonitasoft/engine/core/contract/data/MyPojo.java deleted file mode 100644 index a1b4f428943..00000000000 --- a/bpm/bonita-core/bonita-contract-data/src/test/java/org/bonitasoft/engine/core/contract/data/MyPojo.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (C) 2019 Bonitasoft S.A. - * Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble - * This library is free software; you can redistribute it and/or modify it under the terms - * of the GNU Lesser General Public License as published by the Free Software Foundation - * version 2.1 of the License. - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * You should have received a copy of the GNU Lesser General Public License along with this - * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301, USA. - **/ -package org.bonitasoft.engine.core.contract.data; - -import java.io.Serializable; - -/** - * @author Baptiste Mesta - */ -class MyPojo implements Serializable { - - private final String name; - private final byte[] content; - - public MyPojo(String name, byte[] content) { - this.name = name; - this.content = content; - } - - public byte[] getContent() { - return content; - } - - public String getName() { - return name; - } -} diff --git a/bpm/bonita-core/bonita-process-definition/src/main/java/org/bonitasoft/engine/core/expression/control/model/SExpressionContext.java b/bpm/bonita-core/bonita-process-definition/src/main/java/org/bonitasoft/engine/core/expression/control/model/SExpressionContext.java index d16a9a28b3c..20e21c38214 100644 --- a/bpm/bonita-core/bonita-process-definition/src/main/java/org/bonitasoft/engine/core/expression/control/model/SExpressionContext.java +++ b/bpm/bonita-core/bonita-process-definition/src/main/java/org/bonitasoft/engine/core/expression/control/model/SExpressionContext.java @@ -210,9 +210,8 @@ public void setParentProcessDefinitionId(final Long parentProcessDefinitionId) { public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof SExpressionContext)) + if (!(o instanceof SExpressionContext that)) return false; - SExpressionContext that = (SExpressionContext) o; return Objects.equals(time, that.time) && Objects.equals(evaluateInDefinition, that.evaluateInDefinition) && Objects.equals(containerId, that.containerId) && diff --git a/bpm/bonita-core/bonita-process-definition/src/main/java/org/bonitasoft/engine/core/operation/impl/XpathUpdateQueryOperationExecutorStrategy.java b/bpm/bonita-core/bonita-process-definition/src/main/java/org/bonitasoft/engine/core/operation/impl/XpathUpdateQueryOperationExecutorStrategy.java index 84b7d117246..a18598638ae 100644 --- a/bpm/bonita-core/bonita-process-definition/src/main/java/org/bonitasoft/engine/core/operation/impl/XpathUpdateQueryOperationExecutorStrategy.java +++ b/bpm/bonita-core/bonita-process-definition/src/main/java/org/bonitasoft/engine/core/operation/impl/XpathUpdateQueryOperationExecutorStrategy.java @@ -100,8 +100,7 @@ public Object computeNewValueForLeftOperand(final SOperation operation, final Ob final String parentPath = xpathExpression.substring(0, xpathExpression.lastIndexOf('/')); final String attributeName = xpathExpression.substring(xpathExpression.lastIndexOf('/') + 2); // +1 for @ final Node parentNode = (Node) xpath.compile(parentPath).evaluate(document, XPathConstants.NODE); - if (parentNode instanceof Element) { - final Element element = (Element) parentNode; + if (parentNode instanceof Element element) { if (value instanceof String) { element.setAttribute(attributeName, getStringValue(value)); } else if (value instanceof Attr) { diff --git a/bpm/bonita-core/bonita-process-definition/src/main/java/org/bonitasoft/engine/core/process/definition/model/builder/ServerModelConvertor.java b/bpm/bonita-core/bonita-process-definition/src/main/java/org/bonitasoft/engine/core/process/definition/model/builder/ServerModelConvertor.java index 775cf04a62c..a1629fd19f8 100644 --- a/bpm/bonita-core/bonita-process-definition/src/main/java/org/bonitasoft/engine/core/process/definition/model/builder/ServerModelConvertor.java +++ b/bpm/bonita-core/bonita-process-definition/src/main/java/org/bonitasoft/engine/core/process/definition/model/builder/ServerModelConvertor.java @@ -94,8 +94,7 @@ public static List convertOperations(final List operation } public static SDataDefinition convertDataDefinition(final DataDefinition dataDefinition) { - if (dataDefinition instanceof XMLDataDefinition) { - final XMLDataDefinition xmlDataDef = (XMLDataDefinition) dataDefinition; + if (dataDefinition instanceof XMLDataDefinition xmlDataDef) { final SXMLDataDefinitionBuilderFactory fact = BuilderFactory.get(SXMLDataDefinitionBuilderFactory.class); final SXMLDataDefinitionBuilder builder = fact.createNewXMLData(dataDefinition.getName()) .setElement(xmlDataDef.getElement()) @@ -107,8 +106,7 @@ public static SDataDefinition convertDataDefinition(final DataDefinition dataDef } final SDataDefinitionBuilderFactory fact = BuilderFactory.get(SDataDefinitionBuilderFactory.class); SDataDefinitionBuilder builder; - if (dataDefinition instanceof TextDataDefinition) { - final TextDataDefinition textDataDefinition = (TextDataDefinition) dataDefinition; + if (dataDefinition instanceof TextDataDefinition textDataDefinition) { builder = fact.createNewTextData(dataDefinition.getName()).setAsLongText(textDataDefinition.isLongText()); } else { builder = fact.createNewInstance(dataDefinition.getName(), dataDefinition.getClassName()); diff --git a/bpm/bonita-core/bonita-process-definition/src/main/java/org/bonitasoft/engine/core/process/definition/model/impl/SFlowElementContainerDefinitionImpl.java b/bpm/bonita-core/bonita-process-definition/src/main/java/org/bonitasoft/engine/core/process/definition/model/impl/SFlowElementContainerDefinitionImpl.java index 2e523b7e314..6184fd25749 100644 --- a/bpm/bonita-core/bonita-process-definition/src/main/java/org/bonitasoft/engine/core/process/definition/model/impl/SFlowElementContainerDefinitionImpl.java +++ b/bpm/bonita-core/bonita-process-definition/src/main/java/org/bonitasoft/engine/core/process/definition/model/impl/SFlowElementContainerDefinitionImpl.java @@ -236,14 +236,13 @@ private void initializeActivities(final List activities2) { final SActivityDefinitionImpl activity; if (activityDefinition instanceof AutomaticTaskDefinitionImpl) { activity = new SAutomaticTaskDefinitionImpl(activityDefinition, transitionsMap); - } else if (activityDefinition instanceof HumanTaskDefinitionImpl) { + } else if (activityDefinition instanceof HumanTaskDefinitionImpl humanTaskDefinitionImpl) { if (activityDefinition instanceof UserTaskDefinitionImpl) { activity = new SUserTaskDefinitionImpl((UserTaskDefinition) activityDefinition, transitionsMap); } else { activity = new SManualTaskDefinitionImpl((ManualTaskDefinitionImpl) activityDefinition, transitionsMap); } - final HumanTaskDefinitionImpl humanTaskDefinitionImpl = (HumanTaskDefinitionImpl) activityDefinition; final UserFilterDefinition userFilter = humanTaskDefinitionImpl.getUserFilter(); final SHumanTaskDefinitionImpl sHumanTaskDefinitionImpl = (SHumanTaskDefinitionImpl) activity; if (userFilter != null) { diff --git a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/api/impl/ProcessAPIImpl.java b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/api/impl/ProcessAPIImpl.java index a6224a94dbb..f245e47392c 100644 --- a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/api/impl/ProcessAPIImpl.java +++ b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/api/impl/ProcessAPIImpl.java @@ -5884,10 +5884,9 @@ public List getPossibleUsersOfHumanTask(final long processDefinitionId, fi final SProcessDefinition processDefinition = processDefinitionService .getProcessDefinition(processDefinitionId); final SFlowNodeDefinition flowNode = processDefinition.getProcessContainer().getFlowNode(humanTaskName); - if (!(flowNode instanceof SHumanTaskDefinition)) { + if (!(flowNode instanceof SHumanTaskDefinition humanTask)) { return Collections.emptyList(); } - final SHumanTaskDefinition humanTask = (SHumanTaskDefinition) flowNode; final String actorName = humanTask.getActorName(); final List userIds = getUserIdsForActor(serviceAccessor, processDefinitionId, actorName, startIndex, maxResults); diff --git a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/bpm/model/impl/BPMInstancesCreator.java b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/bpm/model/impl/BPMInstancesCreator.java index 93e20be3338..99affbba0c6 100644 --- a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/bpm/model/impl/BPMInstancesCreator.java +++ b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/bpm/model/impl/BPMInstancesCreator.java @@ -227,8 +227,7 @@ public SFlowNodeInstance toFlowNodeInstance(final long processDefinitionId, fina final long parentProcessInstanceId, final boolean createInnerActivity, final int loopCounter, final SStateCategory stateCategory, final long relatedActivityInstanceId) throws SActorNotFoundException, SActivityReadException { - if (!createInnerActivity && sFlowNodeDefinition instanceof SActivityDefinition) { - final SActivityDefinition activityDefinition = (SActivityDefinition) sFlowNodeDefinition; + if (!createInnerActivity && sFlowNodeDefinition instanceof SActivityDefinition activityDefinition) { final SLoopCharacteristics loopCharacteristics = activityDefinition.getLoopCharacteristics(); if (loopCharacteristics != null) { SFlowNodeInstanceBuilder builder; diff --git a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/execution/StateBehaviors.java b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/execution/StateBehaviors.java index c7a94c21368..7a34a4e9add 100644 --- a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/execution/StateBehaviors.java +++ b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/execution/StateBehaviors.java @@ -89,7 +89,6 @@ import org.bonitasoft.engine.core.process.instance.model.business.data.SProcessMultiRefBusinessDataInstance; import org.bonitasoft.engine.core.process.instance.model.business.data.SRefBusinessDataInstance; import org.bonitasoft.engine.core.process.instance.model.event.SBoundaryEventInstance; -import org.bonitasoft.engine.core.process.instance.model.event.SCatchEventInstance; import org.bonitasoft.engine.core.process.instance.model.event.SIntermediateCatchEventInstance; import org.bonitasoft.engine.core.process.instance.model.event.SThrowEventInstance; import org.bonitasoft.engine.data.instance.api.DataInstanceContainer; @@ -203,10 +202,9 @@ public void mapDataOutputOfMultiInstance(final SProcessDefinition processDefinit if (activityDefinition != null) {// can be null if the activity was added in runtime try { final SLoopCharacteristics loopCharacteristics = activityDefinition.getLoopCharacteristics(); - if (loopCharacteristics instanceof SMultiInstanceLoopCharacteristics + if (loopCharacteristics instanceof SMultiInstanceLoopCharacteristics miLoop && ((SMultiInstanceLoopCharacteristics) loopCharacteristics) .getDataOutputItemRef() != null) { - final SMultiInstanceLoopCharacteristics miLoop = (SMultiInstanceLoopCharacteristics) loopCharacteristics; final SBusinessDataDefinition businessData = processContainer .getBusinessDataDefinition(miLoop.getLoopDataOutputRef()); if (businessData == null) { @@ -340,8 +338,7 @@ public void registerWaitingEvent(final SProcessDefinition processDefinition, final SFlowNodeInstance flowNodeInstance) throws SActivityStateExecutionException { // handle catch event - if (flowNodeInstance instanceof SIntermediateCatchEventInstance) { - final SCatchEventInstance intermediateCatchEventInstance = (SCatchEventInstance) flowNodeInstance; + if (flowNodeInstance instanceof SIntermediateCatchEventInstance intermediateCatchEventInstance) { // handleEventTriggerInstances(processDefinition, intermediateCatchEventInstance); final SFlowElementContainerDefinition processContainer = processDefinition.getProcessContainer(); final SIntermediateCatchEventDefinition intermediateCatchEventDefinition = (SIntermediateCatchEventDefinition) processContainer @@ -352,8 +349,7 @@ public void registerWaitingEvent(final SProcessDefinition processDefinition, } catch (final SBonitaException e) { throw new SActivityStateExecutionException("unable to handle catch event " + flowNodeInstance, e); } - } else if (flowNodeInstance instanceof SReceiveTaskInstance) { - final SReceiveTaskInstance receiveTaskInstance = (SReceiveTaskInstance) flowNodeInstance; + } else if (flowNodeInstance instanceof SReceiveTaskInstance receiveTaskInstance) { final SFlowElementContainerDefinition processContainer = processDefinition.getProcessContainer(); final SReceiveTaskDefinition receiveTaskIDefinition = (SReceiveTaskDefinition) processContainer .getFlowNode(receiveTaskInstance @@ -433,10 +429,9 @@ public void updateExpectedDuration(final SProcessDefinition processDefinition, final SFlowElementContainerDefinition processContainer = processDefinition.getProcessContainer(); final SFlowNodeDefinition flowNodeDefinition = processContainer .getFlowNode(flowNodeInstance.getFlowNodeDefinitionId()); - if (!(flowNodeDefinition instanceof SHumanTaskDefinition)) { + if (!(flowNodeDefinition instanceof SHumanTaskDefinition humanTaskDefinition)) { return; } - SHumanTaskDefinition humanTaskDefinition = (SHumanTaskDefinition) flowNodeDefinition; final SExpression expectedDurationExpression = humanTaskDefinition.getExpectedDuration(); if (expectedDurationExpression == null) { return; @@ -490,8 +485,7 @@ public void executeOperations(final SProcessDefinition processDefinition, final final SFlowElementContainerDefinition processContainer = processDefinition.getProcessContainer(); final SFlowNodeDefinition flowNode = processContainer .getFlowNode(activityInstance.getFlowNodeDefinitionId()); - if (flowNode instanceof SActivityDefinition) { - final SActivityDefinition activityDefinition = (SActivityDefinition) flowNode; + if (flowNode instanceof SActivityDefinition activityDefinition) { final List sOperations = activityDefinition.getSOperations(); final SExpressionContext sExpressionContext = new SExpressionContext(activityInstance.getId(), DataInstanceContainer.ACTIVITY_INSTANCE.name(), @@ -505,8 +499,7 @@ public void executeOperations(final SProcessDefinition processDefinition, final public void handleThrowEvent(final SProcessDefinition processDefinition, final SFlowNodeInstance flowNodeInstance) throws SActivityStateExecutionException { - if (flowNodeInstance instanceof SThrowEventInstance) { - final SThrowEventInstance throwEventInstance = (SThrowEventInstance) flowNodeInstance; + if (flowNodeInstance instanceof SThrowEventInstance throwEventInstance) { final SFlowElementContainerDefinition processContainer = processDefinition.getProcessContainer(); final SThrowEventDefinition eventDefinition = (SThrowEventDefinition) processContainer .getFlowNode(throwEventInstance.getFlowNodeDefinitionId()); @@ -755,8 +748,7 @@ private int getNumberOfInstanceToCreateFromSimpleData(final SProcessDefinition p DataInstanceContainer.ACTIVITY_INSTANCE.name(), parentContainerResolver); if (loopDataInput != null) { final Serializable value = loopDataInput.getValue(); - if (value instanceof List) { - final List loopDataInputCollection = (List) value; + if (value instanceof List loopDataInputCollection) { return loopDataInputCollection.size(); } throw new SActivityStateExecutionException( diff --git a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/execution/state/InitializingLoopActivityState.java b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/execution/state/InitializingLoopActivityState.java index ecfd888c3c6..534d9669acc 100644 --- a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/execution/state/InitializingLoopActivityState.java +++ b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/execution/state/InitializingLoopActivityState.java @@ -78,8 +78,7 @@ public StateCode execute(final SProcessDefinition processDefinition, final SFlow final SLoopActivityInstance loopActivity = (SLoopActivityInstance) activityInstanceService .getFlowNodeInstance(flowNodeInstance.getId()); final SLoopCharacteristics loopCharacteristics = activity.getLoopCharacteristics(); - if (loopCharacteristics instanceof SStandardLoopCharacteristics) { - final SStandardLoopCharacteristics standardLoop = (SStandardLoopCharacteristics) loopCharacteristics; + if (loopCharacteristics instanceof SStandardLoopCharacteristics standardLoop) { final SExpression loopMax = ((SStandardLoopCharacteristics) loopCharacteristics).getLoopMax(); Integer intLoopMax; diff --git a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/execution/state/InitializingMultiInstanceActivityState.java b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/execution/state/InitializingMultiInstanceActivityState.java index 57c796c46b4..5a6bd31f077 100644 --- a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/execution/state/InitializingMultiInstanceActivityState.java +++ b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/execution/state/InitializingMultiInstanceActivityState.java @@ -59,8 +59,7 @@ public StateCode execute(final SProcessDefinition processDefinition, final SFlow final SActivityDefinition activity = (SActivityDefinition) processContainer .getFlowNode(flowNodeInstance.getFlowNodeDefinitionId()); final SLoopCharacteristics loopCharacteristics = activity.getLoopCharacteristics(); - if (loopCharacteristics instanceof SMultiInstanceLoopCharacteristics) { - final SMultiInstanceLoopCharacteristics miLoop = (SMultiInstanceLoopCharacteristics) loopCharacteristics; + if (loopCharacteristics instanceof SMultiInstanceLoopCharacteristics miLoop) { final SExpression loopCardinality = miLoop.getLoopCardinality(); int numberOfInstanceMax = -1; if (loopCardinality != null) { diff --git a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/operation/AbstractDocumentLeftOperandHandler.java b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/operation/AbstractDocumentLeftOperandHandler.java index c60246a3c45..bf66cff573b 100644 --- a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/operation/AbstractDocumentLeftOperandHandler.java +++ b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/operation/AbstractDocumentLeftOperandHandler.java @@ -65,8 +65,7 @@ protected long getAuthorId(long containerId, String containerType) { try { if (loggedUserFromSession <= 0 && DataInstanceContainer.ACTIVITY_INSTANCE.name().equals(containerType)) { SActivityInstance activityInstance = activityInstanceService.getActivityInstance(containerId); - if (activityInstance instanceof SHumanTaskInstance) { - SHumanTaskInstance instance = (SHumanTaskInstance) activityInstance; + if (activityInstance instanceof SHumanTaskInstance instance) { return instance.getAssigneeId(); } } diff --git a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/operation/BusinessDataLeftOperandHandler.java b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/operation/BusinessDataLeftOperandHandler.java index 818947f37c9..4e6ca008c9e 100644 --- a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/operation/BusinessDataLeftOperandHandler.java +++ b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/operation/BusinessDataLeftOperandHandler.java @@ -89,8 +89,7 @@ protected Object getBusinessData(final String businessDataName, final long conta new Container(containerId, containerType))); final Class dataClass = (Class) Thread.currentThread().getContextClassLoader() .loadClass(reference.getDataClassName()); - if (reference instanceof SSimpleRefBusinessDataInstance) { - final SSimpleRefBusinessDataInstance simpleRef = (SSimpleRefBusinessDataInstance) reference; + if (reference instanceof SSimpleRefBusinessDataInstance simpleRef) { final Long dataId = simpleRef.getDataId(); if (dataId != null) { return businessDataRepository.findById(dataClass, dataId); @@ -127,8 +126,7 @@ protected void removeBusinessData(final SRefBusinessDataInstance reference) throws ClassNotFoundException, SBusinessDataNotFoundException { final Class dataClass = (Class) Thread.currentThread().getContextClassLoader() .loadClass(reference.getDataClassName()); - if (reference instanceof SSimpleRefBusinessDataInstance) { - final SSimpleRefBusinessDataInstance simpleRef = (SSimpleRefBusinessDataInstance) reference; + if (reference instanceof SSimpleRefBusinessDataInstance simpleRef) { final Entity entity = businessDataRepository.findById(dataClass, simpleRef.getDataId()); businessDataRepository.remove(entity); } else { diff --git a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/operation/UpdateDataRefAction.java b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/operation/UpdateDataRefAction.java index 6b6ce999e6b..f9e5911c5de 100644 --- a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/operation/UpdateDataRefAction.java +++ b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/operation/UpdateDataRefAction.java @@ -111,8 +111,7 @@ public void handleNull(final BusinessDataContext businessDataContext) throws SEn try { final SRefBusinessDataInstance reference = refBusinessDataRetriever .getRefBusinessDataInstance(businessDataContext); - if (reference instanceof SSimpleRefBusinessDataInstance) { - final SSimpleRefBusinessDataInstance simpleReference = (SSimpleRefBusinessDataInstance) reference; + if (reference instanceof SSimpleRefBusinessDataInstance simpleReference) { refBusinessDataService.updateRefBusinessDataInstance(simpleReference, null); } else { final SProcessMultiRefBusinessDataInstance multiReference = (SProcessMultiRefBusinessDataInstance) reference; diff --git a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/service/ModelConvertor.java b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/service/ModelConvertor.java index 8edd25e5dd7..689c19326df 100644 --- a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/service/ModelConvertor.java +++ b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/service/ModelConvertor.java @@ -2103,8 +2103,7 @@ public static BusinessDataReference toBusinessDataReference( if (sRefBusinessDataInstance == null) { return null; } - if (sRefBusinessDataInstance instanceof SProcessMultiRefBusinessDataInstance) { - final SProcessMultiRefBusinessDataInstance multi = (SProcessMultiRefBusinessDataInstance) sRefBusinessDataInstance; + if (sRefBusinessDataInstance instanceof SProcessMultiRefBusinessDataInstance multi) { return new MultipleBusinessDataReferenceImpl(multi.getName(), multi.getDataClassName(), multi.getDataIds()); } final SSimpleRefBusinessDataInstance simple = (SSimpleRefBusinessDataInstance) sRefBusinessDataInstance; diff --git a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/execution/work/BPMWorkFactoryTest.java b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/execution/work/BPMWorkFactoryTest.java index 30ff8a44353..462080acd3a 100644 --- a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/execution/work/BPMWorkFactoryTest.java +++ b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/execution/work/BPMWorkFactoryTest.java @@ -241,10 +241,9 @@ private T getWorkOfClass(BonitaWork work, Class clazz) { if (clazz.isAssignableFrom(work.getClass())) { return ((T) work); } - if (!(work instanceof WrappingBonitaWork)) { + if (!(work instanceof WrappingBonitaWork wrappingBonitaWork)) { return null; } - WrappingBonitaWork wrappingBonitaWork = ((WrappingBonitaWork) work); return getWorkOfClass(wrappingBonitaWork.getWrappedWork(), clazz); } diff --git a/bpm/bonita-synchro-repository/bonita-synchro-register/src/main/java/org/bonitasoft/engine/synchro/FlowNodeReachStateHandler.java b/bpm/bonita-synchro-repository/bonita-synchro-register/src/main/java/org/bonitasoft/engine/synchro/FlowNodeReachStateHandler.java index 21d6b03d915..23ae6ec34f3 100755 --- a/bpm/bonita-synchro-repository/bonita-synchro-register/src/main/java/org/bonitasoft/engine/synchro/FlowNodeReachStateHandler.java +++ b/bpm/bonita-synchro-repository/bonita-synchro-register/src/main/java/org/bonitasoft/engine/synchro/FlowNodeReachStateHandler.java @@ -48,8 +48,7 @@ protected Map getEvent(final SEvent sEvent) { @Override public boolean isInterested(final SEvent event) { // the !isStateExecuting avoid having 2 times the same event in case of execution of e.g. connectors - if (event.getObject() instanceof SFlowNodeInstance) { - final SFlowNodeInstance fni = (SFlowNodeInstance) event.getObject(); + if (event.getObject() instanceof SFlowNodeInstance fni) { boolean interested = !fni.isStateExecuting(); interested &= fni.getStateId() == stateId; return interested; diff --git a/bpm/bonita-synchro-repository/bonita-synchro-register/src/main/java/org/bonitasoft/engine/synchro/TaskReadyHandler.java b/bpm/bonita-synchro-repository/bonita-synchro-register/src/main/java/org/bonitasoft/engine/synchro/TaskReadyHandler.java index 965f34ff259..544ef3757ed 100644 --- a/bpm/bonita-synchro-repository/bonita-synchro-register/src/main/java/org/bonitasoft/engine/synchro/TaskReadyHandler.java +++ b/bpm/bonita-synchro-repository/bonita-synchro-register/src/main/java/org/bonitasoft/engine/synchro/TaskReadyHandler.java @@ -44,8 +44,7 @@ protected Map getEvent(final SEvent sEvent) { @Override public boolean isInterested(final SEvent event) { // the !isStateExecuting avoid having 2 times the same event in case of execution of e.g. connectors - if (event.getObject() instanceof SFlowNodeInstance) { - final SFlowNodeInstance fni = (SFlowNodeInstance) event.getObject(); + if (event.getObject() instanceof SFlowNodeInstance fni) { boolean interested = !fni.isStateExecuting(); interested &= fni.getStateId() == 4; interested &= (fni.getType() == SFlowNodeType.USER_TASK || fni.getType() == SFlowNodeType.MANUAL_TASK); diff --git a/bpm/bonita-web-server/src/main/java/org/bonitasoft/console/common/server/auth/impl/jaas/ConsoleCallbackHandler.java b/bpm/bonita-web-server/src/main/java/org/bonitasoft/console/common/server/auth/impl/jaas/ConsoleCallbackHandler.java index 04c045323e3..ea342a4c432 100644 --- a/bpm/bonita-web-server/src/main/java/org/bonitasoft/console/common/server/auth/impl/jaas/ConsoleCallbackHandler.java +++ b/bpm/bonita-web-server/src/main/java/org/bonitasoft/console/common/server/auth/impl/jaas/ConsoleCallbackHandler.java @@ -61,14 +61,11 @@ public ConsoleCallbackHandler(final String name, final String password) { @Override public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (final Callback callback : callbacks) { - if (callback instanceof NameCallback) { - final NameCallback nc = (NameCallback) callback; + if (callback instanceof NameCallback nc) { nc.setName(this.name); - } else if (callback instanceof PasswordCallback) { - final PasswordCallback pc = (PasswordCallback) callback; + } else if (callback instanceof PasswordCallback pc) { pc.setPassword(this.password.toCharArray()); - } else if (callback instanceof TextInputCallback) { - final TextInputCallback tc = (TextInputCallback) callback; + } else if (callback instanceof TextInputCallback tc) { tc.setText(String.valueOf(TenantsManagementUtils.getDefaultTenantId())); } diff --git a/bpm/bonita-web-server/src/main/java/org/bonitasoft/console/common/server/auth/impl/jaas/ConsoleIdentityLoginModule.java b/bpm/bonita-web-server/src/main/java/org/bonitasoft/console/common/server/auth/impl/jaas/ConsoleIdentityLoginModule.java index 27ef0334ca0..e70ed076645 100644 --- a/bpm/bonita-web-server/src/main/java/org/bonitasoft/console/common/server/auth/impl/jaas/ConsoleIdentityLoginModule.java +++ b/bpm/bonita-web-server/src/main/java/org/bonitasoft/console/common/server/auth/impl/jaas/ConsoleIdentityLoginModule.java @@ -240,8 +240,7 @@ protected void adjustLoggingsArgs(final Map callbacks, final M if (!loggingsArgs.containsKey(JAVAX_SECURITY_AUTH_LOGIN_PASSWORD)) { // update password - if (callbacks.get(PASSWORD_PROMPT) instanceof PasswordCallback) { - PasswordCallback pwdCallback = ((PasswordCallback) callbacks.get(PASSWORD_PROMPT)); + if (callbacks.get(PASSWORD_PROMPT) instanceof PasswordCallback pwdCallback) { loggingsArgs.put(JAVAX_SECURITY_AUTH_LOGIN_PASSWORD, String.valueOf(pwdCallback.getPassword())); pwdCallback.clearPassword(); } diff --git a/bpm/bonita-web-server/src/main/java/org/bonitasoft/console/common/server/page/CustomPageService.java b/bpm/bonita-web-server/src/main/java/org/bonitasoft/console/common/server/page/CustomPageService.java index 922d4b69696..3246aded6ce 100644 --- a/bpm/bonita-web-server/src/main/java/org/bonitasoft/console/common/server/page/CustomPageService.java +++ b/bpm/bonita-web-server/src/main/java/org/bonitasoft/console/common/server/page/CustomPageService.java @@ -322,10 +322,9 @@ private GroovyClassLoader createPageClassloader(final String pageName, final Fil private boolean isOutdated(GroovyClassLoader pageClassLoader, BDMClientDependenciesResolver bdmDependenciesResolver) { final ClassLoader parent = pageClassLoader.getParent(); - if (!(parent instanceof VersionedClassloader)) { + if (!(parent instanceof VersionedClassloader cachedClassloader)) { throw new IllegalStateException("Parent classloader should be versioned."); } - final VersionedClassloader cachedClassloader = (VersionedClassloader) parent; return !cachedClassloader.hasVersion(bdmDependenciesResolver.getBusinessDataModelVersion()); } diff --git a/bpm/bonita-web-server/src/main/java/org/bonitasoft/web/rest/server/api/bdm/BusinessDataReferenceResource.java b/bpm/bonita-web-server/src/main/java/org/bonitasoft/web/rest/server/api/bdm/BusinessDataReferenceResource.java index 6defe1c2f7c..874db086ffa 100644 --- a/bpm/bonita-web-server/src/main/java/org/bonitasoft/web/rest/server/api/bdm/BusinessDataReferenceResource.java +++ b/bpm/bonita-web-server/src/main/java/org/bonitasoft/web/rest/server/api/bdm/BusinessDataReferenceResource.java @@ -42,8 +42,7 @@ public BusinessDataReferenceClient getProcessBusinessDataReference() throws Data } public static BusinessDataReferenceClient toClient(BusinessDataReference object) { - if (object instanceof SimpleBusinessDataReference) { - final SimpleBusinessDataReference businessDataReference = (SimpleBusinessDataReference) object; + if (object instanceof SimpleBusinessDataReference businessDataReference) { return new SimpleBusinessDataReferenceClient(object.getName(), object.getType(), getUrl(object.getType(), getStorageIdString(businessDataReference)), businessDataReference.getStorageId()); diff --git a/bpm/bonita-web-server/src/main/java/org/bonitasoft/web/rest/server/api/bdm/BusinessDataResource.java b/bpm/bonita-web-server/src/main/java/org/bonitasoft/web/rest/server/api/bdm/BusinessDataResource.java index 5c177614f30..a7c03f48a52 100644 --- a/bpm/bonita-web-server/src/main/java/org/bonitasoft/web/rest/server/api/bdm/BusinessDataResource.java +++ b/bpm/bonita-web-server/src/main/java/org/bonitasoft/web/rest/server/api/bdm/BusinessDataResource.java @@ -65,8 +65,7 @@ private DataNotFoundException searchInCauseDataNotFoundException(final Throwable // Exception are all wrapped so we need to get cause fist if (throwable.getCause() != null) { final Throwable realException = throwable.getCause(); - if (realException instanceof CommandExecutionException) { - final CommandExecutionException e = (CommandExecutionException) realException; + if (realException instanceof CommandExecutionException e) { if (e.getCause() instanceof DataNotFoundException) { return (DataNotFoundException) e.getCause(); } diff --git a/bpm/bonita-web-server/src/main/java/org/bonitasoft/web/toolkit/client/common/Tree.java b/bpm/bonita-web-server/src/main/java/org/bonitasoft/web/toolkit/client/common/Tree.java index 88502dd2cd6..9b2988802bb 100644 --- a/bpm/bonita-web-server/src/main/java/org/bonitasoft/web/toolkit/client/common/Tree.java +++ b/bpm/bonita-web-server/src/main/java/org/bonitasoft/web/toolkit/client/common/Tree.java @@ -99,12 +99,10 @@ public boolean equals(final Object o) { if (o == this) { return true; } - if (!(o instanceof Tree)) { + if (!(o instanceof Tree tree)) { return false; } - final Tree tree = (Tree) o; - if (tree.size() != this.size()) { return false; } diff --git a/bpm/bonita-web-server/src/main/java/org/bonitasoft/web/toolkit/client/common/TreeIndexed.java b/bpm/bonita-web-server/src/main/java/org/bonitasoft/web/toolkit/client/common/TreeIndexed.java index aa70932d0ef..744262169df 100644 --- a/bpm/bonita-web-server/src/main/java/org/bonitasoft/web/toolkit/client/common/TreeIndexed.java +++ b/bpm/bonita-web-server/src/main/java/org/bonitasoft/web/toolkit/client/common/TreeIndexed.java @@ -123,12 +123,10 @@ public boolean equals(final Object o) { if (o == this) { return true; } - if (!(o instanceof TreeIndexed)) { + if (!(o instanceof TreeIndexed tree)) { return false; } - final TreeIndexed tree = (TreeIndexed) o; - if (tree.size() != this.size()) { return false; } diff --git a/services/bonita-business-application/src/main/java/org/bonitasoft/engine/business/application/impl/MenuIndex.java b/services/bonita-business-application/src/main/java/org/bonitasoft/engine/business/application/impl/MenuIndex.java index 40972061338..031080720c5 100755 --- a/services/bonita-business-application/src/main/java/org/bonitasoft/engine/business/application/impl/MenuIndex.java +++ b/services/bonita-business-application/src/main/java/org/bonitasoft/engine/business/application/impl/MenuIndex.java @@ -46,11 +46,9 @@ public int getLastUsedIndex() { public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof MenuIndex)) + if (!(o instanceof MenuIndex menuIndex)) return false; - MenuIndex menuIndex = (MenuIndex) o; - if (lastUsedIndex != menuIndex.lastUsedIndex) return false; if (value != menuIndex.value) diff --git a/services/bonita-business-application/src/main/java/org/bonitasoft/engine/business/application/impl/filter/ApplicationPageRelatedMenusFilterBuilder.java b/services/bonita-business-application/src/main/java/org/bonitasoft/engine/business/application/impl/filter/ApplicationPageRelatedMenusFilterBuilder.java index 73d4b5b88a7..7020278b59d 100755 --- a/services/bonita-business-application/src/main/java/org/bonitasoft/engine/business/application/impl/filter/ApplicationPageRelatedMenusFilterBuilder.java +++ b/services/bonita-business-application/src/main/java/org/bonitasoft/engine/business/application/impl/filter/ApplicationPageRelatedMenusFilterBuilder.java @@ -48,11 +48,9 @@ public QueryOptions buildQueryOptions() { public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof ApplicationPageRelatedMenusFilterBuilder)) + if (!(o instanceof ApplicationPageRelatedMenusFilterBuilder that)) return false; - ApplicationPageRelatedMenusFilterBuilder that = (ApplicationPageRelatedMenusFilterBuilder) o; - if (applicationPageId != that.applicationPageId) return false; if (range != null ? !range.equals(that.range) : that.range != null) diff --git a/services/bonita-business-application/src/main/java/org/bonitasoft/engine/business/application/impl/filter/ApplicationRelatedMenusFilterBuilder.java b/services/bonita-business-application/src/main/java/org/bonitasoft/engine/business/application/impl/filter/ApplicationRelatedMenusFilterBuilder.java index f7fe6cc480f..b3ee2978891 100755 --- a/services/bonita-business-application/src/main/java/org/bonitasoft/engine/business/application/impl/filter/ApplicationRelatedMenusFilterBuilder.java +++ b/services/bonita-business-application/src/main/java/org/bonitasoft/engine/business/application/impl/filter/ApplicationRelatedMenusFilterBuilder.java @@ -51,11 +51,9 @@ public QueryOptions buildQueryOptions() { public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof ApplicationRelatedMenusFilterBuilder)) + if (!(o instanceof ApplicationRelatedMenusFilterBuilder that)) return false; - ApplicationRelatedMenusFilterBuilder that = (ApplicationRelatedMenusFilterBuilder) o; - if (applicationId != that.applicationId) return false; if (range != null ? !range.equals(that.range) : that.range != null) diff --git a/services/bonita-business-application/src/main/java/org/bonitasoft/engine/business/application/impl/filter/ChildrenMenusFilterBuilder.java b/services/bonita-business-application/src/main/java/org/bonitasoft/engine/business/application/impl/filter/ChildrenMenusFilterBuilder.java index 7797fae405b..8b8e51b4198 100755 --- a/services/bonita-business-application/src/main/java/org/bonitasoft/engine/business/application/impl/filter/ChildrenMenusFilterBuilder.java +++ b/services/bonita-business-application/src/main/java/org/bonitasoft/engine/business/application/impl/filter/ChildrenMenusFilterBuilder.java @@ -15,6 +15,7 @@ import java.util.Collections; import java.util.List; +import java.util.Objects; import org.bonitasoft.engine.business.application.model.SApplicationMenu; import org.bonitasoft.engine.persistence.FilterOption; @@ -27,8 +28,8 @@ */ public class ChildrenMenusFilterBuilder implements FilterBuilder { - private SelectRange range; - private long parentId; + private final SelectRange range; + private final long parentId; public ChildrenMenusFilterBuilder(SelectRange range, long parentId) { this.range = range; @@ -48,14 +49,12 @@ public QueryOptions buildQueryOptions() { public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof ChildrenMenusFilterBuilder)) + if (!(o instanceof ChildrenMenusFilterBuilder that)) return false; - ChildrenMenusFilterBuilder that = (ChildrenMenusFilterBuilder) o; - if (parentId != that.parentId) return false; - if (range != null ? !range.equals(that.range) : that.range != null) + if (!Objects.equals(range, that.range)) return false; return true; diff --git a/services/bonita-business-application/src/main/java/org/bonitasoft/engine/business/application/impl/filter/SelectRange.java b/services/bonita-business-application/src/main/java/org/bonitasoft/engine/business/application/impl/filter/SelectRange.java index 9c3c6a9f82b..297d4cf6f08 100755 --- a/services/bonita-business-application/src/main/java/org/bonitasoft/engine/business/application/impl/filter/SelectRange.java +++ b/services/bonita-business-application/src/main/java/org/bonitasoft/engine/business/application/impl/filter/SelectRange.java @@ -38,11 +38,9 @@ public int getMaxResults() { public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof SelectRange)) + if (!(o instanceof SelectRange that)) return false; - SelectRange that = (SelectRange) o; - if (maxResults != that.maxResults) return false; if (startIndex != that.startIndex) diff --git a/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/IndexUpdaterTest.java b/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/IndexUpdaterTest.java index 199c153fdfd..5147260732e 100755 --- a/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/IndexUpdaterTest.java +++ b/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/IndexUpdaterTest.java @@ -57,7 +57,7 @@ public class IndexUpdaterTest { private IndexUpdater indexUpdater; @Before - public void setUp() throws Exception { + public void setUp() { indexUpdater = new IndexUpdater(applicationService, MAX_RESULTS); given(menu3.getIndex()).willReturn(3); diff --git a/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/MenuIndexValidatorTest.java b/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/MenuIndexValidatorTest.java index 374f2732f8b..6cd5553ac5f 100755 --- a/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/MenuIndexValidatorTest.java +++ b/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/MenuIndexValidatorTest.java @@ -24,7 +24,7 @@ public class MenuIndexValidatorTest { private MenuIndexValidator validator = new MenuIndexValidator(); @Test - public void isValid_should_return_problem_when_new_index_is_less_than_or_equal_zero() throws Exception { + public void isValid_should_return_problem_when_new_index_is_less_than_or_equal_zero() { //given MenuIndex oldIndex = new MenuIndex(null, 2, 5); MenuIndex newIndex = new MenuIndex(null, 0, 5); @@ -39,8 +39,7 @@ public void isValid_should_return_problem_when_new_index_is_less_than_or_equal_z } @Test - public void isValid_should_return_problem_when_parent_is_same_and_new_index_is_greater_than_last_used_index() - throws Exception { + public void isValid_should_return_problem_when_parent_is_same_and_new_index_is_greater_than_last_used_index() { //given MenuIndex oldIndex = new MenuIndex(null, 5, 5); MenuIndex newIndex = new MenuIndex(null, 6, 5); @@ -55,8 +54,7 @@ public void isValid_should_return_problem_when_parent_is_same_and_new_index_is_g } @Test - public void isValid_should_return_no_problems_when_parent_is_not_the_same_and_new_index_is_greater_than_last_used_index_by_one() - throws Exception { + public void isValid_should_return_no_problems_when_parent_is_not_the_same_and_new_index_is_greater_than_last_used_index_by_one() { //given MenuIndex oldIndex = new MenuIndex(null, 5, 5); MenuIndex newIndex = new MenuIndex(2L, 4, 3); @@ -69,8 +67,7 @@ public void isValid_should_return_no_problems_when_parent_is_not_the_same_and_ne } @Test - public void isValid_should_return_problem_when_parent_is_not_the_same_and_new_index_is_greater_than_last_used_index_by_more_than_one() - throws Exception { + public void isValid_should_return_problem_when_parent_is_not_the_same_and_new_index_is_greater_than_last_used_index_by_more_than_one() { //given MenuIndex oldIndex = new MenuIndex(null, 5, 5); MenuIndex newIndex = new MenuIndex(2L, 5, 3); @@ -84,7 +81,7 @@ public void isValid_should_return_problem_when_parent_is_not_the_same_and_new_in } @Test - public void isValid_should_return_true_when_new_index_is_valid() throws Exception { + public void isValid_should_return_true_when_new_index_is_valid() { //given MenuIndex oldIndex = new MenuIndex(null, 5, 5); MenuIndex newIndex = new MenuIndex(null, 4, 5); diff --git a/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/cleaner/ApplicationMenuCleanerTest.java b/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/cleaner/ApplicationMenuCleanerTest.java index 789553114d9..7bbc8625324 100755 --- a/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/cleaner/ApplicationMenuCleanerTest.java +++ b/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/cleaner/ApplicationMenuCleanerTest.java @@ -47,7 +47,7 @@ public class ApplicationMenuCleanerTest { private ApplicationMenuCleaner cleaner; @Before - public void setUp() throws Exception { + public void setUp() { given(options.getNumberOfResults()).willReturn(MAX_RESULTS); } diff --git a/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/filter/ApplicationPageRelatedMenusFilterBuilderTest.java b/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/filter/ApplicationPageRelatedMenusFilterBuilderTest.java index 0e4b4f8f1a2..cec0a1fc707 100755 --- a/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/filter/ApplicationPageRelatedMenusFilterBuilderTest.java +++ b/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/filter/ApplicationPageRelatedMenusFilterBuilderTest.java @@ -28,7 +28,7 @@ public class ApplicationPageRelatedMenusFilterBuilderTest { public static final int MAX_RESULTS = 10; @Test - public void buildQueryOptions_should_filter_on_applicationPageId() throws Exception { + public void buildQueryOptions_should_filter_on_applicationPageId() { //given long applicationPageId = 2L; ApplicationPageRelatedMenusFilterBuilder builder = new ApplicationPageRelatedMenusFilterBuilder( diff --git a/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/filter/ApplicationRelatedMenusFilterBuilderTest.java b/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/filter/ApplicationRelatedMenusFilterBuilderTest.java index 9c9df2edb22..430b5c8ab82 100755 --- a/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/filter/ApplicationRelatedMenusFilterBuilderTest.java +++ b/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/filter/ApplicationRelatedMenusFilterBuilderTest.java @@ -28,7 +28,7 @@ public class ApplicationRelatedMenusFilterBuilderTest { public static final int MAX_RESULTS = 10; @Test - public void buildQueryOptions_should_filter_on_applicationId() throws Exception { + public void buildQueryOptions_should_filter_on_applicationId() { //given long applicationId = 1; ApplicationRelatedMenusFilterBuilder builder = new ApplicationRelatedMenusFilterBuilder( diff --git a/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/filter/ChildrenMenusFilterBuilderTest.java b/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/filter/ChildrenMenusFilterBuilderTest.java index 9425f2c4cea..c2a77d8bd5f 100755 --- a/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/filter/ChildrenMenusFilterBuilderTest.java +++ b/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/filter/ChildrenMenusFilterBuilderTest.java @@ -28,7 +28,7 @@ public class ChildrenMenusFilterBuilderTest { public static final int MAX_RESULTS = 10; @Test - public void build_query_options_should_filter_on_parent_id() throws Exception { + public void build_query_options_should_filter_on_parent_id() { //given long parentId = 4L; ChildrenMenusFilterBuilder builder = new ChildrenMenusFilterBuilder(new SelectRange(START_INDEX, MAX_RESULTS), diff --git a/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/filter/SelectRangeTest.java b/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/filter/SelectRangeTest.java index 61f4124d08e..1599dcbdd80 100755 --- a/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/filter/SelectRangeTest.java +++ b/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/filter/SelectRangeTest.java @@ -20,7 +20,7 @@ public class SelectRangeTest { @Test - public void getStartIndex_should_return_startIndex_used_in_constructor() throws Exception { + public void getStartIndex_should_return_startIndex_used_in_constructor() { //given SelectRange range = new SelectRange(5, 10); @@ -29,7 +29,7 @@ public void getStartIndex_should_return_startIndex_used_in_constructor() throws } @Test - public void getMaxResults_should_return_maxResults_used_in_constructor() throws Exception { + public void getMaxResults_should_return_maxResults_used_in_constructor() { //given SelectRange range = new SelectRange(5, 10); diff --git a/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/model/builder/SApplicationUpdateBuilderTest.java b/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/model/builder/SApplicationUpdateBuilderTest.java index 049963f8688..a90ba563b1a 100644 --- a/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/model/builder/SApplicationUpdateBuilderTest.java +++ b/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/model/builder/SApplicationUpdateBuilderTest.java @@ -25,7 +25,7 @@ public class SApplicationUpdateBuilderTest { @Test - public void constructorShouldUpdateUpdatedByAndLastUpdateDateFields() throws Exception { + public void constructorShouldUpdateUpdatedByAndLastUpdateDateFields() { //given long homePageId = 4L; long updaterUserId = 17L; diff --git a/services/bonita-business-data/bonita-business-data-api/src/main/java/org/bonitasoft/engine/business/data/proxy/ServerProxyfier.java b/services/bonita-business-data/bonita-business-data-api/src/main/java/org/bonitasoft/engine/business/data/proxy/ServerProxyfier.java index 67332454ec0..7b2369a73c4 100644 --- a/services/bonita-business-data/bonita-business-data-api/src/main/java/org/bonitasoft/engine/business/data/proxy/ServerProxyfier.java +++ b/services/bonita-business-data/bonita-business-data-api/src/main/java/org/bonitasoft/engine/business/data/proxy/ServerProxyfier.java @@ -141,8 +141,7 @@ private Object proxifyIfNeeded(final Object invocationResult) { } private boolean isAListOfEntities(final Object invocationResult) { - if (invocationResult instanceof List) { - final List list = (List) invocationResult; + if (invocationResult instanceof List list) { return !list.isEmpty() && list.get(0) instanceof Entity; } return false; diff --git a/services/bonita-business-data/bonita-business-data-client-resources/src/main/java/org/bonitasoft/engine/bdm/dao/client/resources/proxy/Proxyfier.java b/services/bonita-business-data/bonita-business-data-client-resources/src/main/java/org/bonitasoft/engine/bdm/dao/client/resources/proxy/Proxyfier.java index fe3015c1265..28b3dace790 100644 --- a/services/bonita-business-data/bonita-business-data-client-resources/src/main/java/org/bonitasoft/engine/bdm/dao/client/resources/proxy/Proxyfier.java +++ b/services/bonita-business-data/bonita-business-data-client-resources/src/main/java/org/bonitasoft/engine/bdm/dao/client/resources/proxy/Proxyfier.java @@ -127,8 +127,7 @@ private Object proxifyIfNeeded(final Object invocationResult) { } private boolean isAListOfEntities(final Object invocationResult) { - if (invocationResult instanceof List) { - final List list = (List) invocationResult; + if (invocationResult instanceof List list) { if (!list.isEmpty() && list.get(0) instanceof Entity) { return true; } diff --git a/services/bonita-business-data/bonita-business-data-client-resources/src/test/java/org/bonitasoft/engine/bdm/proxy/model/TestEntity.java b/services/bonita-business-data/bonita-business-data-client-resources/src/test/java/org/bonitasoft/engine/bdm/proxy/model/TestEntity.java index 3b0cf0db308..ee08ea27237 100644 --- a/services/bonita-business-data/bonita-business-data-client-resources/src/test/java/org/bonitasoft/engine/bdm/proxy/model/TestEntity.java +++ b/services/bonita-business-data/bonita-business-data-client-resources/src/test/java/org/bonitasoft/engine/bdm/proxy/model/TestEntity.java @@ -86,8 +86,7 @@ public boolean equals(Object obj) { return true; if (obj == null) return false; - if (obj instanceof TestEntity) { - TestEntity other = (TestEntity) obj; + if (obj instanceof TestEntity other) { if (entity == null) { if (other.entity != null) return false; diff --git a/services/bonita-business-data/bonita-business-data-impl/src/main/java/org/bonitasoft/engine/business/data/impl/jackson/utils/Link.java b/services/bonita-business-data/bonita-business-data-impl/src/main/java/org/bonitasoft/engine/business/data/impl/jackson/utils/Link.java index 18d056ab32b..6b3801b4026 100644 --- a/services/bonita-business-data/bonita-business-data-impl/src/main/java/org/bonitasoft/engine/business/data/impl/jackson/utils/Link.java +++ b/services/bonita-business-data/bonita-business-data-impl/src/main/java/org/bonitasoft/engine/business/data/impl/jackson/utils/Link.java @@ -50,9 +50,8 @@ public String toString() { public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof Link)) + if (!(o instanceof Link link)) return false; - Link link = (Link) o; return Objects.equals(rel, link.rel) && Objects.equals(href, link.href); } diff --git a/services/bonita-business-data/bonita-business-data-impl/src/test/java/org/bonitasoft/engine/business/data/impl/EntitySerializerPojo.java b/services/bonita-business-data/bonita-business-data-impl/src/test/java/org/bonitasoft/engine/business/data/impl/EntitySerializerPojo.java index c7ffa99ee06..8fdb134c9c8 100644 --- a/services/bonita-business-data/bonita-business-data-impl/src/test/java/org/bonitasoft/engine/business/data/impl/EntitySerializerPojo.java +++ b/services/bonita-business-data/bonita-business-data-impl/src/test/java/org/bonitasoft/engine/business/data/impl/EntitySerializerPojo.java @@ -243,11 +243,9 @@ public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof EntitySerializerPojo)) + if (!(o instanceof EntitySerializerPojo that)) return false; - EntitySerializerPojo that = (EntitySerializerPojo) o; - return new EqualsBuilder() .append(getPersistenceId(), that.getPersistenceId()) .append(getPersistenceVersion(), that.getPersistenceVersion()) diff --git a/services/bonita-commons/src/main/java/org/bonitasoft/engine/commons/TypeConverterUtil.java b/services/bonita-commons/src/main/java/org/bonitasoft/engine/commons/TypeConverterUtil.java index 026b4d71af8..c0ebaa40c53 100644 --- a/services/bonita-commons/src/main/java/org/bonitasoft/engine/commons/TypeConverterUtil.java +++ b/services/bonita-commons/src/main/java/org/bonitasoft/engine/commons/TypeConverterUtil.java @@ -60,10 +60,9 @@ private class LocalDateConverter extends AbstractConverter { @Override protected T convertToType(Class type, Object value) throws Throwable { - if (!(value instanceof String)) { + if (!(value instanceof String valueAsString)) { throw conversionException(type, value); } - String valueAsString = (String) value; if (valueAsString.length() > MAX_LOCAL_DATE_LENGTH) { valueAsString = valueAsString.substring(0, MAX_LOCAL_DATE_LENGTH); } @@ -80,10 +79,9 @@ private class LocalDateTimeConverter extends AbstractConverter { @Override protected T convertToType(Class type, Object value) throws Throwable { - if (!(value instanceof String)) { + if (!(value instanceof String paramValueString)) { throw conversionException(type, value); } - String paramValueString = (String) value; try { return type.cast(LocalDateTime.parse(paramValueString)); } catch (DateTimeParseException e) { diff --git a/services/bonita-expression/src/main/java/org/bonitasoft/engine/expression/model/impl/SExpressionImpl.java b/services/bonita-expression/src/main/java/org/bonitasoft/engine/expression/model/impl/SExpressionImpl.java index 48302b2782b..78b23284bad 100644 --- a/services/bonita-expression/src/main/java/org/bonitasoft/engine/expression/model/impl/SExpressionImpl.java +++ b/services/bonita-expression/src/main/java/org/bonitasoft/engine/expression/model/impl/SExpressionImpl.java @@ -131,9 +131,8 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof SExpressionImpl)) + if (!(o instanceof SExpressionImpl that)) return false; - SExpressionImpl that = (SExpressionImpl) o; return Objects.equals(name, that.name) && Objects.equals(content, that.content) && Objects.equals(returnType, that.returnType) && diff --git a/services/bonita-persistence/src/main/java/org/bonitasoft/engine/persistence/OrderByOption.java b/services/bonita-persistence/src/main/java/org/bonitasoft/engine/persistence/OrderByOption.java index 51a26f63af7..1247e438136 100755 --- a/services/bonita-persistence/src/main/java/org/bonitasoft/engine/persistence/OrderByOption.java +++ b/services/bonita-persistence/src/main/java/org/bonitasoft/engine/persistence/OrderByOption.java @@ -57,11 +57,9 @@ public String toString() { public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof OrderByOption)) + if (!(o instanceof OrderByOption that)) return false; - OrderByOption that = (OrderByOption) o; - if (clazz != null ? !clazz.equals(that.clazz) : that.clazz != null) return false; if (fieldName != null ? !fieldName.equals(that.fieldName) : that.fieldName != null) diff --git a/services/bonita-persistence/src/main/java/org/bonitasoft/engine/persistence/QueryOptions.java b/services/bonita-persistence/src/main/java/org/bonitasoft/engine/persistence/QueryOptions.java index 0e5b4c09a44..ae6546931c4 100755 --- a/services/bonita-persistence/src/main/java/org/bonitasoft/engine/persistence/QueryOptions.java +++ b/services/bonita-persistence/src/main/java/org/bonitasoft/engine/persistence/QueryOptions.java @@ -180,12 +180,10 @@ public boolean equals(final Object o) { if (this == o) { return true; } - if (!(o instanceof QueryOptions)) { + if (!(o instanceof QueryOptions that)) { return false; } - final QueryOptions that = (QueryOptions) o; - if (fromIndex != that.fromIndex) { return false; } diff --git a/services/bonita-scheduler/src/main/java/org/bonitasoft/engine/scheduler/impl/QuartzJobListener.java b/services/bonita-scheduler/src/main/java/org/bonitasoft/engine/scheduler/impl/QuartzJobListener.java index a304201647f..64e7f0664af 100644 --- a/services/bonita-scheduler/src/main/java/org/bonitasoft/engine/scheduler/impl/QuartzJobListener.java +++ b/services/bonita-scheduler/src/main/java/org/bonitasoft/engine/scheduler/impl/QuartzJobListener.java @@ -126,8 +126,7 @@ protected Long getTenantId(final JobDetail jobDetail) { private StatelessJob getBosJob(final JobExecutionContext context) { final Job instance = context.getJobInstance(); - if (instance instanceof AbstractQuartzJob) { - final AbstractQuartzJob job = (AbstractQuartzJob) instance; + if (instance instanceof AbstractQuartzJob job) { return job.getBosJob(); } return null; diff --git a/services/bonita-scheduler/src/main/java/org/bonitasoft/engine/scheduler/impl/QuartzSchedulerExecutor.java b/services/bonita-scheduler/src/main/java/org/bonitasoft/engine/scheduler/impl/QuartzSchedulerExecutor.java index 167b83b7dcb..1c4b2d7fd65 100644 --- a/services/bonita-scheduler/src/main/java/org/bonitasoft/engine/scheduler/impl/QuartzSchedulerExecutor.java +++ b/services/bonita-scheduler/src/main/java/org/bonitasoft/engine/scheduler/impl/QuartzSchedulerExecutor.java @@ -205,8 +205,7 @@ org.quartz.Trigger getQuartzTrigger(final Trigger trigger, final String jobName, final TriggerBuilder base = TriggerBuilder.newTrigger().forJob(jobName, tenantId) .withIdentity(trigger.getName(), tenantId) .startNow(); - if (trigger instanceof CronTrigger) { - final CronTrigger cronTrigger = (CronTrigger) trigger; + if (trigger instanceof CronTrigger cronTrigger) { final CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder .cronSchedule(cronTrigger.getExpression()); switch (cronTrigger.getMisfireHandlingPolicy()) {