2

I'm working in Kotlin and want to read a list of entities, but I am getting a syntax error on the {}: "Type mismatch, Required: Type!, Found: () -> Unit"

if I remove the {} the syntax error is on GenericType: "Cannot access 'init' it is protected in GenericType"

I'm wondering what the correct syntax is for reading a list of Entities from a response in Kotlin

val path = URL_PATH
val target = getTarget(path)
val response = getRequestBuilder(target).get()

response.readEntity(GenericType<List<FoodSummary>>() {})
Aaron B
  • 97
  • 1
  • 1
  • 7

1 Answers1

6

This should work:

response.readEntity(object : GenericType<List<FoodSummary>>() {})

Check the following for more details: How to create an instance of anonymous class of abstract class in Kotlin?

Adam W
  • 61
  • 2