Reflection and delegation properties?


#1

I am trying to write more or less generic code to serialize a kotlin data class with google protobuf using the Kotlin release 1.1-beta-22.
I have a data class and using inheritance with delegation to support one interface in the the data class.

data class VehicleOffer(val baseOffer: BaseOffer,
                        val name: String,
                        val transmissionType: String? = null,
                        val airConditionInd: String? = null,
                        val vehTypeVehicleCategory: String? = null,
                        val vehTypeDoorCount: String? = null,
                        val fuelType: String? = null,
                        val vehicleClassSize: String? = null,
                        val rateQualifier: String? = null) : Offer by baseOffer

Whe performing the serialization I need to skip the properties in the extend class that come by delegation because I already have a function to handle the super type. How can I how is the property I am about to handle is from the super of the extended class ?
The following is the serialization code:

fun toWire(vehicleOffer: VehicleOffer) : Data.Offer {
    val baseOffer = toWire(vehicleOffer as Offer)
    val builder = Data.Offer.newBuilder(baseOffer)
    val kClass = vehicleOffer.javaClass.kotlin
    kClass.memberProperties.forEach { prop ->
        val name = prop.name
        val value = prop.get(vehicleOffer)
        if (value !is Offer) {
            builder.putAttributes(name, value.toString())
        }
    }
    return builder.build()
}

Thank you, kindly
Oscar