Source:
<code>public Task update(UpdateTaskPayload updateTaskPayload) { Task task; <START> int updates=0; <END> String oldValue,newValue; try { task = task(updateTaskPayload.getTaskId()); } catch (IllegalStateException ex) { throw new IllegalStateException("The authenticated user cannot update the task" + updateTaskPayload.getTaskId() + " due it is not the current assignee"); } String authenticatedUserId = securityManager.getAuthenticatedUserId(); if (!Objects.equals(task.getAssignee(), authenticatedUserId)) { throw new IllegalStateException("You cannot update a task where you are not the assignee"); } org.activiti.engine.task.Task internalTask = getInternalTask(updateTaskPayload.getTaskId()); if ((newValue=updateTaskPayload.getTaskName()) != null) { oldValue=internalTask.getName(); if (!Objects.equals(oldValue,newValue)) { updates++; internalTask.setName(newValue); } } if ((newValue=updateTaskPayload.getDescription()) != null) { oldValue=internalTask.getDescription(); if (!Objects.equals(oldValue,newValue)) { updates++; internalTask.setDescription(newValue); } } if (updateTaskPayload.getPriority() != null) { if (internalTask.getPriority()!=updateTaskPayload.getPriority()) { updates++; internalTask.setPriority(updateTaskPayload.getPriority()); } } if (updateTaskPayload.getDueDate() != null) { if (!Objects.equals(internalTask.getDueDate(),updateTaskPayload.getDueDate())) { updates++; internalTask.setDueDate(updateTaskPayload.getDueDate()); } } if ((newValue=updateTaskPayload.getParentTaskId()) != null) { oldValue=internalTask.getParentTaskId(); if (!Objects.equals(oldValue,newValue)) { updates++; internalTask.setParentTaskId(newValue); } } if ((newValue=updateTaskPayload.getFormKey()) != null) { oldValue=internalTask.getFormKey(); if (!Objects.equals(oldValue,newValue)) { updates++; internalTask.setFormKey(newValue); } } if (updates>0) taskService.saveTask(internalTask); return taskConverter.from(getInternalTask(updateTaskPayload.getTaskId())); }</code><technical_language>@CTI777 great stuff well! this is better</technical_language>

Target:
public Task update(UpdateTaskPayload updateTaskPayload) { Task task; int updates=0; String oldValue,newValue; try { task = task(updateTaskPayload.getTaskId()); } catch (IllegalStateException ex) { throw new IllegalStateException("The authenticated user cannot update the task" + updateTaskPayload.getTaskId() + " due it is not the current assignee"); } String authenticatedUserId = securityManager.getAuthenticatedUserId(); if (!Objects.equals(task.getAssignee(),authenticatedUserId)) { throw new IllegalStateException("You cannot update a task where you are not the assignee"); } org.activiti.engine.task.Task internalTask = getInternalTask(updateTaskPayload.getTaskId()); if ((newValue = updateTaskPayload.getTaskName()) != null) { oldValue = internalTask.getName(); if (!Objects.equals(oldValue,newValue)) { updates++; internalTask.setName(newValue); } } if ((newValue = updateTaskPayload.getDescription()) != null) { oldValue = internalTask.getDescription(); if (!Objects.equals(oldValue,newValue)) { updates++; internalTask.setDescription(newValue); } } if (updateTaskPayload.getPriority() != null) { if (internalTask.getPriority()!=updateTaskPayload.getPriority()) { updates++; internalTask.setPriority(updateTaskPayload.getPriority()); } } if (updateTaskPayload.getDueDate() != null) { if (!Objects.equals(internalTask.getDueDate(),updateTaskPayload.getDueDate())) { updates++; internalTask.setDueDate(updateTaskPayload.getDueDate()); } } if ((newValue=updateTaskPayload.getParentTaskId()) != null) { oldValue = internalTask.getParentTaskId(); if (!Objects.equals(oldValue,newValue)) { updates++; internalTask.setParentTaskId(newValue); } } if ((newValue=updateTaskPayload.getFormKey()) != null) { oldValue = internalTask.getFormKey(); if (!Objects.equals(oldValue,newValue)) { updates++; internalTask.setFormKey(newValue); } } if (updates > 0) { taskService.saveTask(internalTask); } return taskConverter.from(getInternalTask(updateTaskPayload.getTaskId())); }