Fixed: Blank page is displayed on ecommerce
Fixed recursions in hashCode methods introduced wth
Thanks Arpit Mor for reporting, Jacques Le Roux amd Priya Sharma for
review and helpful hints.
@@ -531,25 +531,18 @@ public class ProductConfigWrapper implements Serializable {
}
@Override
- public boolean equals(Object obj) {
- if (obj == null || !(obj instanceof ConfigItem)) {
- return false;
- }
- ConfigItem ci = (ConfigItem)obj;
- if (!configItem.getString("configItemId").equals(ci.getConfigItem().getString("configItemId"))) {
- return false;
- }
- List<ConfigOption> opts = ci.getOptions();
- if (options.size() != opts.size()) {
- return false;
- }
- for (int i = 0; i < options.size(); i++) {
- ConfigOption co = options.get(i);
- if (!co.equals(opts.get(i))) {
- return false;
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ConfigItem that = (ConfigItem) o;
+ return Objects.equals(getConfigItem(), that.getConfigItem()) &&
+ Objects.equals(getConfigItemAssoc(), that.getConfigItemAssoc()) &&
+ Objects.equals(getOptions(), that.getOptions());
}
- }
- return true;
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getConfigItem(), getConfigItemAssoc(), getOptions());
}
@Override
@@ -557,10 +550,6 @@ public class ProductConfigWrapper implements Serializable {
return configItem.getString("configItemId");
}
- @Override
- public int hashCode() {
- return Objects.hash(configItem, configItemAssoc, content, options, first);
- }
}
public class ConfigOption implements java.io.Serializable {
@@ -815,41 +804,27 @@ public class ProductConfigWrapper implements Serializable {
return componentOptions;
}
-
@Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + getOuterType().hashCode();
- result = prime * result + ((componentList == null) ? 0 : componentList.hashCode());
- result = prime * result + ((componentOptions == null) ? 0 : componentOptions.hashCode());
- return result;
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ConfigOption that = (ConfigOption) o;
+ return Objects.equals(availabilityDate, that.availabilityDate) &&
+ Objects.equals(componentList, that.componentList) &&
+ Objects.equals(getComponentOptions(), that.getComponentOptions()) &&
+ Objects.equals(configOption, that.configOption);
}
-
@Override
- public boolean equals(Object obj) {
- if (obj == null || !(obj instanceof ConfigOption)) {
- return false;
- }
- ConfigOption co = (ConfigOption)obj;
- if (componentOptions != null && !componentOptions.equals(co.getComponentOptions())) {
- return false;
- }
-
- return isSelected() == co.isSelected();
+ public int hashCode() {
+ return Objects.hash(availabilityDate, componentList, getComponentOptions(), configOption);
}
-
@Override
public String toString() {
return configOption.getString("configItemId") + "/" + configOption.getString("configOptionId") + (isSelected()? "*": "");
}
- private ProductConfigWrapper getOuterType() {
- return ProductConfigWrapper.this;
- }
-
}
}
