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

com.simiacryptus.util.describe.AbbrevBlacklistYamlDescriber.kt Maven / Gradle / Ivy

There is a newer version: 1.0.33
Show newest version
package com.simiacryptus.util.describe

import com.simiacryptus.util.describe.DescriptorUtil.componentType
import com.simiacryptus.util.describe.DescriptorUtil.isArray
import java.lang.reflect.ParameterizedType
import java.lang.reflect.Type

class AbbrevBlacklistYamlDescriber(vararg val abbreviated: String) : YamlDescriber() {
    override fun isAbbreviated(self: Type): Boolean {
        if (self.typeName in TypeDescriber.primitives) {
            return false
        } else if (self is ParameterizedType && List::class.java.isAssignableFrom(self.rawType as Class<*>)) {
            return isAbbreviated(self.actualTypeArguments[0])
        } else if (self is ParameterizedType && Map::class.java.isAssignableFrom(self.rawType as Class<*>)) {
            return isAbbreviated(self.actualTypeArguments[0]) && isAbbreviated(self.actualTypeArguments[1])
        } else if (self.isArray) {
            return isAbbreviated(self.componentType!!)
        }
        return (abbreviated.find { self.typeName.startsWith(it) } != null) || super.isAbbreviated(self)
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy