Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can create a custom SingleValueConverter to convert the list:</p> <pre><code>public class IntegerListConverter implements SingleValueConverter { @Override public boolean canConvert(Class clazz) { return List.class.isAssignableFrom(clazz); } @Override public Object fromString(String arg0) { Collection&lt;Integer&gt; collection = new ArrayList&lt;Integer&gt;(); String[] integerStrings = arg0.split(" "); for (int i = 0; i &lt; integerStrings.length; i++) { collection.add(Integer.valueOf(integerStrings[i])); } return collection; } @Override public String toString(Object arg0) { List collection = (List) arg0; StringBuffer sb = new StringBuffer(); boolean first = true; for (Object object : collection) { if (first) { first = false; } else { sb.append(' '); } sb.append(object.toString()); } return sb.toString(); } } </code></pre> <p>The fact that <code>List&lt;Integer&gt;</code> is a generic interface makes things a little complicated. This implementation of <code>canConvert</code> will give false positives for Lists that contain other things than Integers. I'm not sure if the clazz parameter contains enough information to determine the generic type arguments. So the safest probably is to assign the converter to that single field only:</p> <pre><code>public class MyClass { @XStreamConverter(IntegerListConverter.class) List&lt;Integer&gt; values; //+ getter &amp; setters } </code></pre> <p>Also, this implementation of <code>fromString</code> will always generate an ArrayList, but that ought to be fine I suspect.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload