You need to sign in to do that
Don't have an account?
halopez
User defined type found in unsupported code path.
Hi all,
Sorry in advance for such a newbie question, but I am currently having problems when using the set methods when comparing custom classes, and I can't seem to find the error. I have the following class:
public class ProductModelerController{ public String name {get{return name;} set {name = value;}} public String role {get{return role;} set {role = value;}} private Set<ProductModelController> assignedModels; private integer identifier; public void updateProductModels(Set<ProductModelController> updatedModels){ //Compare each of the product models and verify it has the most updated information if(!this.assignedModels.isEmpty()){ for(ProductModelController model: updatedModels){ //Search for the model in the list of assignedModels for(ProductModelController storedModel: this.assignedModels){ //If the model name is the same, update its contents if (model.name == storedModel.name){ storedModel.updateProductModel(model); } } } if (!this.assignedModels.containsAll(updatedModels)){ //Updates the set of available models with the recently added models Set<ProductModelController> newModels = updatedModels.clone(); newModels.removeAll(this.assignedModels); this.assignedModels.addAll(newModels); } } else{ this.assignedModels = updatedModels; } } }
When testing it, I am getting an error in the moment the code reach
if (!this.assignedModels.containsAll(updatedModels)){
The error is: System.UnexpectedException: User defined type found in unsupported code path.
I haven't seen something like that before, and perhaps any of you have a clue what's wrong here? any help would be greatly appreciated!
Thanks and again sorry for the newbie question
I've been having the same issue and can't find information anywhere!
The only thing I've managed to turn up is that Sets need you to provide equals and hashCode methods for your custom class in order to determine uniqueness. That said, I've done so and am still getting this error, but maybe you'll have better luck...
Otherwise, somebody please help! haha
Indeed, I have tried by implementing both equals and hashCode (as mentioned in http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_collections_maps_keys_userdefined.htm), with not much luck: the error persists and hashCode is not even touched.
Instead of the custom sets and maps, I am giving it a try to the apex common library (http://www.tgerm.com/2011/07/xcollections-using-udt-with-map-set-in.html). You don't have generics, which makes the adaptation a bit lenghy, but the comparison between custom objects works fine.