title: How to instantiate model class from nested classes with kotlin reflection
body: <p>Can't seem to get my head around the reflection documentation for Kotlin.</p>
  <p>I have a bunch of nested classes which implement an interface so they all have the same methods and properties. I want to show each of these class in a RecyclerView. I'm almost there but I can't get the information from my classes to build my model class which will be used in the RecyclerAdapter.</p>
  <p>I got my list of nested classes, but I can't figure out how to access to properties so i can instantiate a model.</p>
  <p>This is my interface:</p>
  <pre><code>interface SquibCommand {
      val title: String
      val description: String
      fun setParams(commandParams: CommandParams)
      fun execute()
  }
  </code></pre>
  <p>Then I can get a Collection of all the nested classes like this:</p>
  <pre><code>val commandClass = AllCommands::class
  val commandList = commandClass.nestedClasses
  Log.d(&quot;Commands&quot;, &quot;Your command collection is &quot; + commandList)
  </code></pre>
  <p>Then I need to build a model from each command that can be used to populate the fields in my adapter view. Something like:</p>
  <pre><code>commandModels = ArrayList&lt;CommandModel&gt;
  commandList.forEach {
     val cmd: CommandModel
     cmd.title = it.title 
     cmd.description = it.description 
     commandModels.add(cmd)
  }
  </code></pre>
  <p>I can't seem to figure out how to get the actual value of the title and description properties from each class, rather than just the name of the property.</p>
  <p>EDIT:</p>
  <p>So I can access the properties of any single class by doing:</p>
  <pre><code>    val myOtherClass = AllCommands.TimerCommand::class.members.find {it.name == &quot;title&quot;}
      Log.d(&quot;BrowseCommands&quot;, &quot;Your commands list is &quot; + myOtherClass!!.call(AllCommands.TimerCommand()))
  </code></pre>
  <p>but as I have to access all the nested classes from a collection, I can't figure out what to pass to the Call... it should surely be something like:</p>
  <pre><code>    val myClass = commandList.elementAt(0)
      Log.d(&quot;BrowseCommands&quot;, &quot;Your commands list is &quot; + myClass.members.find {it.name == &quot;title&quot;}?.call(myClass()))
  </code></pre>
  <p>But this doesn't work. How do I instantiate the class when it is from within the commandList collection?</p>