title: Android: How to make type converters (for Room) generic for all List of objects in Kotlin
body: <p>I am using Room as the local database solution in my project.
  For every list of a certain object type I've added type converters to the project so the type convertor would look something like this: </p>
  
  <pre><code>@TypeConverter
  fun convertListToString(video: List&lt;VideoType&gt;): String {
  
      val videoArray = arrayOfNulls&lt;VideoType&gt;(video.size)
      for (i in 0..video.size - 1) {
          videoArray[i] = video[i]
      }
      var str = ""
      val gson = Gson()
      for (i in videoArray.indices) {
          val jsonString = gson.toJson(videoArray[i])
          str = str + jsonString
          if (i &lt; videoArray.size - 1) {
              str = str + strSeparator
          }
      }
  
      return str
  }
  
  @TypeConverter
  fun convertStringToList(videoString: String): List&lt;VideoType&gt; {
  
      val videoArray = videoString.split(strSeparator.toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
      val videos = ArrayList&lt;VideoType&gt;()
      val gson = Gson()
      for (i in 0 until videoArray.size - 1) {
          videos.add(gson.fromJson(videoArray[i], VideoType::class.java))
      }
  
      return videos
  }
  </code></pre>
  
  <p>Problem only is that I have a whole bunch of List of different types that need to be converted, so currently I am just copying this code for every type. I would like to use generics, but so far haven't been able to figure out how to do it.</p>
  
  <p>For example using something like:</p>
  
  <pre><code>@TypeConverter
  inline fun &lt;reified T&gt; convertStringToList(string: String): List&lt;T&gt; {
      val objectArray = string.split(strSeparator.toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
      val objects = ArrayList&lt;T&gt;()
      val gson = Gson()
      for (i in 0 until objectArray.size - 1) {
          objects.add(gson.fromJson(objectArray[i], T::class.java))
      }
      return objects
  }
  </code></pre>
  
  <p>isn't working and causes compilation error with Android Studio giving me an error telling: <strong>Type converters must be public</strong></p>
  
  <p>Anyone an idea how I can use generics for my Room TypeConverter?</p>