Skip to content

Commit

Permalink
Optimized boolean transformations
Browse files Browse the repository at this point in the history
  • Loading branch information
Prathamesh Mane authored and filiphr committed Aug 23, 2023
1 parent cd6ca22 commit 11696a3
Show file tree
Hide file tree
Showing 26 changed files with 105 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ public DataResponse<AppDefinitionResponse> getForms(@ApiParam(hidden = true) @Re
}
}
if (allRequestParams.containsKey("latest")) {
boolean latest = Boolean.parseBoolean(allRequestParams.get("latest"));
if (latest) {
if (Boolean.parseBoolean(allRequestParams.get("latest"))) {
appDefinitionQuery.latestVersion();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public DataResponse<HistoricTaskInstanceResponse> getHistoricProcessInstances(@A
queryRequest.setTaskCandidateGroup(allRequestParams.get("taskCandidateGroup"));
}

if (allRequestParams.containsKey("ignoreTaskAssignee") && Boolean.valueOf(allRequestParams.get("ignoreTaskAssignee"))) {
if (allRequestParams.containsKey("ignoreTaskAssignee") && Boolean.parseBoolean(allRequestParams.get("ignoreTaskAssignee"))) {
queryRequest.setIgnoreTaskAssignee(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public DataResponse<JobResponse> getJobs(@ApiParam(hidden = true) @RequestParam
query.scopeId(allRequestParams.get("caseInstanceId"));
query.scopeType(ScopeTypes.CMMN);
}
if (allRequestParams.containsKey("withoutScopeId") && Boolean.valueOf(allRequestParams.get("withoutScopeId"))) {
if (allRequestParams.containsKey("withoutScopeId") && Boolean.parseBoolean(allRequestParams.get("withoutScopeId"))) {
query.withoutScopeId();
}
if (allRequestParams.containsKey("planItemInstanceId")) {
Expand All @@ -122,11 +122,11 @@ public DataResponse<JobResponse> getJobs(@ApiParam(hidden = true) @RequestParam
if (allRequestParams.containsKey("messagesOnly")) {
throw new FlowableIllegalArgumentException("Only one of 'timersOnly' or 'messagesOnly' can be provided.");
}
if (Boolean.valueOf(allRequestParams.get("timersOnly"))) {
if (Boolean.parseBoolean(allRequestParams.get("timersOnly"))) {
query.timers();
}
}
if (allRequestParams.containsKey("messagesOnly") && Boolean.valueOf(allRequestParams.get("messagesOnly"))) {
if (allRequestParams.containsKey("messagesOnly") && Boolean.parseBoolean(allRequestParams.get("messagesOnly"))) {
query.messages();
}
if (allRequestParams.containsKey("dueBefore")) {
Expand All @@ -135,7 +135,7 @@ public DataResponse<JobResponse> getJobs(@ApiParam(hidden = true) @RequestParam
if (allRequestParams.containsKey("dueAfter")) {
query.duedateHigherThan(RequestUtil.getDate(allRequestParams, "dueAfter"));
}
if (allRequestParams.containsKey("withException") && Boolean.valueOf(allRequestParams.get("withException"))) {
if (allRequestParams.containsKey("withException") && Boolean.parseBoolean(allRequestParams.get("withException"))) {
query.withException();
}
if (allRequestParams.containsKey("exceptionMessage")) {
Expand All @@ -147,13 +147,13 @@ public DataResponse<JobResponse> getJobs(@ApiParam(hidden = true) @RequestParam
if (allRequestParams.containsKey("tenantIdLike")) {
query.jobTenantIdLike(allRequestParams.get("tenantIdLike"));
}
if (allRequestParams.containsKey("withoutTenantId") && Boolean.valueOf(allRequestParams.get("withoutTenantId"))) {
if (allRequestParams.containsKey("withoutTenantId") && Boolean.parseBoolean(allRequestParams.get("withoutTenantId"))) {
query.jobWithoutTenantId();
}
if (allRequestParams.containsKey("scopeType")) {
query.scopeType(allRequestParams.get("scopeType"));
}
if (allRequestParams.containsKey("withoutProcessInstanceId") && Boolean.valueOf(allRequestParams.get("withoutProcessInstanceId"))) {
if (allRequestParams.containsKey("withoutProcessInstanceId") && Boolean.parseBoolean(allRequestParams.get("withoutProcessInstanceId"))) {
query.withoutProcessInstanceId();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public DataResponse<HistoryJobResponse> getHistoryJobs(@ApiParam(hidden = true)
query.jobId(allRequestParams.get("scopeType"));
}
if (allRequestParams.containsKey("withException")) {
if (Boolean.valueOf(allRequestParams.get("withException"))) {
if (Boolean.parseBoolean(allRequestParams.get("withException"))) {
query.withException();
}
}
Expand All @@ -92,12 +92,12 @@ public DataResponse<HistoryJobResponse> getHistoryJobs(@ApiParam(hidden = true)
query.lockOwner(allRequestParams.get("lockOwner"));
}
if (allRequestParams.containsKey("locked")) {
if (Boolean.valueOf(allRequestParams.get("locked"))) {
if (Boolean.parseBoolean(allRequestParams.get("locked"))) {
query.locked();
}
}
if (allRequestParams.containsKey("unlocked")) {
if (Boolean.valueOf(allRequestParams.get("unlocked"))) {
if (Boolean.parseBoolean(allRequestParams.get("unlocked"))) {
query.unlocked();
}
}
Expand All @@ -108,7 +108,7 @@ public DataResponse<HistoryJobResponse> getHistoryJobs(@ApiParam(hidden = true)
query.jobTenantIdLike(allRequestParams.get("tenantIdLike"));
}
if (allRequestParams.containsKey("withoutTenantId")) {
if (Boolean.valueOf(allRequestParams.get("withoutTenantId"))) {
if (Boolean.parseBoolean(allRequestParams.get("withoutTenantId"))) {
query.jobWithoutTenantId();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public DataResponse<JobResponse> getJobs(@ApiParam(hidden = true) @RequestParam
query.scopeId(allRequestParams.get("caseInstanceId"));
query.scopeType(ScopeTypes.CMMN);
}
if (allRequestParams.containsKey("withoutScopeId") && Boolean.valueOf(allRequestParams.get("withoutScopeId"))) {
if (allRequestParams.containsKey("withoutScopeId") && Boolean.parseBoolean(allRequestParams.get("withoutScopeId"))) {
query.withoutScopeId();
}
if (allRequestParams.containsKey("planItemInstanceId")) {
Expand All @@ -137,11 +137,11 @@ public DataResponse<JobResponse> getJobs(@ApiParam(hidden = true) @RequestParam
if (allRequestParams.containsKey("messagesOnly")) {
throw new FlowableIllegalArgumentException("Only one of 'timersOnly' or 'messagesOnly' can be provided.");
}
if (Boolean.valueOf(allRequestParams.get("timersOnly"))) {
if (Boolean.parseBoolean(allRequestParams.get("timersOnly"))) {
query.timers();
}
}
if (allRequestParams.containsKey("messagesOnly") && Boolean.valueOf(allRequestParams.get("messagesOnly"))) {
if (allRequestParams.containsKey("messagesOnly") && Boolean.parseBoolean(allRequestParams.get("messagesOnly"))) {
query.messages();
}
if (allRequestParams.containsKey("dueBefore")) {
Expand All @@ -150,7 +150,7 @@ public DataResponse<JobResponse> getJobs(@ApiParam(hidden = true) @RequestParam
if (allRequestParams.containsKey("dueAfter")) {
query.duedateHigherThan(RequestUtil.getDate(allRequestParams, "dueAfter"));
}
if (allRequestParams.containsKey("withException") && Boolean.valueOf(allRequestParams.get("withException"))) {
if (allRequestParams.containsKey("withException") && Boolean.parseBoolean(allRequestParams.get("withException"))) {
query.withException();
}
if (allRequestParams.containsKey("exceptionMessage")) {
Expand All @@ -162,19 +162,19 @@ public DataResponse<JobResponse> getJobs(@ApiParam(hidden = true) @RequestParam
if (allRequestParams.containsKey("tenantIdLike")) {
query.jobTenantIdLike(allRequestParams.get("tenantIdLike"));
}
if (allRequestParams.containsKey("withoutTenantId") && Boolean.valueOf(allRequestParams.get("withoutTenantId"))) {
if (allRequestParams.containsKey("withoutTenantId") && Boolean.parseBoolean(allRequestParams.get("withoutTenantId"))) {
query.jobWithoutTenantId();
}
if (allRequestParams.containsKey("locked") && Boolean.valueOf(allRequestParams.get("locked"))) {
if (allRequestParams.containsKey("locked") && Boolean.parseBoolean(allRequestParams.get("locked"))) {
query.locked();
}
if (allRequestParams.containsKey("unlocked") && Boolean.valueOf(allRequestParams.get("unlocked"))) {
if (allRequestParams.containsKey("unlocked") && Boolean.parseBoolean(allRequestParams.get("unlocked"))) {
query.unlocked();
}
if (allRequestParams.containsKey("scopeType")) {
query.scopeType(allRequestParams.get("scopeType"));
}
if (allRequestParams.containsKey("withoutProcessInstanceId") && Boolean.valueOf(allRequestParams.get("withoutProcessInstanceId"))) {
if (allRequestParams.containsKey("withoutProcessInstanceId") && Boolean.parseBoolean(allRequestParams.get("withoutProcessInstanceId"))) {
query.withoutProcessInstanceId();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public DataResponse<JobResponse> getJobs(@ApiParam(hidden = true) @RequestParam
query.scopeId(allRequestParams.get("caseInstanceId"));
query.scopeType(ScopeTypes.CMMN);
}
if (allRequestParams.containsKey("withoutScopeId") && Boolean.valueOf(allRequestParams.get("withoutScopeId"))) {
if (allRequestParams.containsKey("withoutScopeId") && Boolean.parseBoolean(allRequestParams.get("withoutScopeId"))) {
query.withoutScopeId();
}
if (allRequestParams.containsKey("planItemInstanceId")) {
Expand All @@ -123,11 +123,11 @@ public DataResponse<JobResponse> getJobs(@ApiParam(hidden = true) @RequestParam
if (allRequestParams.containsKey("messagesOnly")) {
throw new FlowableIllegalArgumentException("Only one of 'timersOnly' or 'messagesOnly' can be provided.");
}
if (Boolean.valueOf(allRequestParams.get("timersOnly"))) {
if (Boolean.parseBoolean(allRequestParams.get("timersOnly"))) {
query.timers();
}
}
if (allRequestParams.containsKey("messagesOnly") && Boolean.valueOf(allRequestParams.get("messagesOnly"))) {
if (allRequestParams.containsKey("messagesOnly") && Boolean.parseBoolean(allRequestParams.get("messagesOnly"))) {
query.messages();
}
if (allRequestParams.containsKey("dueBefore")) {
Expand All @@ -136,13 +136,13 @@ public DataResponse<JobResponse> getJobs(@ApiParam(hidden = true) @RequestParam
if (allRequestParams.containsKey("dueAfter")) {
query.duedateHigherThan(RequestUtil.getDate(allRequestParams, "dueAfter"));
}
if (allRequestParams.containsKey("withException") && Boolean.valueOf(allRequestParams.get("withException"))) {
if (allRequestParams.containsKey("withException") && Boolean.parseBoolean(allRequestParams.get("withException"))) {
query.withException();
}
if (allRequestParams.containsKey("withRetriesLeft") && Boolean.valueOf(allRequestParams.get("withRetriesLeft"))) {
if (allRequestParams.containsKey("withRetriesLeft") && Boolean.parseBoolean(allRequestParams.get("withRetriesLeft"))) {
query.withRetriesLeft();
}
if (allRequestParams.containsKey("noRetriesLeft") && Boolean.valueOf(allRequestParams.get("noRetriesLeft"))) {
if (allRequestParams.containsKey("noRetriesLeft") && Boolean.parseBoolean(allRequestParams.get("noRetriesLeft"))) {
query.noRetriesLeft();
}
if (allRequestParams.containsKey("exceptionMessage")) {
Expand All @@ -154,13 +154,13 @@ public DataResponse<JobResponse> getJobs(@ApiParam(hidden = true) @RequestParam
if (allRequestParams.containsKey("tenantIdLike")) {
query.jobTenantIdLike(allRequestParams.get("tenantIdLike"));
}
if (allRequestParams.containsKey("withoutTenantId") && Boolean.valueOf(allRequestParams.get("withoutTenantId"))) {
if (allRequestParams.containsKey("withoutTenantId") && Boolean.parseBoolean(allRequestParams.get("withoutTenantId"))) {
query.jobWithoutTenantId();
}
if (allRequestParams.containsKey("scopeType")) {
query.scopeType(allRequestParams.get("scopeType"));
}
if (allRequestParams.containsKey("withoutProcessInstanceId") && Boolean.valueOf(allRequestParams.get("withoutProcessInstanceId"))) {
if (allRequestParams.containsKey("withoutProcessInstanceId") && Boolean.parseBoolean(allRequestParams.get("withoutProcessInstanceId"))) {
query.withoutProcessInstanceId();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public DataResponse<JobResponse> getJobs(@ApiParam(hidden = true) @RequestParam
query.scopeId(allRequestParams.get("caseInstanceId"));
query.scopeType(ScopeTypes.CMMN);
}
if (allRequestParams.containsKey("withoutScopeId") && Boolean.valueOf(allRequestParams.get("withoutScopeId"))) {
if (allRequestParams.containsKey("withoutScopeId") && Boolean.parseBoolean(allRequestParams.get("withoutScopeId"))) {
query.withoutScopeId();
}
if (allRequestParams.containsKey("planItemInstanceId")) {
Expand All @@ -123,11 +123,11 @@ public DataResponse<JobResponse> getJobs(@ApiParam(hidden = true) @RequestParam
if (allRequestParams.containsKey("messagesOnly")) {
throw new FlowableIllegalArgumentException("Only one of 'timersOnly' or 'messagesOnly' can be provided.");
}
if (Boolean.valueOf(allRequestParams.get("timersOnly"))) {
if (Boolean.parseBoolean(allRequestParams.get("timersOnly"))) {
query.timers();
}
}
if (allRequestParams.containsKey("messagesOnly") && Boolean.valueOf(allRequestParams.get("messagesOnly"))) {
if (allRequestParams.containsKey("messagesOnly") && Boolean.parseBoolean(allRequestParams.get("messagesOnly"))) {
query.messages();
}
if (allRequestParams.containsKey("dueBefore")) {
Expand All @@ -136,7 +136,7 @@ public DataResponse<JobResponse> getJobs(@ApiParam(hidden = true) @RequestParam
if (allRequestParams.containsKey("dueAfter")) {
query.duedateHigherThan(RequestUtil.getDate(allRequestParams, "dueAfter"));
}
if (allRequestParams.containsKey("withException") && Boolean.valueOf(allRequestParams.get("withException"))) {
if (allRequestParams.containsKey("withException") && Boolean.parseBoolean(allRequestParams.get("withException"))) {
query.withException();
}
if (allRequestParams.containsKey("exceptionMessage")) {
Expand All @@ -148,13 +148,13 @@ public DataResponse<JobResponse> getJobs(@ApiParam(hidden = true) @RequestParam
if (allRequestParams.containsKey("tenantIdLike")) {
query.jobTenantIdLike(allRequestParams.get("tenantIdLike"));
}
if (allRequestParams.containsKey("withoutTenantId") && Boolean.valueOf(allRequestParams.get("withoutTenantId"))) {
if (allRequestParams.containsKey("withoutTenantId") && Boolean.parseBoolean(allRequestParams.get("withoutTenantId"))) {
query.jobWithoutTenantId();
}
if (allRequestParams.containsKey("scopeType")) {
query.scopeType(allRequestParams.get("scopeType"));
}
if (allRequestParams.containsKey("withoutProcessInstanceId") && Boolean.valueOf(allRequestParams.get("withoutProcessInstanceId"))) {
if (allRequestParams.containsKey("withoutProcessInstanceId") && Boolean.parseBoolean(allRequestParams.get("withoutProcessInstanceId"))) {
query.withoutProcessInstanceId();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ public DataResponse<CaseDefinitionResponse> getProcessDefinitions(@ApiParam(hidd
caseDefinitionQuery.caseDefinitionVersion(Integer.valueOf(allRequestParams.get("version")));
}
if (allRequestParams.containsKey("latest")) {
Boolean latest = Boolean.valueOf(allRequestParams.get("latest"));
if (latest != null && latest) {
if (Boolean.parseBoolean(allRequestParams.get("latest"))) {
caseDefinitionQuery.latestVersion();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public DataResponse<CaseInstanceResponse> getCaseInstances(@ApiParam(hidden = tr
}

if (allRequestParams.containsKey("withoutTenantId")) {
if (Boolean.valueOf(allRequestParams.get("withoutTenantId"))) {
if (Boolean.parseBoolean(allRequestParams.get("withoutTenantId"))) {
queryRequest.setWithoutTenantId(Boolean.TRUE);
}
}
Expand Down Expand Up @@ -297,7 +297,7 @@ public CaseInstanceResponse createCaseInstance(@RequestBody CaseInstanceCreateRe
if (request.isTenantSet()) {
caseInstanceBuilder.tenantId(request.getTenantId());
}
if (request.getOverrideDefinitionTenantId() != null && request.getOverrideDefinitionTenantId().length() > 0) {
if (request.getOverrideDefinitionTenantId() != null && !request.getOverrideDefinitionTenantId().isEmpty()) {
caseInstanceBuilder.overrideCaseDefinitionTenantId(request.getOverrideDefinitionTenantId());
}
if (startVariables != null) {
Expand Down
Loading

0 comments on commit 11696a3

Please sign in to comment.