All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.frtu.kotlin.protobuf.BaseMessageMetadataHelper.kt Maven / Gradle / Ivy

package com.github.frtu.kotlin.protobuf

import com.google.protobuf.DescriptorProtos.MessageOptions
import com.google.protobuf.Descriptors
import com.google.protobuf.GeneratedMessage
import java.util.*

open class BaseMessageMetadataHelper(
    private val messageOptions: GeneratedMessage.GeneratedExtension,
) {
    fun getExtension(messageDescriptor: Descriptors.Descriptor?): T? {
        if (messageDescriptor == null) {
            return null
        }
        val options = messageDescriptor.options
        return options.getExtension(messageOptions)
    }

    fun hasExtension(messageDescriptor: Descriptors.Descriptor?): Boolean {
        return getExtension(messageDescriptor) != null
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy