From 2b4f7477f01d159aa593c93caaae855f35df9da2 Mon Sep 17 00:00:00 2001 From: David Mackessy Date: Fri, 25 Oct 2024 15:11:36 +0100 Subject: [PATCH] chore: Avoid comparing potential nulls --- .../org/hisp/dhis/common/QueryOperator.java | 2 +- .../hisp/dhis/datastore/DatastoreQuery.java | 4 +-- .../dhis/interpretation/MentionUtils.java | 2 +- .../dhis/scheduling/JobConfiguration.java | 2 +- .../analytics/common/ValueTypeMapping.java | 2 +- .../dhis/appmanager/DefaultAppManager.java | 2 +- .../hibernate/HibernateDataApprovalStore.java | 2 +- .../java/org/hisp/dhis/gist/GistPlanner.java | 4 +-- .../dhis/query/JpaCriteriaQueryEngine.java | 2 +- .../DefaultJobConfigurationService.java | 2 +- .../ImpersonatingUserDetailsChecker.java | 2 +- .../oidc/OIDCLoginEnabledCondition.java | 2 +- .../sms/listener/DataValueSMSListener.java | 4 +-- .../org/hisp/dhis/dxf2/common/Options.java | 2 +- .../ExpressionDimensionItemService.java | 2 +- .../dxf2/pdfform/PdfDataEntryFormUtil.java | 4 +-- .../fieldfiltering/FieldFilterParser.java | 6 ++-- .../fieldfiltering/FieldFilterService.java | 2 +- .../DefaultFieldFilterService.java | 2 +- .../dhis/fieldfilter/DefaultFieldParser.java | 34 +++++++++---------- .../org/hisp/dhis/fieldfilter/Defaults.java | 2 +- .../preheat/ReferenceTrackerEntity.java | 2 +- ...figuration_job_type_column_to_varchar.java | 2 +- ...binary_columns_into_varchar_data_type.java | 4 +-- ...ing_value_column_from_bytea_to_string.java | 2 +- .../hisp/dhis/config/DataSourceConfig.java | 6 ++-- .../org/hisp/dhis/config/HibernateConfig.java | 2 +- .../org/hisp/dhis/datasource/StubDriver.java | 2 +- .../org/hisp/dhis/system/util/MathUtils.java | 2 +- .../org/hisp/dhis/http/HttpClientAdapter.java | 4 +-- .../test/utils/Dxf2NamespaceResolver.java | 2 +- .../e2e/actions/metadata/ProgramActions.java | 2 +- .../tracker/PotentialDuplicatesActions.java | 4 +-- .../hisp/dhis/test/e2e/dto/ApiResponse.java | 2 +- .../dhis/test/e2e/utils/DataGenerator.java | 6 ++-- .../extensions/CoverageLoggerExtension.java | 2 +- .../hisp/dhis/helpers/file/CsvFileReader.java | 2 +- .../dhis/helpers/file/JsonFileReader.java | 4 +-- .../hisp/dhis/helpers/file/XmlFileReader.java | 2 +- .../hisp/dhis/helpers/matchers/Sorted.java | 2 +- .../tracker/export/TrackerExportTest.java | 2 +- .../EventsDataValueValidationTests.java | 2 +- .../dhis/dxf2/csv/CsvImportServiceTest.java | 6 ++-- .../metadata/MetadataImportServiceTest.java | 13 ++++--- .../SMSCommandObjectBundleServiceTest.java | 4 +-- .../maintenance/MaintenanceServiceTest.java | 6 ++-- .../hisp/dhis/message/MessageServiceTest.java | 2 +- .../dhis/query/CriteriaQueryEngineTest.java | 4 +-- .../tracker/imports/bundle/OwnershipTest.java | 6 ++-- .../ProgramRuleAssignActionTest.java | 4 +-- .../controller/DashboardControllerTest.java | 6 ++-- .../DataSetMetadataControllerTest.java | 2 +- .../JobConfigurationControllerTest.java | 4 +-- .../AbstractFullReadOnlyController.java | 2 +- .../webapi/controller/AccountController.java | 2 +- .../webapi/controller/user/MeController.java | 2 +- .../org/hisp/dhis/webapi/openapi/Api.java | 4 +-- .../dhis/webapi/openapi/ApiExtractor.java | 2 +- .../dhis/webapi/openapi/OpenApiObject.java | 4 +-- .../webapi/security/ExternalAccessVoter.java | 2 +- .../servlet/DhisWebApiWebAppInitializer.java | 2 +- .../webapi/utils/HttpServletRequestPaths.java | 4 +-- dhis-2/pom.xml | 17 ++++++++++ 63 files changed, 129 insertions(+), 113 deletions(-) diff --git a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryOperator.java b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryOperator.java index cb3cffef7b48..eb7c1cf8e77f 100644 --- a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryOperator.java +++ b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryOperator.java @@ -85,7 +85,7 @@ public static QueryOperator fromString(String string) { } // To still support NE operator until it gets removed - if (string.trim().equals("NE")) { + if ("NE".equals(string.trim())) { return NEQ; } diff --git a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/datastore/DatastoreQuery.java b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/datastore/DatastoreQuery.java index 35df52723e0c..40c4cbb71adc 100644 --- a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/datastore/DatastoreQuery.java +++ b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/datastore/DatastoreQuery.java @@ -117,11 +117,11 @@ public interface HasPath { String getPath(); default boolean isKeyPath() { - return getPath().equals("_"); + return "_".equals(getPath()); } default boolean isValuePath() { - return getPath().equals("."); + return ".".equals(getPath()); } } diff --git a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/MentionUtils.java b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/MentionUtils.java index 42110e111df4..2dd79235855a 100644 --- a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/MentionUtils.java +++ b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/MentionUtils.java @@ -68,7 +68,7 @@ public static List removeCustomFilters(List filters) { ListIterator filterIterator = filters.listIterator(); while (filterIterator.hasNext()) { String[] filterSplit = filterIterator.next().split(":"); - if (filterSplit[1].equals("in") && filterSplit[0].equals("mentions")) { + if ("in".equals(filterSplit[1]) && "mentions".equals(filterSplit[0])) { mentions.add(filterSplit[2]); filterIterator.remove(); } diff --git a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/JobConfiguration.java b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/JobConfiguration.java index 4db73584d7c5..99f7d1b89bc5 100644 --- a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/JobConfiguration.java +++ b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/JobConfiguration.java @@ -451,6 +451,6 @@ public static Instant maxDelayedExecutionTime( private static boolean isUndefinedCronExpression(String cronExpression) { return cronExpression == null || cronExpression.isEmpty() - || cronExpression.equals("* * * * * ?"); + || "* * * * * ?".equals(cronExpression); } } diff --git a/dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/common/ValueTypeMapping.java b/dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/common/ValueTypeMapping.java index bac5c446b1f2..e762f55e131a 100644 --- a/dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/common/ValueTypeMapping.java +++ b/dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/common/ValueTypeMapping.java @@ -63,7 +63,7 @@ public enum ValueTypeMapping { ValueTypeMapping::booleanConverter, ValueTypeMapping::booleanJsonExtractor, Boolean.class); private static final UnaryOperator BOOLEAN_JSON_EXTRACTOR = - value -> value.equalsIgnoreCase("true") ? "1" : "0"; + value -> "true".equalsIgnoreCase(value) ? "1" : "0"; private final Function converter; @Getter private final UnaryOperator selectTransformer; diff --git a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManager.java b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManager.java index bb56988149e0..1835cf632200 100644 --- a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManager.java +++ b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManager.java @@ -393,7 +393,7 @@ private void installApp(App app) { @Override public boolean isAccessible(App app) { - return app.getKey().equals("login") + return "login".equals(app.getKey()) || CurrentUserUtil.hasAnyAuthority( List.of( Authorities.ALL.toString(), diff --git a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java index bd62c36314ca..8e02048e3c53 100644 --- a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java +++ b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java @@ -755,7 +755,7 @@ public List getDataApprovalStatuses( final String[] approved = highestApproved == null ? null : highestApproved.split(SQL_CONCAT); final int level = approved == null ? 0 : Integer.parseInt(approved[0]) - MAX_APPROVAL_LEVEL; final boolean accepted = - approved == null ? false : approved[1].substring(0, 1).equalsIgnoreCase("t"); + approved == null ? false : "t".equalsIgnoreCase(approved[1].substring(0, 1)); final long approvedOrgUnitId = approved == null ? 0 : Long.parseLong(approved[2]); // null if not approved diff --git a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/gist/GistPlanner.java b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/gist/GistPlanner.java index 7405b51759d2..430c8d226313 100644 --- a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/gist/GistPlanner.java +++ b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/gist/GistPlanner.java @@ -403,11 +403,11 @@ private static boolean isAllField(String path) { } private boolean isDisplayShortName(String path) { - return path.equals("displayShortName") || path.endsWith(".displayShortName"); + return "displayShortName".equals(path) || path.endsWith(".displayShortName"); } private boolean isDisplayNameField(String path) { - return path.equals("displayName") || path.endsWith(".displayName"); + return "displayName".equals(path) || path.endsWith(".displayName"); } private static List map1to1(List from, Predicate when, UnaryOperator then) { diff --git a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/JpaCriteriaQueryEngine.java b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/JpaCriteriaQueryEngine.java index caf8dea42adb..12bac86bb6fa 100644 --- a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/JpaCriteriaQueryEngine.java +++ b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/JpaCriteriaQueryEngine.java @@ -143,7 +143,7 @@ public List query(Query query) { ? CurrentUserUtil.getCurrentUsername() : "system-process"; - if (!username.equals("system-process") && shareable && !query.isSkipSharing()) { + if (!"system-process".equals(username) && shareable && !query.isSkipSharing()) { UserDetails userDetails = query.getCurrentUserDetails() != null diff --git a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/scheduling/DefaultJobConfigurationService.java b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/scheduling/DefaultJobConfigurationService.java index b3af654bb06b..18aada84ef9a 100644 --- a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/scheduling/DefaultJobConfigurationService.java +++ b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/scheduling/DefaultJobConfigurationService.java @@ -449,7 +449,7 @@ private static Property getProperty( ? jobType.getRelativeApiElements().get(field.getName()) : ""; - if (relativeApiElements != null && !relativeApiElements.equals("")) { + if (relativeApiElements != null && !"".equals(relativeApiElements)) { property.setRelativeApiEndpoint(relativeApiElements); } diff --git a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/ImpersonatingUserDetailsChecker.java b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/ImpersonatingUserDetailsChecker.java index 35cc6cd77441..39379ab8b241 100644 --- a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/ImpersonatingUserDetailsChecker.java +++ b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/ImpersonatingUserDetailsChecker.java @@ -48,7 +48,7 @@ public void check(org.springframework.security.core.userdetails.UserDetails user boolean userToImpersonateIsSuper = userToImpersonate.getAuthorities().stream() - .anyMatch(grantedAuthority -> grantedAuthority.getAuthority().equals("ALL")); + .anyMatch(grantedAuthority -> "ALL".equals(grantedAuthority.getAuthority())); if ((!currentUser.isSuper() && userToImpersonateIsSuper)) { throw new InsufficientAuthenticationException( diff --git a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/oidc/OIDCLoginEnabledCondition.java b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/oidc/OIDCLoginEnabledCondition.java index d1402215f474..d21485518cc3 100644 --- a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/oidc/OIDCLoginEnabledCondition.java +++ b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/oidc/OIDCLoginEnabledCondition.java @@ -42,7 +42,7 @@ public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) return false; } String isEnabled = getConfiguration().getProperty(ConfigurationKey.OIDC_OAUTH2_LOGIN_ENABLED); - return isEnabled.equalsIgnoreCase("on"); + return "on".equalsIgnoreCase(isEnabled); } @Override diff --git a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/listener/DataValueSMSListener.java b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/listener/DataValueSMSListener.java index 1e773553e656..a50219891bbb 100644 --- a/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/listener/DataValueSMSListener.java +++ b/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/listener/DataValueSMSListener.java @@ -333,9 +333,9 @@ private boolean storeDataValue( targetValue = Integer.parseInt(targetDataValue.getValue()); } - if (operation.equals("+")) { + if ("+".equals(operation)) { targetValue = targetValue + Integer.parseInt(value); - } else if (operation.equals("-")) { + } else if ("-".equals(operation)) { targetValue = targetValue - Integer.parseInt(value); } diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/Options.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/Options.java index 3045a4df4041..d65d935657ce 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/Options.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/Options.java @@ -51,7 +51,7 @@ public class Options { public Options(Map options) { this.options = options; this.assumeTrue = - options.get("assumeTrue") == null || options.get("assumeTrue").equalsIgnoreCase("true"); + options.get("assumeTrue") == null || "true".equalsIgnoreCase(options.get("assumeTrue")); } public Options() {} diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/expressiondimensionitem/ExpressionDimensionItemService.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/expressiondimensionitem/ExpressionDimensionItemService.java index 08f659cef758..95ceffc385f6 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/expressiondimensionitem/ExpressionDimensionItemService.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/expressiondimensionitem/ExpressionDimensionItemService.java @@ -106,7 +106,7 @@ public List getExpressionItems(DataDimensionItem data * @return true when the expression is valid */ public boolean isValidExpressionItems(String expression) { - if (trimToNull(expression) == null || trimToEmpty(expression).equalsIgnoreCase("null")) { + if (trimToNull(expression) == null || "null".equalsIgnoreCase(trimToEmpty(expression))) { return false; } diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/PdfDataEntryFormUtil.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/PdfDataEntryFormUtil.java index a510cf1312da..4faca9222cf7 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/PdfDataEntryFormUtil.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/PdfDataEntryFormUtil.java @@ -253,9 +253,9 @@ private static String fieldValueFormat(String[] strArrFldName, String fldValue) int fieldType = Integer.parseInt(strArrFldName[3].substring(1)); if (fieldType == PdfFieldCell.TYPE_CHECKBOX) { - if (fldValue.compareTo("On") == 0) { + if ("On".compareTo(fldValue) == 0) { fldValue = "true"; - } else if (fldValue.compareTo("Off") == 0) { + } else if ("Off".compareTo(fldValue) == 0) { fldValue = null; } } diff --git a/dhis-2/dhis-services/dhis-service-field-filtering/src/main/java/org/hisp/dhis/fieldfiltering/FieldFilterParser.java b/dhis-2/dhis-services/dhis-service-field-filtering/src/main/java/org/hisp/dhis/fieldfiltering/FieldFilterParser.java index d2127191fe34..09c2ab5bd752 100644 --- a/dhis-2/dhis-services/dhis-service-field-filtering/src/main/java/org/hisp/dhis/fieldfiltering/FieldFilterParser.java +++ b/dhis-2/dhis-services/dhis-service-field-filtering/src/main/java/org/hisp/dhis/fieldfiltering/FieldFilterParser.java @@ -87,7 +87,7 @@ private static List expandField(String field, String prefix) { token = fieldSplit[idx]; if ((containsAny(token, ":", "~", "|"))) { - if (token.equals(":")) { + if (":".equals(token)) { idx++; } @@ -120,8 +120,8 @@ private static List expandField(String field, String prefix) { transformerParameters.add(transformerNameBuilder.toString()); break; } else if (isFieldSeparator(token) - || (token.equals("]") && !insideParameters) - || (token.equals("[") && !insideParameters)) { + || ("]".equals(token) && !insideParameters) + || ("[".equals(token) && !insideParameters)) { idx--; break; } diff --git a/dhis-2/dhis-services/dhis-service-field-filtering/src/main/java/org/hisp/dhis/fieldfiltering/FieldFilterService.java b/dhis-2/dhis-services/dhis-service-field-filtering/src/main/java/org/hisp/dhis/fieldfiltering/FieldFilterService.java index 3c370c37a859..ace4710835b7 100644 --- a/dhis-2/dhis-services/dhis-service-field-filtering/src/main/java/org/hisp/dhis/fieldfiltering/FieldFilterService.java +++ b/dhis-2/dhis-services/dhis-service-field-filtering/src/main/java/org/hisp/dhis/fieldfiltering/FieldFilterService.java @@ -583,7 +583,7 @@ private void applyAccess( object, fieldPaths, isSkipSharing, - s -> s.equals("access") || s.endsWith(".access"), + s -> "access".equals(s) || s.endsWith(".access"), o -> { if (o instanceof IdentifiableObject identifiableObject) { identifiableObject.setAccess(aclService.getAccess(identifiableObject, userDetails)); diff --git a/dhis-2/dhis-services/dhis-service-node/src/main/java/org/hisp/dhis/fieldfilter/DefaultFieldFilterService.java b/dhis-2/dhis-services/dhis-service-node/src/main/java/org/hisp/dhis/fieldfilter/DefaultFieldFilterService.java index d4f342f764bc..7c669b992cdd 100644 --- a/dhis-2/dhis-services/dhis-service-node/src/main/java/org/hisp/dhis/fieldfilter/DefaultFieldFilterService.java +++ b/dhis-2/dhis-services/dhis-service-node/src/main/java/org/hisp/dhis/fieldfilter/DefaultFieldFilterService.java @@ -703,7 +703,7 @@ private ComplexNode getProperties(Property currentProperty, Object object, List< private boolean isBaseIdentifiableObjectIdOnly( @Nonnull Object object, @Nonnull List fields) { return fields.size() == 1 - && fields.get(0).equals("id") + && "id".equals(fields.get(0)) && object instanceof BaseIdentifiableObject; } diff --git a/dhis-2/dhis-services/dhis-service-node/src/main/java/org/hisp/dhis/fieldfilter/DefaultFieldParser.java b/dhis-2/dhis-services/dhis-service-node/src/main/java/org/hisp/dhis/fieldfilter/DefaultFieldParser.java index 5b496eb41535..d64dabf52fe7 100644 --- a/dhis-2/dhis-services/dhis-service-node/src/main/java/org/hisp/dhis/fieldfilter/DefaultFieldParser.java +++ b/dhis-2/dhis-services/dhis-service-node/src/main/java/org/hisp/dhis/fieldfilter/DefaultFieldParser.java @@ -54,28 +54,28 @@ public FieldMap parse(String fields) { // if we reach a field transformer, parse it out here (necessary to // allow for () to be used to handle transformer parameters) - if ((c.equals(":") && fieldSplit[i + 1].equals(":")) || c.equals("~") || c.equals("|")) { + if ((":".equals(c) && ":".equals(fieldSplit[i + 1])) || "~".equals(c) || "|".equals(c)) { boolean insideParameters = false; for (; i < fieldSplit.length; i++) { c = fieldSplit[i]; - if (StringUtils.isAlphanumeric(c) || c.equals(":") || c.equals("~") || c.equals("|")) { + if (StringUtils.isAlphanumeric(c) || ":".equals(c) || "~".equals(c) || "|".equals(c)) { builder.append(c); - } else if (c.equals("(")) // start parameter + } else if ("(".equals(c)) // start parameter { insideParameters = true; builder.append(c); - } else if (insideParameters && c.equals(";")) // allow + } else if (insideParameters && ";".equals(c)) // allow // parameter // separator { builder.append(c); - } else if ((insideParameters && c.equals(")"))) // end + } else if ((insideParameters && ")".equals(c))) // end { builder.append(c); break; - } else if (c.equals(",") || (c.equals("[") && !insideParameters)) // rewind + } else if (",".equals(c) || ("[".equals(c) && !insideParameters)) // rewind // and // break { @@ -83,13 +83,13 @@ public FieldMap parse(String fields) { break; } } - } else if (c.equals(",")) { + } else if (",".equals(c)) { putInMap(fieldMap, joinedWithPrefix(builder, prefixList)); builder = new StringBuilder(); - } else if (c.equals("[") || c.equals("(")) { + } else if ("[".equals(c) || "(".equals(c)) { prefixList.add(builder.toString()); builder = new StringBuilder(); - } else if (c.equals("]") || c.equals(")")) { + } else if ("]".equals(c) || ")".equals(c)) { if (!builder.toString().isEmpty()) { putInMap(fieldMap, joinedWithPrefix(builder, prefixList)); } @@ -97,14 +97,14 @@ public FieldMap parse(String fields) { prefixList.remove(prefixList.size() - 1); builder = new StringBuilder(); } else if (StringUtils.isAlphanumeric(c) - || c.equals("*") - || c.equals(":") - || c.equals(";") - || c.equals("~") - || c.equals("!") - || c.equals("|") - || c.equals("{") - || c.equals("}")) { + || "*".equals(c) + || ":".equals(c) + || ";".equals(c) + || "~".equals(c) + || "!".equals(c) + || "|".equals(c) + || "{".equals(c) + || "}".equals(c)) { builder.append(c); } } diff --git a/dhis-2/dhis-services/dhis-service-node/src/main/java/org/hisp/dhis/fieldfilter/Defaults.java b/dhis-2/dhis-services/dhis-service-node/src/main/java/org/hisp/dhis/fieldfilter/Defaults.java index dd873185172e..0939846c9682 100644 --- a/dhis-2/dhis-services/dhis-service-node/src/main/java/org/hisp/dhis/fieldfilter/Defaults.java +++ b/dhis-2/dhis-services/dhis-service-node/src/main/java/org/hisp/dhis/fieldfilter/Defaults.java @@ -41,6 +41,6 @@ public enum Defaults { EXCLUDE; public boolean isExclude() { - return this.name().equals("EXCLUDE"); + return "EXCLUDE".equals(this.name()); } } diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/preheat/ReferenceTrackerEntity.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/preheat/ReferenceTrackerEntity.java index cb18b6c9e12a..eae8c7d90c91 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/preheat/ReferenceTrackerEntity.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/preheat/ReferenceTrackerEntity.java @@ -45,6 +45,6 @@ public class ReferenceTrackerEntity { private final String parentUid; public boolean isRoot() { - return this.parentUid.equals("ROOT"); + return "ROOT".equals(this.parentUid); } } diff --git a/dhis-2/dhis-support/dhis-support-db-migration/src/main/java/org/hisp/dhis/db/migration/v33/V2_33_1__Job_configuration_job_type_column_to_varchar.java b/dhis-2/dhis-support/dhis-support-db-migration/src/main/java/org/hisp/dhis/db/migration/v33/V2_33_1__Job_configuration_job_type_column_to_varchar.java index ab3cb2dc7ab4..c2afd3f397c3 100644 --- a/dhis-2/dhis-support/dhis-support-db-migration/src/main/java/org/hisp/dhis/db/migration/v33/V2_33_1__Job_configuration_job_type_column_to_varchar.java +++ b/dhis-2/dhis-support/dhis-support-db-migration/src/main/java/org/hisp/dhis/db/migration/v33/V2_33_1__Job_configuration_job_type_column_to_varchar.java @@ -59,7 +59,7 @@ public void migrate(final Context context) throws Exception { + "WHERE table_name = 'jobconfiguration' AND column_name = 'jobtype';"; try (Statement stmt = context.getConnection().createStatement(); ResultSet rs = stmt.executeQuery(sql); ) { - if (rs.next() && rs.getString("data_type").equals("bytea")) { + if (rs.next() && "bytea".equals(rs.getString("data_type"))) { continueWithMigration = true; } } diff --git a/dhis-2/dhis-support/dhis-support-db-migration/src/main/java/org/hisp/dhis/db/migration/v34/V2_34_5__Convert_job_configuration_binary_columns_into_varchar_data_type.java b/dhis-2/dhis-support/dhis-support-db-migration/src/main/java/org/hisp/dhis/db/migration/v34/V2_34_5__Convert_job_configuration_binary_columns_into_varchar_data_type.java index 1e267b20c276..ea86203e6f78 100644 --- a/dhis-2/dhis-support/dhis-support-db-migration/src/main/java/org/hisp/dhis/db/migration/v34/V2_34_5__Convert_job_configuration_binary_columns_into_varchar_data_type.java +++ b/dhis-2/dhis-support/dhis-support-db-migration/src/main/java/org/hisp/dhis/db/migration/v34/V2_34_5__Convert_job_configuration_binary_columns_into_varchar_data_type.java @@ -71,7 +71,7 @@ private void migrateJobStatusColumn(final Context context) throws Exception { boolean continueWithMigration = false; try (Statement stmt = context.getConnection().createStatement(); ResultSet rs = stmt.executeQuery(CHECK_JOB_STATUS_DATA_TYPE_SQL); ) { - if (rs.next() && rs.getString("data_type").equals("bytea")) { + if (rs.next() && "bytea".equals(rs.getString("data_type"))) { continueWithMigration = true; } } @@ -142,7 +142,7 @@ private void migrateLastExecutedStatusColumn(final Context context) throws Excep boolean continueWithMigration = false; try (Statement stmt = context.getConnection().createStatement(); ResultSet rs = stmt.executeQuery(CHECK_LAST_EXECUTED_STATUS_DATA_TYPE_SQL); ) { - if (rs.next() && rs.getString("data_type").equals("bytea")) { + if (rs.next() && "bytea".equals(rs.getString("data_type"))) { continueWithMigration = true; } } diff --git a/dhis-2/dhis-support/dhis-support-db-migration/src/main/java/org/hisp/dhis/db/migration/v34/V2_34_6__Convert_systemsetting_value_column_from_bytea_to_string.java b/dhis-2/dhis-support/dhis-support-db-migration/src/main/java/org/hisp/dhis/db/migration/v34/V2_34_6__Convert_systemsetting_value_column_from_bytea_to_string.java index ddeabded497c..c7d66cea3710 100644 --- a/dhis-2/dhis-support/dhis-support-db-migration/src/main/java/org/hisp/dhis/db/migration/v34/V2_34_6__Convert_systemsetting_value_column_from_bytea_to_string.java +++ b/dhis-2/dhis-support/dhis-support-db-migration/src/main/java/org/hisp/dhis/db/migration/v34/V2_34_6__Convert_systemsetting_value_column_from_bytea_to_string.java @@ -83,7 +83,7 @@ public void migrate(final Context context) throws Exception { boolean continueWithMigration = false; try (Statement stmt = context.getConnection().createStatement(); ResultSet rs = stmt.executeQuery(CHECK_SYSTEM_SETTING_VALUE_TYPE_SQL); ) { - if (rs.next() && rs.getString("data_type").equals("bytea")) { + if (rs.next() && "bytea".equals(rs.getString("data_type"))) { continueWithMigration = true; } } diff --git a/dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/config/DataSourceConfig.java b/dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/config/DataSourceConfig.java index a92661c2cd04..42298d540655 100644 --- a/dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/config/DataSourceConfig.java +++ b/dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/config/DataSourceConfig.java @@ -178,12 +178,12 @@ private static void executeAfterMethod(MethodExecutionContext executionContext) String packageName = className.substring(0, pos); if (className.contains("org.hisp.dhis.cacheinvalidation.KnownTransactionsService") - || methodName.equals("getSingleResult") - || methodName.equals("doFilterInternal")) { + || "getSingleResult".equals(methodName) + || "doFilterInternal".equals(methodName)) { break; } - if (packageName.startsWith("org.hisp.dhis") && !methodName.equals("executeAfterMethod")) { + if (packageName.startsWith("org.hisp.dhis") && !"executeAfterMethod".equals(methodName)) { StackTraceElement nextElement = stackTrace[i - 1]; String methodName1 = nextElement.getMethodName(); String className1 = nextElement.getClassName(); diff --git a/dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/config/HibernateConfig.java b/dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/config/HibernateConfig.java index c26fb5e58ef9..507f41157d7a 100644 --- a/dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/config/HibernateConfig.java +++ b/dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/config/HibernateConfig.java @@ -170,7 +170,7 @@ private Properties getAdditionalProperties(DhisConfigurationProvider dhisConfig) "hibernate.current_session_context_class", "org.springframework.orm.hibernate5.SpringSessionContext"); - if (dhisConfig.getProperty(USE_SECOND_LEVEL_CACHE).equals("true")) { + if ("true".equals(dhisConfig.getProperty(USE_SECOND_LEVEL_CACHE))) { properties.put(AvailableSettings.USE_SECOND_LEVEL_CACHE, "true"); properties.put(AvailableSettings.CACHE_REGION_FACTORY, JCacheRegionFactory.class.getName()); properties.put(AvailableSettings.USE_QUERY_CACHE, dhisConfig.getProperty(USE_QUERY_CACHE)); diff --git a/dhis-2/dhis-support/dhis-support-hibernate/src/test/java/org/hisp/dhis/datasource/StubDriver.java b/dhis-2/dhis-support/dhis-support-hibernate/src/test/java/org/hisp/dhis/datasource/StubDriver.java index 6ced10b00618..93f94de173f5 100644 --- a/dhis-2/dhis-support/dhis-support-hibernate/src/test/java/org/hisp/dhis/datasource/StubDriver.java +++ b/dhis-2/dhis-support/dhis-support-hibernate/src/test/java/org/hisp/dhis/datasource/StubDriver.java @@ -50,7 +50,7 @@ public Connection connect(String s, Properties properties) throws SQLException { @Override public boolean acceptsURL(String url) throws SQLException { - return url.equals("jdbc:fake:db"); + return "jdbc:fake:db".equals(url); } @Override diff --git a/dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java b/dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java index e53ba747033f..df8319f7742f 100644 --- a/dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java +++ b/dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java @@ -389,7 +389,7 @@ public static boolean isZero(String value) { * @return if the provided string argument is to be considered as a boolean. */ public static boolean isBool(String value) { - return value != null && (value.equals("true") || value.equals("false")); + return value != null && ("true".equals(value) || "false".equals(value)); } /** diff --git a/dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/http/HttpClientAdapter.java b/dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/http/HttpClientAdapter.java index cedd2c766ff9..1efcd64b20cc 100644 --- a/dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/http/HttpClientAdapter.java +++ b/dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/http/HttpClientAdapter.java @@ -207,7 +207,7 @@ default HttpResponse perform(HttpMethod method, String url, RequestComponent... List
headers = new ArrayList<>(); for (RequestComponent c : components) { if (c instanceof Header header) { - if (header.name().equalsIgnoreCase("ContentType")) { + if ("ContentType".equalsIgnoreCase(header.name())) { // last provided content type wins contentMediaType = header.value().toString(); } else { @@ -277,7 +277,7 @@ public boolean success() { * @return raw content body in UTF-8 encoding */ public String content(String contentType) { - if (contentType.equals("application/json")) { + if ("application/json".equals(contentType)) { fail("Use one of the other content() methods for JSON"); } String actualContentType = header("Content-Type"); diff --git a/dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/test/utils/Dxf2NamespaceResolver.java b/dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/test/utils/Dxf2NamespaceResolver.java index 915d9c72b4f5..572e0aee4719 100644 --- a/dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/test/utils/Dxf2NamespaceResolver.java +++ b/dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/test/utils/Dxf2NamespaceResolver.java @@ -40,7 +40,7 @@ public String getNamespaceURI(String prefix) { if (prefix == null) { throw new IllegalArgumentException("No prefix provided!"); } else { - if (prefix.equals("d")) { + if ("d".equals(prefix)) { return "http://dhis2.org/schema/dxf/2.0"; } else { return XMLConstants.NULL_NS_URI; diff --git a/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/actions/metadata/ProgramActions.java b/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/actions/metadata/ProgramActions.java index 629db710419e..83c94841e466 100644 --- a/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/actions/metadata/ProgramActions.java +++ b/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/actions/metadata/ProgramActions.java @@ -61,7 +61,7 @@ public ProgramActions() { public ApiResponse createProgram(String programType) { JsonObject object = buildProgram(programType); - if (programType.equalsIgnoreCase("WITH_REGISTRATION")) { + if ("WITH_REGISTRATION".equalsIgnoreCase(programType)) { JsonObjectBuilder.jsonObject(object) .addObject("trackedEntityType", new JsonObjectBuilder().addProperty("id", "Q9GufDoplCL")); } diff --git a/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/actions/tracker/PotentialDuplicatesActions.java b/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/actions/tracker/PotentialDuplicatesActions.java index f20c8f79023f..fa417e9c2366 100644 --- a/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/actions/tracker/PotentialDuplicatesActions.java +++ b/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/actions/tracker/PotentialDuplicatesActions.java @@ -50,11 +50,11 @@ public String createAndValidatePotentialDuplicate(String teA, String teB, String String uid = this.post(object).validateStatus(200).extractUid(); - if (status.equals("MERGED")) { + if ("MERGED".equals(status)) { this.autoMergePotentialDuplicate(uid).validateStatus(200); } - if (status.equals("INVALID")) { + if ("INVALID".equals(status)) { this.update(uid + "?status=INVALID", new JsonObjectBuilder().build()).validateStatus(200); } diff --git a/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/dto/ApiResponse.java b/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/dto/ApiResponse.java index 3a0568e0f417..a20d2f69dca8 100644 --- a/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/dto/ApiResponse.java +++ b/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/dto/ApiResponse.java @@ -165,7 +165,7 @@ public List getTypeReports() { public List getSuccessfulImportSummaries() { return getImportSummaries().stream() - .filter(is -> is.getStatus().equalsIgnoreCase("SUCCESS")) + .filter(is -> "SUCCESS".equalsIgnoreCase(is.getStatus())) .collect(Collectors.toList()); } diff --git a/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/utils/DataGenerator.java b/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/utils/DataGenerator.java index 7aa8b1826130..b3837c8ac5cd 100644 --- a/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/utils/DataGenerator.java +++ b/dhis-2/dhis-test-e2e/src/main/java/org/hisp/dhis/test/e2e/utils/DataGenerator.java @@ -79,7 +79,7 @@ public static JsonElement generateRandomValueMatchingSchema(SchemaProperty prope new JsonPrimitive(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").format(date)); } case BOOLEAN -> { - if (property.getName().equalsIgnoreCase("external")) { + if ("external".equalsIgnoreCase(property.getName())) { jsonElement = new JsonPrimitive(true); break; } @@ -180,8 +180,8 @@ private static JsonElement generateConstantValue(SchemaProperty property) { int randomConstant = -1; JsonPrimitive element = null; while (randomConstant == -1 - || (property.getName().equals("valueType") - && property.getConstants().get(randomConstant).equals("MULTI_TEXT"))) { + || ("valueType".equals(property.getName()) + && "MULTI_TEXT".equals(property.getConstants().get(randomConstant)))) { randomConstant = faker.number().numberBetween(0, property.getConstants().size() - 1); element = new JsonPrimitive(property.getConstants().get(randomConstant)); } diff --git a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/helpers/extensions/CoverageLoggerExtension.java b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/helpers/extensions/CoverageLoggerExtension.java index 057b73212acf..410a669a857e 100644 --- a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/helpers/extensions/CoverageLoggerExtension.java +++ b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/helpers/extensions/CoverageLoggerExtension.java @@ -60,7 +60,7 @@ public void close() throws Throwable { EndpointTracker.getCoverageList().stream() .filter( p -> - !p.getMethod().equalsIgnoreCase("DELETE") + !"DELETE".equalsIgnoreCase(p.getMethod()) && !p.getUrl().contains("/tracker//jobs")) .map(this::toCsvRow) .forEach(pw::println); diff --git a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/helpers/file/CsvFileReader.java b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/helpers/file/CsvFileReader.java index 2c0df65925d1..e91efebe56a1 100644 --- a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/helpers/file/CsvFileReader.java +++ b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/helpers/file/CsvFileReader.java @@ -80,7 +80,7 @@ public org.hisp.dhis.helpers.file.FileReader replacePropertyValuesWith( lastColumnReplacedValue = replacedValue; - if (replacedValue.equalsIgnoreCase("uniqueid")) { + if ("uniqueid".equalsIgnoreCase(replacedValue)) { lastColumnReplacedValue = new IdGenerator().generateUniqueId(); } diff --git a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/helpers/file/JsonFileReader.java b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/helpers/file/JsonFileReader.java index cead2e236ae5..0fe40f5d6cd1 100644 --- a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/helpers/file/JsonFileReader.java +++ b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/helpers/file/JsonFileReader.java @@ -83,7 +83,7 @@ public JsonFileReader replacePropertyValuesWith(String propertyName, String repl replace( p -> { JsonObject object = ((JsonElement) p).getAsJsonObject(); - if (replacedValue.equalsIgnoreCase("uniqueid")) { + if ("uniqueid".equalsIgnoreCase(replacedValue)) { object.addProperty(propertyName, new IdGenerator().generateUniqueId()); } else { object.addProperty(propertyName, replacedValue); @@ -104,7 +104,7 @@ public JsonFileReader replacePropertyValuesRecursivelyWith( if (!jsonObject.has(propertyName)) { return; } - if (replacedValue.equalsIgnoreCase("uniqueid")) { + if ("uniqueid".equalsIgnoreCase(replacedValue)) { jsonObject.addProperty(propertyName, new IdGenerator().generateUniqueId()); } else { jsonObject.addProperty(propertyName, replacedValue); diff --git a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/helpers/file/XmlFileReader.java b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/helpers/file/XmlFileReader.java index 5351037cb362..8a55a3c5ee3d 100644 --- a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/helpers/file/XmlFileReader.java +++ b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/helpers/file/XmlFileReader.java @@ -80,7 +80,7 @@ public FileReader replacePropertyValuesWith(String propertyName, String replaced for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i).getAttributes().getNamedItem(propertyName); - if (replacedValue.equalsIgnoreCase("uniqueid")) { + if ("uniqueid".equalsIgnoreCase(replacedValue)) { node.setNodeValue(new IdGenerator().generateUniqueId()); continue; } diff --git a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/helpers/matchers/Sorted.java b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/helpers/matchers/Sorted.java index 3ffdafb94eed..d84a959e2986 100644 --- a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/helpers/matchers/Sorted.java +++ b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/helpers/matchers/Sorted.java @@ -55,7 +55,7 @@ public static TypeSafeDiagnosingMatcher by(String orderType) { } private static boolean isInDescendingOrder(String orderType) { - return orderType.equalsIgnoreCase("desc") || orderType.equalsIgnoreCase("descending"); + return "desc".equalsIgnoreCase(orderType) || "descending".equalsIgnoreCase(orderType); } @Override diff --git a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/tracker/export/TrackerExportTest.java b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/tracker/export/TrackerExportTest.java index 834ce8d0053f..9fa0afb5c3ba 100644 --- a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/tracker/export/TrackerExportTest.java +++ b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/tracker/export/TrackerExportTest.java @@ -365,7 +365,7 @@ private List splitFields(String fields) { if (field.contains("[")) { for (String s : field.substring(field.indexOf("[") + 1, field.indexOf("]")).split(",")) { - if (s.equalsIgnoreCase("*")) { + if ("*".equalsIgnoreCase(s)) { split.add(field.substring(0, field.indexOf("["))); return; } diff --git a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/tracker/imports/events/EventsDataValueValidationTests.java b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/tracker/imports/events/EventsDataValueValidationTests.java index 02d681399ce7..33d6954c61a6 100644 --- a/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/tracker/imports/events/EventsDataValueValidationTests.java +++ b/dhis-2/dhis-test-e2e/src/test/java/org/hisp/dhis/tracker/imports/events/EventsDataValueValidationTests.java @@ -241,7 +241,7 @@ public void shouldImportEventsWithCompulsoryDataValues() { private JsonObject createEventBodyWithStatus(String status) { EventDataBuilder builder = new EventDataBuilder().setStatus(status); - if (status.equalsIgnoreCase("SCHEDULE")) { + if ("SCHEDULE".equalsIgnoreCase(status)) { builder.setScheduledDate(Instant.now().plus(1, ChronoUnit.DAYS).toString()); } diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/csv/CsvImportServiceTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/csv/CsvImportServiceTest.java index b4d1bb8f52fe..1e3454dced2e 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/csv/CsvImportServiceTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/csv/CsvImportServiceTest.java @@ -255,15 +255,15 @@ void testImportCategoryOptionGroup() throws IOException { List allGroups = manager.getAll(CategoryOptionGroup.class); assertEquals(3, allGroups.size()); CategoryOptionGroup groupA = - allGroups.stream().filter(g -> g.getName().equals("GroupA")).findFirst().orElse(null); + allGroups.stream().filter(g -> "GroupA".equals(g.getName())).findFirst().orElse(null); assertNotNull(groupA); assertEquals(DataDimensionType.DISAGGREGATION, groupA.getDataDimensionType()); CategoryOptionGroup groupB = - allGroups.stream().filter(g -> g.getName().equals("GroupB")).findFirst().orElse(null); + allGroups.stream().filter(g -> "GroupB".equals(g.getName())).findFirst().orElse(null); assertNotNull(groupB); assertEquals(DataDimensionType.DISAGGREGATION, groupB.getDataDimensionType()); CategoryOptionGroup groupC = - allGroups.stream().filter(g -> g.getName().equals("GroupC")).findFirst().orElse(null); + allGroups.stream().filter(g -> "GroupC".equals(g.getName())).findFirst().orElse(null); assertNotNull(groupC); assertEquals(DataDimensionType.ATTRIBUTE, groupC.getDataDimensionType()); } diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/MetadataImportServiceTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/MetadataImportServiceTest.java index 96f4314b514e..2dc9a470e411 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/MetadataImportServiceTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/MetadataImportServiceTest.java @@ -741,7 +741,7 @@ void testMetadataImportWithDeletedDataElements() throws IOException { assertNotNull(manager.get(Section.class, "JwcV2ZifEQf")); assertTrue( dataset.getSections().stream() - .filter(s -> s.getUid().equals("JwcV2ZifEQf")) + .filter(s -> "JwcV2ZifEQf".equals(s.getUid())) .findFirst() .get() .getDataElements() @@ -767,7 +767,7 @@ void testMetadataImportWithDeletedDataElements() throws IOException { assertNotNull(manager.get(Section.class, "JwcV2ZifEQf")); assertFalse( dataset.getSections().stream() - .filter(s -> s.getUid().equals("JwcV2ZifEQf")) + .filter(s -> "JwcV2ZifEQf".equals(s.getUid())) .findFirst() .get() .getDataElements() @@ -877,7 +877,7 @@ void testImportUserNewFormatWithPersistedReferences() throws IOException { User user = manager.get(User.class, "sPWjoHSY03y"); assertNotNull(user); assertTrue( - user.getUserRoles().stream().anyMatch(userRole -> userRole.getUid().equals("xJZBzAHI88H"))); + user.getUserRoles().stream().anyMatch(userRole -> "xJZBzAHI88H".equals(userRole.getUid()))); } @Test @@ -1118,10 +1118,9 @@ void testImportDuplicates() throws IOException { assertTrue( report.hasErrorReport( errorReport -> - errorReport - .getMessage() - .equals( - "Duplicate reference [XJGLlMAMCcn] (Category) on object Gender [faV8QvLgIwB] (CategoryCombo) for association `category`"))); + "Duplicate reference [XJGLlMAMCcn] (Category) on object Gender [faV8QvLgIwB] (CategoryCombo) for association `category`" + .equals(errorReport + .getMessage()))); } private MetadataImportParams createParams(ImportStrategy importStrategy) { diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SMSCommandObjectBundleServiceTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SMSCommandObjectBundleServiceTest.java index e57a0c0809a0..5e26908df178 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SMSCommandObjectBundleServiceTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/SMSCommandObjectBundleServiceTest.java @@ -94,8 +94,8 @@ public void textCreateSMSCommandWithCorrectCOCId() throws IOException { SMSCommand smsCommand = manager.get(SMSCommand.class, "em8Bg4LCr1a"); Set smsCodes = smsCommand.getCodes(); - SMSCode smsCode1 = smsCodes.stream().filter(c -> c.getCode().equals("a")).findFirst().get(); - SMSCode smsCode2 = smsCodes.stream().filter(c -> c.getCode().equals("b")).findFirst().get(); + SMSCode smsCode1 = smsCodes.stream().filter(c -> "a".equals(c.getCode())).findFirst().get(); + SMSCode smsCode2 = smsCodes.stream().filter(c -> "b".equals(c.getCode())).findFirst().get(); assertSame(smsCode1.getOptionId(), categoryService.getDefaultCategoryOptionCombo()); assertSame( diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/maintenance/MaintenanceServiceTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/maintenance/MaintenanceServiceTest.java index 7ae7d692395e..eef463b49d4c 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/maintenance/MaintenanceServiceTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/maintenance/MaintenanceServiceTest.java @@ -445,14 +445,14 @@ void testAuditEntryForDeletionOfSoftDeletedTrackedEntity() { assertEquals( 1, audits.stream() - .filter(a -> a.getKlass().equals("org.hisp.dhis.program.Enrollment")) + .filter(a -> "org.hisp.dhis.program.Enrollment".equals(a.getKlass())) .count()); assertEquals( - 1, audits.stream().filter(a -> a.getKlass().equals("org.hisp.dhis.program.Event")).count()); + 1, audits.stream().filter(a -> "org.hisp.dhis.program.Event".equals(a.getKlass())).count()); assertEquals( 1, audits.stream() - .filter(a -> a.getKlass().equals("org.hisp.dhis.trackedentity.TrackedEntity")) + .filter(a -> "org.hisp.dhis.trackedentity.TrackedEntity".equals(a.getKlass())) .count()); audits.forEach(a -> assertSame(a.getAuditType(), AuditType.DELETE)); } diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/message/MessageServiceTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/message/MessageServiceTest.java index 7cb97cc0a658..d6f7ec6f57e8 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/message/MessageServiceTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/message/MessageServiceTest.java @@ -145,7 +145,7 @@ void testSendMessage() { assertEquals("Subject", conversation.getSubject()); assertEquals(3, conversation.getUserMessages().size()); assertEquals(1, conversation.getMessages().size()); - assertTrue(conversation.getMessages().iterator().next().getText().equals("Text")); + assertTrue("Text".equals(conversation.getMessages().iterator().next().getText())); } @Test diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/query/CriteriaQueryEngineTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/query/CriteriaQueryEngineTest.java index 5ea5a8be4a4a..bef22d3ffeb7 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/query/CriteriaQueryEngineTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/query/CriteriaQueryEngineTest.java @@ -576,7 +576,7 @@ void testEmptyQueryWithNoAccessPermission() { List objects = queryEngine.query(query); // UserB is the owner so DEA is in the result list Optional notPublicDe = - objects.stream().filter(d -> d.getUid().equalsIgnoreCase("deabcdefghA")).findFirst(); + objects.stream().filter(d -> "deabcdefghA".equalsIgnoreCase(d.getUid())).findFirst(); assertTrue(notPublicDe.isPresent()); query = Query.from(schemaService.getDynamicSchema(DataElement.class)); query.setCurrentUserDetails(UserDetails.fromUser(userA)); @@ -585,7 +585,7 @@ void testEmptyQueryWithNoAccessPermission() { // UserA isn't the owner and DEA is not public so it doesn't present in // result list notPublicDe = - objects.stream().filter(d -> d.getUid().equalsIgnoreCase("deabcdefghA")).findFirst(); + objects.stream().filter(d -> "deabcdefghA".equalsIgnoreCase(d.getUid())).findFirst(); assertTrue(!notPublicDe.isPresent()); } diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/bundle/OwnershipTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/bundle/OwnershipTest.java index b09fd731b169..aa9e9022955b 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/bundle/OwnershipTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/bundle/OwnershipTest.java @@ -169,7 +169,7 @@ void testUpdateEnrollment() throws IOException { List enrollments = manager.getAll(Enrollment.class); assertEquals(2, enrollments.size()); Enrollment enrollment = - enrollments.stream().filter(e -> e.getUid().equals("TvctPPhpD8u")).findAny().get(); + enrollments.stream().filter(e -> "TvctPPhpD8u".equals(e.getUid())).findAny().get(); compareEnrollmentBasicProperties(enrollment, trackerObjects.getEnrollments().get(0)); assertNull(enrollment.getCompletedBy()); assertNull(enrollment.getCompletedDate()); @@ -188,7 +188,7 @@ void testUpdateEnrollment() throws IOException { assertEquals(1, updatedReport.getStats().getUpdated()); enrollments = manager.getAll(Enrollment.class); assertEquals(2, enrollments.size()); - enrollment = enrollments.stream().filter(e -> e.getUid().equals("TvctPPhpD8u")).findAny().get(); + enrollment = enrollments.stream().filter(e -> "TvctPPhpD8u".equals(e.getUid())).findAny().get(); compareEnrollmentBasicProperties(enrollment, updatedEnrollment); assertNotNull(enrollment.getCompletedBy()); assertNotNull(enrollment.getCompletedDate()); @@ -200,7 +200,7 @@ void testDeleteEnrollment() throws IOException { TrackerObjects trackerObjects = fromJson("tracker/ownership_enrollment.json"); List enrollments = manager.getAll(Enrollment.class); assertEquals(2, enrollments.size()); - enrollments.stream().filter(e -> e.getUid().equals("TvctPPhpD8u")).findAny().get(); + enrollments.stream().filter(e -> "TvctPPhpD8u".equals(e.getUid())).findAny().get(); params.setImportStrategy(TrackerImportStrategy.DELETE); ImportReport updatedReport = trackerImportService.importTracker(params, trackerObjects); assertNoErrors(updatedReport); diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/programrule/ProgramRuleAssignActionTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/programrule/ProgramRuleAssignActionTest.java index 732b0819490f..e969ed828981 100644 --- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/programrule/ProgramRuleAssignActionTest.java +++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/programrule/ProgramRuleAssignActionTest.java @@ -163,7 +163,7 @@ void shouldImportEventAndCorrectlyAssignPreviousEventDataValue( List eventDataValues = event.getEventDataValues().stream() - .filter(dv -> dv.getDataElement().equals("DATAEL00002")) + .filter(dv -> "DATAEL00002".equals(dv.getDataElement())) .map(EventDataValue::getValue) .toList(); assertContainsOnly(List.of(previousEventDataValue), eventDataValues); @@ -296,7 +296,7 @@ private TrackerObjects getEvent(String eventUid, String occurredDate, String val private List getValueForAssignedDataElement(String eventUid) { return manager.get(Event.class, eventUid).getEventDataValues().stream() - .filter(dv -> dv.getDataElement().equals("DATAEL00002")) + .filter(dv -> "DATAEL00002".equals(dv.getDataElement())) .map(EventDataValue::getValue) .toList(); } diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/DashboardControllerTest.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/DashboardControllerTest.java index 75e98af72202..f1f925a6343f 100644 --- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/DashboardControllerTest.java +++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/DashboardControllerTest.java @@ -64,7 +64,7 @@ void testUpdateWithNonAccessibleItems() { assertEquals(1, dashboard.getItems().size()); Visualization visualization = dashboard.getItems().stream() - .filter(item -> item.getUid().equals("KnmKNIFiAwC")) + .filter(item -> "KnmKNIFiAwC".equals(item.getUid())) .findFirst() .get() .getVisualization(); @@ -97,7 +97,7 @@ void testUpdateWithAccessibleItems() { assertEquals(1, dashboard.getItems().size()); Visualization visualization = dashboard.getItems().stream() - .filter(item -> item.getUid().equals("KnmKNIFiAwC")) + .filter(item -> "KnmKNIFiAwC".equals(item.getUid())) .findFirst() .get() .getVisualization(); @@ -118,7 +118,7 @@ void testUpdateWithAccessibleItems() { // Visualization is still attached to the dashboard item. Optional dashboardItem = dashboard.getItems().stream() - .filter(item -> item.getUid().equals("KnmKNIFiAwC")) + .filter(item -> "KnmKNIFiAwC".equals(item.getUid())) .findFirst(); assertTrue(dashboardItem.isPresent()); assertEquals("gyYXi0rXAIc", dashboardItem.get().getVisualization().getUid()); diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/DataSetMetadataControllerTest.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/DataSetMetadataControllerTest.java index b4b8559fc72e..3270c2ff9863 100644 --- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/DataSetMetadataControllerTest.java +++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/DataSetMetadataControllerTest.java @@ -68,7 +68,7 @@ void getDatasetMetadataDefaultCatComboTest( assertEquals(expectedCatComboSize, categoryCombos.size(), catComboSizeCondition); long count = categoryCombos.asList(JsonObject.class).stream() - .filter(cc -> cc.getString("name").string().equals("default")) + .filter(cc -> "default".equals(cc.getString("name").string())) .count(); assertEquals(expectedDefaultCatComboCount, count, defaultCatComboCondition); } diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/JobConfigurationControllerTest.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/JobConfigurationControllerTest.java index c2f2b294d175..6e8bb578c351 100644 --- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/JobConfigurationControllerTest.java +++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/JobConfigurationControllerTest.java @@ -212,9 +212,9 @@ void testLOCK_EXCEPTION_CLEANUP() { void testGetJobTypeInfo() { for (JsonObject e : GET("/jobConfigurations/jobTypes").content().getList("jobTypes", JsonObject.class)) { - if (e.getString("jobType").string().equals("ANALYTICS_TABLE")) { + if ("ANALYTICS_TABLE".equals(e.getString("jobType").string())) { for (JsonObject param : e.getList("jobParameters", JsonObject.class)) { - if (param.getString("name").string().equals("skipTableTypes")) { + if ("skipTableTypes".equals(param.getString("name").string())) { assertEquals( List.of( "DATA_VALUE", diff --git a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractFullReadOnlyController.java b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractFullReadOnlyController.java index 670851025140..ed6067805448 100644 --- a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractFullReadOnlyController.java +++ b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractFullReadOnlyController.java @@ -595,7 +595,7 @@ private void handleLinksAndAccess(List entityList, List fields, boole private boolean fieldsContains(String match, List fields) { for (String field : fields) { // for now assume href/access if * or preset is requested - if (field.contains(match) || field.equals("*") || field.startsWith(":")) { + if (field.contains(match) || "*".equals(field) || field.startsWith(":")) { return true; } } diff --git a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AccountController.java b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AccountController.java index edab70e5ec67..d8d42bddb803 100644 --- a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AccountController.java +++ b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AccountController.java @@ -587,7 +587,7 @@ private Map validateUserName(String username, boolean validateIf result.put("response", result.isEmpty() ? "success" : "error"); - if (result.get("response").equals("success")) { + if ("success".equals(result.get("response"))) { result.put("message", ""); } diff --git a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/MeController.java b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/MeController.java index fbcedc684843..5f30573b5272 100644 --- a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/MeController.java +++ b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/MeController.java @@ -196,7 +196,7 @@ private void determineUserImpersonation(MeDto meDto) { private boolean fieldsContains(String key, List fields) { for (String field : fields) { - if (field.contains(key) || field.equals("*") || field.startsWith(":")) { + if (field.contains(key) || "*".equals(field) || field.startsWith(":")) { return true; } } diff --git a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/openapi/Api.java b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/openapi/Api.java index de1e5f6d380c..480a92421ecb 100644 --- a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/openapi/Api.java +++ b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/openapi/Api.java @@ -559,8 +559,8 @@ public boolean isIdentifiable() { public boolean isMap() { return type == Type.OBJECT && properties.size() == 2 - && properties.get(0).name.equals("_keys") - && properties.get(1).name.equals("_values"); + && "_keys".equals(properties.get(0).name) + && "_values".equals(properties.get(1).name); } Set getRequiredProperties() { diff --git a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/openapi/ApiExtractor.java b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/openapi/ApiExtractor.java index cf55978db43c..ac93996bd832 100644 --- a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/openapi/ApiExtractor.java +++ b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/openapi/ApiExtractor.java @@ -1001,7 +1001,7 @@ private static ParameterDetails getParameterDetails(PathVariable a) { @Nonnull private static ParameterDetails getParameterDetails(RequestParam a, Parameter p) { - boolean hasDefault = !a.defaultValue().equals("\n\t\t\n\t\t\n\ue000\ue001\ue002\n\t\t\t\t\n"); + boolean hasDefault = !"\n\t\t\n\t\t\n\ue000\ue001\ue002\n\t\t\t\t\n".equals(a.defaultValue()); boolean required = a.required() && !hasDefault; String javaDefaultValue = hasDefault ? a.defaultValue() : null; Class type = p.getType(); diff --git a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/openapi/OpenApiObject.java b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/openapi/OpenApiObject.java index b3aff3e15684..7a7bb7e0c6f1 100644 --- a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/openapi/OpenApiObject.java +++ b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/openapi/OpenApiObject.java @@ -409,7 +409,7 @@ default ParameterObject resolve() { default boolean isShared() { String path = node().getPath().toString(); - return path.substring(0, path.lastIndexOf('.')).equals(".components.parameters"); + return ".components.parameters".equals(path.substring(0, path.lastIndexOf('.'))); } default String getSharedName() { @@ -497,7 +497,7 @@ default boolean isRef() { default boolean isShared() { if (!exists()) return false; String path = node().getPath().toString(); - return path.substring(0, path.lastIndexOf('.')).equals(".components.schemas"); + return ".components.schemas".equals(path.substring(0, path.lastIndexOf('.'))); } default String getSharedName() { diff --git a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/security/ExternalAccessVoter.java b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/security/ExternalAccessVoter.java index e94428b56bc6..f6d0bcdba130 100644 --- a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/security/ExternalAccessVoter.java +++ b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/security/ExternalAccessVoter.java @@ -108,7 +108,7 @@ public int vote( if (urlSplit.length > 3) { String type = urlSplit[2]; - if (urlSplit[1].equals("api") && externalClasses.get(type) != null) { + if ("api".equals(urlSplit[1]) && externalClasses.get(type) != null) { String uid = getUidPart(urlSplit[3]); if (CodeGenerator.isValidUid(uid)) { diff --git a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/servlet/DhisWebApiWebAppInitializer.java b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/servlet/DhisWebApiWebAppInitializer.java index bda63e479b02..9842e7dc691d 100644 --- a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/servlet/DhisWebApiWebAppInitializer.java +++ b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/servlet/DhisWebApiWebAppInitializer.java @@ -144,7 +144,7 @@ public static void setupServlets( context.addServlet("RootPageServlet", LoginFallbackServlet.class).addMapping("/login.html"); String profile = System.getProperty("spring.profiles.active"); - if (profile == null || !profile.equals("embeddedJetty")) { + if (profile == null || !"embeddedJetty".equals(profile)) { RequestContextListener requestContextListener = new RequestContextListener(); context.addListener(requestContextListener); } diff --git a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/HttpServletRequestPaths.java b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/HttpServletRequestPaths.java index 66f89c6dff36..aedde2588a47 100644 --- a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/HttpServletRequestPaths.java +++ b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/HttpServletRequestPaths.java @@ -59,8 +59,8 @@ public static String getContextPath(HttpServletRequest request) { String xForwardedPort = request.getHeader("X-Forwarded-Port"); if (xForwardedProto != null - && (xForwardedProto.equalsIgnoreCase("http") - || xForwardedProto.equalsIgnoreCase("https"))) { + && ("http".equalsIgnoreCase(xForwardedProto) + || "https".equalsIgnoreCase(xForwardedProto))) { builder.append(xForwardedProto); } else { builder.append(request.getScheme()); diff --git a/dhis-2/pom.xml b/dhis-2/pom.xml index 7be4ef66fdbb..43f356f4f462 100644 --- a/dhis-2/pom.xml +++ b/dhis-2/pom.xml @@ -2372,6 +2372,23 @@ jasperreports.version=${jasperreports.version} org.jacoco jacoco-maven-plugin + + org.openrewrite.maven + rewrite-maven-plugin + 5.43.0 + + + org.openrewrite.staticanalysis.EqualsAvoidsNull + + + + + org.openrewrite.recipe + rewrite-static-analysis + 1.19.0 + + +