title: How to add existing objects on a new class on Realm Migration in Android
body: <p>I have an app on production, so changes has to be applied with a <code>RealmMigration</code></p>
  
  <p>I've looked the documentation and this <a href="https://github.com/realm/realm-java/blob/master/examples/migrationExample/src/main/java/io/realm/examples/realmmigrationexample/model/Migration.java" rel="noreferrer">example</a> but I didn't find how to do the following.</p>
  
  <p>In current version I have items of type <code>Foo</code> that has a <code>boolean</code> property called <code>favorite</code>. 
  Now I want to generalize that and create user custom <code>Foo</code> lists, so the users will be able to create their custom lists and add as many objects as they want.
  I want to implement this with a new class called <code>UserFooList</code> with basically <code>name</code> and a <code>RealmList&lt;Foo&gt;</code>of elements.</p>
  
  <p>In migration process I'm creating this new class with its fields.</p>
  
  <p>That's easy, but here comes the difficult part:</p>
  
  <p>I want to add all previous <code>Foo</code> items flagged with <code>favorite</code> to a new <code>UserFooList</code> and then remove the now unused <code>Foo</code>'s field <code>favorite</code></p>
  
  <hr>
  
  <p>Some code to help to clarify:</p>
  
  <p><strong>Current class</strong></p>
  
  <pre><code>public class Foo extends RealmObject{
  
      private String title;
      private boolean favorite;
  
      public String getTitle() {
          return title;
      }
  
      public void setTitle(String title) {
          this.title = title;
      }
  
      public boolean isFavorite() {
          return favorite;
      }
  
      public void setFavorite(boolean favorite) {
          this.favorite = favorite;
      }
  }
  </code></pre>
  
  <p><strong>Changed class</strong></p>
  
  <pre><code>public class Foo extends RealmObject{
  
      //favorite field will be removed
      private String title;
  
      public String getTitle() {
          return title;
      }
  
      public void setTitle(String title) {
          this.title = title;
      }
  }
  </code></pre>
  
  <p><strong>New class</strong></p>
  
  <pre><code>public class UserFooList extends RealmObject{
  
      private String name;
      private RealmList&lt;Foo&gt; items;
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public RealmList&lt;Foo&gt; getItems() {
          return items;
      }
  
      public void setItems(RealmList&lt;Foo&gt; items) {
          this.items = items;
      }
  }
  </code></pre>
  
  <p>I want to insert a <code>UserFooList</code> instance and populate it with:</p>
  
  <ul>
  <li><code>name</code>: "favorites"</li>
  <li><code>items</code>: all existing <code>Foo</code> instances with <code>favorite == true</code></li>
  </ul>
  
  <p>And I want to do it during Migration because in that way I will be able to remove <code>favorite</code> field after inserting all elements in the new created list.</p>