title: Create instance of Spring´s ParameterizedTypeReference in Kotlin
body: <p>I am trying to learn Kotlin, and test how it works with spring boot. My application is using a mongo database to store data and I have a Jersey resource for retrieving data. I am testing it using <code>spring-boot-test</code> and <code>RestTestTemplate</code>.</p>
  
  <p>The <code>RestTestTemplate</code> has an <code>exchange</code> method which takes a <code>ParameterizedTypeReference</code>. This class has a protected constructor. So the only way I managed to use it from Kotlin was like this:</p>
  
  <p><code>class ListOfPeople : ParameterizedTypeReference&lt;List&lt;Person&gt;&gt;()</code> </p>
  
  <p>Here is my test-method:</p>
  
  <pre><code>@Test
  fun `get list of people`() {
      // create testdata
      datastore.save(Person(firstname = "test1", lastname = "lastname1"))
      datastore.save(Person(firstname = "test2", lastname = "lastname2"))
      datastore.save(Person(firstname = "test3", lastname = "lastname2"))
      datastore.save(Person(firstname = "test4", lastname = "lastname2"))
  
      val requestEntity = RequestEntity&lt;Any&gt;(HttpMethod.GET, URI.create("/person"))
  
      // create typereference for response de-serialization
      class ListOfPeople : ParameterizedTypeReference&lt;List&lt;Person&gt;&gt;() // can this be done inline in the exchange method?
      val responseEntity : ResponseEntity&lt;List&lt;Person&gt;&gt; = restTemplate.exchange(requestEntity, ListOfPeople())
  
      assertNotNull(responseEntity)
      assertEquals(200, responseEntity.statusCodeValue)
      assertTrue( responseEntity.body.size &gt;= 4 )
  
      responseEntity.body.forEach { person -&gt;
          println("Found person: [${person.firstname} ${person.lastname}] " +
                  ", born [${person.birthdate}]")
      }
  }
  </code></pre>
  
  <p>Is this the correct (or only) way to do this, or is there a better way?</p>
  
  <p>If it helps, here is a link for the whole test: <a href="https://github.com/thomasandersen77/learning-kotlin/blob/master/kotlin-springboot/src/test/kotlin/org/andtho/kotlin/web/restkotlin/RestKotlinApplicationTests.kt" rel="noreferrer">testclass on github</a></p>