I am trying to change the Map value Object to List Value Object, so that a single key can store multiple values. Please find the code snippet.
protected Subscriber updateSubscriberAttributes(Subscriber subscriber, Collection<SubscriberAttributeDto> subscriberAttributesCollection)
throws ErrorException {
// Do we have any custom attributes to store?
if ((subscriberAttributesCollection != null) && !subscriberAttributesCollection.isEmpty()) {
// Yes! Convert to a Map first.
Map<String, Object> subscriberAttributesMap = new HashMap<String, Object>(subscriberAttributesCollection.size());
for (SubscriberAttributeDto subscriberAttribute : subscriberAttributesCollection) {
// Convert the input attribute value to a database-appropriate value
SubscriberAttributeMetadata attrMetadata = subscriberAttribute.getAttributeMetadata();
if (attrMetadata != null) {
subscriberAttributesMap.put(attrMetadata.getColumnName(),
attrMetadata.convertToDatabaseValue((String) subscriberAttribute.getValue()));
}
}
// Perform the update
return updateSubscriberAttributes(subscriber, subscriberAttributesMap);
} else {
return subscriber;
}
}
Sorry the code is little messy. So the trouble I am facing here is, If I change the declaration of subscribersAttributeMap to Map<String,List<Object>> I have to change the method declaration and throwing me so many errors. I did try it from long time.