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

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

package com.github.frtu.kotlin.protobuf

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

open class BaseFieldMetadataHelper(
    private val fieldExtention: GeneratedMessage.GeneratedExtension,
) {
    fun getExtension(fieldDescriptor: Descriptors.FieldDescriptor?): Optional {
        if (fieldDescriptor == null) {
            return Optional.empty()
        }
        val options = fieldDescriptor.options
        return Optional.of(options.getExtension(fieldExtention))
    }

    fun hasExtension(fieldDescriptor: Descriptors.FieldDescriptor?): Boolean {
        return getExtension(fieldDescriptor).isPresent
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy