Author: mbrohl
Date: Sun Oct 22 11:24:21 2017 New Revision: 1812897 URL: http://svn.apache.org/viewvc?rev=1812897&view=rev Log: Improved: Fixing defects reported by FindBugs, package org.apache.ofbiz.service.eca. (OFBIZ-9683) Thanks Julian Leichert for reporting and providing the patch. Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaAction.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaCondition.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaRule.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaSetField.java Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaAction.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaAction.java?rev=1812897&r1=1812896&r2=1812897&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaAction.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaAction.java Sun Oct 22 11:24:21 2017 @@ -233,6 +233,24 @@ public class ServiceEcaAction implements } @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((eventName == null) ? 0 : eventName.hashCode()); + result = prime * result + (ignoreError ? 1231 : 1237); + result = prime * result + (ignoreFailure ? 1231 : 1237); + result = prime * result + (newTransaction ? 1231 : 1237); + result = prime * result + (persist ? 1231 : 1237); + result = prime * result + ((resultMapName == null) ? 0 : resultMapName.hashCode()); + result = prime * result + (resultToContext ? 1231 : 1237); + result = prime * result + (resultToResult ? 1231 : 1237); + result = prime * result + ((runAsUser == null) ? 0 : runAsUser.hashCode()); + result = prime * result + ((serviceMode == null) ? 0 : serviceMode.hashCode()); + result = prime * result + ((serviceName == null) ? 0 : serviceName.hashCode()); + return result; + } + + @Override public boolean equals(Object obj) { if (obj instanceof ServiceEcaAction) { ServiceEcaAction other = (ServiceEcaAction) obj; Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaCondition.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaCondition.java?rev=1812897&r1=1812896&r2=1812897&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaCondition.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaCondition.java Sun Oct 22 11:24:21 2017 @@ -75,12 +75,6 @@ public class ServiceEcaCondition impleme this.compareType = condition.getAttribute("type"); this.format = condition.getAttribute("format"); - if (lhsValueName == null) { - lhsValueName = ""; - } - if (rhsValueName == null) { - rhsValueName = ""; - } } } @@ -215,6 +209,23 @@ public class ServiceEcaCondition impleme } @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((compareType == null) ? 0 : compareType.hashCode()); + result = prime * result + ((conditionService == null) ? 0 : conditionService.hashCode()); + result = prime * result + ((format == null) ? 0 : format.hashCode()); + result = prime * result + (isConstant ? 1231 : 1237); + result = prime * result + (isService ? 1231 : 1237); + result = prime * result + ((lhsMapName == null) ? 0 : lhsMapName.hashCode()); + result = prime * result + ((lhsValueName == null) ? 0 : lhsValueName.hashCode()); + result = prime * result + ((operator == null) ? 0 : operator.hashCode()); + result = prime * result + ((rhsMapName == null) ? 0 : rhsMapName.hashCode()); + result = prime * result + ((rhsValueName == null) ? 0 : rhsValueName.hashCode()); + return result; + } + + @Override public boolean equals(Object obj) { if (obj instanceof ServiceEcaCondition) { ServiceEcaCondition other = (ServiceEcaCondition) obj; Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaRule.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaRule.java?rev=1812897&r1=1812896&r2=1812897&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaRule.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaRule.java Sun Oct 22 11:24:21 2017 @@ -40,14 +40,14 @@ public final class ServiceEcaRule implem public static final String module = ServiceEcaRule.class.getName(); - protected final String serviceName; - protected final String eventName; - protected final boolean runOnFailure; - protected final boolean runOnError; - protected final List<ServiceEcaCondition> conditions = new ArrayList<ServiceEcaCondition>(); - protected final List<Object> actionsAndSets = new ArrayList<Object>(); - protected boolean enabled = true; - protected final String definitionLocation; + public final String serviceName; + public final String eventName; + public final boolean runOnFailure; + public final boolean runOnError; + public final List<ServiceEcaCondition> conditions = new ArrayList<ServiceEcaCondition>(); + public final List<Object> actionsAndSets = new ArrayList<Object>(); + public boolean enabled = true; + public final String definitionLocation; public ServiceEcaRule(Element eca, String definitionLocation) { this.definitionLocation = definitionLocation; @@ -178,6 +178,21 @@ public final class ServiceEcaRule implem } @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((actionsAndSets == null) ? 0 : actionsAndSets.hashCode()); + result = prime * result + ((conditions == null) ? 0 : conditions.hashCode()); + result = prime * result + ((definitionLocation == null) ? 0 : definitionLocation.hashCode()); + result = prime * result + (enabled ? 1231 : 1237); + result = prime * result + ((eventName == null) ? 0 : eventName.hashCode()); + result = prime * result + (runOnError ? 1231 : 1237); + result = prime * result + (runOnFailure ? 1231 : 1237); + result = prime * result + ((serviceName == null) ? 0 : serviceName.hashCode()); + return result; + } + + @Override public boolean equals(Object obj) { if (obj instanceof ServiceEcaRule) { ServiceEcaRule other = (ServiceEcaRule) obj; Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaSetField.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaSetField.java?rev=1812897&r1=1812896&r2=1812897&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaSetField.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaSetField.java Sun Oct 22 11:24:21 2017 @@ -20,6 +20,7 @@ package org.apache.ofbiz.service.eca; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import org.apache.ofbiz.base.util.Debug; @@ -106,10 +107,10 @@ public class ServiceEcaSetField { return newStr.toString(); } if ("to-upper".equalsIgnoreCase(format)) { - return s.toUpperCase(); + return s.toUpperCase(Locale.getDefault()); } if ("to-lower".equalsIgnoreCase(format)) { - return s.toLowerCase(); + return s.toLowerCase(Locale.getDefault()); } if ("hash-code".equalsIgnoreCase(format)) { return Integer.valueOf(s.hashCode()); @@ -140,6 +141,18 @@ public class ServiceEcaSetField { } @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((envName == null) ? 0 : envName.hashCode()); + result = prime * result + ((fieldName == null) ? 0 : fieldName.hashCode()); + result = prime * result + ((format == null) ? 0 : format.hashCode()); + result = prime * result + ((mapName == null) ? 0 : mapName.hashCode()); + result = prime * result + ((value == null) ? 0 : value.hashCode()); + return result; + } + + @Override public boolean equals(Object obj) { if (obj instanceof ServiceEcaSetField) { ServiceEcaSetField other = (ServiceEcaSetField) obj; |
Free forum by Nabble | Edit this page |