title: How to map a CSV to Object with List using CsvMapper?
body: <p>I'm trying to map a Csv file to an Object what instances List of Objects using CsvMapper, is that even possible?</p>
  <p>Example:</p>
  <p>Content of Csv file (without header):</p>
  <p>Field 1: name</p>
  <p>Field 2: gender</p>
  <p>Field 3: hobby (List comma separated)</p>
  <p>Field 4: relation</p>
  <pre><code>Bob;male;riding,swimming,dance;single
  </code></pre>
  <p>Example class:</p>
  <pre class="lang-java prettyprint-override"><code>@AllArgsConstructor(access = AccessLevel.PRIVATE)
  Class User {
      String name;
      String gender;
      List&lt;Hobby&gt; hobbys;
      String relation;
      Boolean check;
      int index;
  
    public static User from(String name,
                            String gender,
                            List&lt;Hobby&gt; hobbys,
                            String relation) {
  
       ------ SOME LOGIC -----
       return new User(name,
                       gender,
                       hobbys,
                       relation,
                       index)
  
     }
  
  }
  </code></pre>
  <pre class="lang-java prettyprint-override"><code>Class UserCreator{
  
     public List&lt;User&gt; create(File csvFile){
        //Now my Problem how can I map the csvFile to User Object???
        //my attempts
        CsvMapper csvMapper = new CsvMapper();
         CsvSchema csvSchema = CsvSchema
              .emptySchema()
              .withoutHeader()
          .withColumnSeparator(',')
          .withLineSeparator(&quot;;&quot;);
  
      try {
        //here its crashes, my problem ist how can I map it to the User object?
        MappingIterator&lt;Map&lt;String, String&gt;&gt; it = csvMapper.readerFor(Map.class)
                                                           .with(csvSchema)
                                                           .readValues(file);
        System.out.println(&quot;test&quot;);
      } catch (IOException e) {
        e.printStackTrace();
      }
     }
  }
  </code></pre>
  <p>Thank you in advance.</p>