Question

I've a bean that contains a java.util.Set, when I try to populate the Set, I got BeanException: Index property is not an array, list or map. Why Jodd doesn't support Set ? My bean look like:

public class ShippingRule {
   private Set<String> returnConstraints;

   public Set<String> getReturnConstraints() {
      return returnConstraints;
   }
   public void setReturnConstraints(Set<String> returnConstraints) {
      this.returnConstraints = returnConstraints;
   }
}

and I populate the with:

ShippingRule shippingRule = new ShippingRule();
BeanUtil.setPropertyForced(shippingRule, "returnConstraints[0]", "restrict1");
BeanUtil.setPropertyForced(shippingRule, "returnConstraints[1]", "restrict2");

am I missing something ? Please advise and thanks!

Was it helpful?

Solution

Because Collections do not have key/value or index behavior or get() method. Let's look your example:

getProperty("returnConstraints") returns a Set<String>. In that case, what would be the [0] on the Set? Set simply can not be used like this :)

Your example looks like your property has to be String[] or List<String> or (unlikely) Map<Integer, String>.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top