public void setParameter(String field, List<String> values) { try { // check if it's a multiple value if (values != null && !values.isEmpty()) { String value = values.iterator().next(); if ("item_comparators".equals(field)) { List<CF_ITEM_COMPARATOR> list = new ArrayList<>(); for (String val : values) { list.add(CF_ITEM_COMPARATOR.valueOf(val)); } setItemComparators(list); } else if ("item_comparator_strategy".equals(field)) { setItemComparatorStrategy(CF_STRATEGY.valueOf(value)); } else if ("recommenders".equals(field)) { List<CF_RECOMMENDER> list = new ArrayList<>(); for (String val : values) { list.add(CF_RECOMMENDER.valueOf(val)); } setRecommenders(list); } else if ("sorters".equals(field)) { List<CF_SORTER> list = new ArrayList<>(); for (String val : values) { list.add(CF_SORTER.valueOf(val)); } setSorters(list); } else if ("sorter_strategy".equals(field)) { setSorterStrategy(CF_STRATEGY.valueOf(value)); } else if ("long_term_cluster_weight".equals(field)) { this.setLongTermWeight(Double.parseDouble(value)); } else if ("short_term_cluster_weight".equals(field)) { this.setShortTermWeight(Double.parseDouble(value)); } else if ("recent_articles_sv".equals(field)) { this.setRecentArticlesForSV(Integer.parseInt(value)); } else if ("tx_history_sv".equals(field)) { this.setTxHistorySizeForSV(Integer.parseInt(value)); } else if ("tag_attr_id".equals(field)) { this.setTagAttrId(Integer.parseInt(value)); } else if ("sv_prefix".equals(field)) { this.setSvPrefix(value); } else if ("num_recent_actions".equals(field)) { this.setNumRecentActions(Integer.parseInt(value)); } else { final String message = "Field : " + field + " not recognized"; logger.error(message, new Exception(message)); } } } catch (Exception e) { logger.error("Not able to process the field : " + field + " with value: " + values, e); } }
@Override public int hashCode() { int result; long temp; result = itemComparators != null ? itemComparators.hashCode() : 0; result = 31 * result + (itemComparatorStrategy != null ? itemComparatorStrategy.hashCode() : 0); result = 31 * result + (recommenders != null ? recommenders.hashCode() : 0); result = 31 * result + (sorters != null ? sorters.hashCode() : 0); result = 31 * result + (sorterStrategy != null ? sorterStrategy.hashCode() : 0); result = 31 * result + (date != null ? date.hashCode() : 0); result = 31 * result + (name != null ? name.hashCode() : 0); result = 31 * result + userCFLimit; result = 31 * result + transactionActionType; temp = longTermWeight != +0.0d ? Double.doubleToLongBits(longTermWeight) : 0L; result = 31 * result + (int) (temp ^ (temp >>> 32)); temp = shortTermWeight != +0.0d ? Double.doubleToLongBits(shortTermWeight) : 0L; result = 31 * result + (int) (temp ^ (temp >>> 32)); result = 31 * result + numRecentActions; return result; }
public String toLogSorter() { String res = ""; // CF_SORTER if (sorters != null && sorters.size() > 0) { for (CF_SORTER s : sorters) { res += s.name() + "|"; } res = res.substring(0, res.length() - 1); } // CF_STRATEGY if (sorterStrategy != null) res += ";" + sorterStrategy.name(); // CF_POSTPROCESSING return res; }