import org.onap.ccsdk.cds.controllerblueprints.core.utils.JsonParserUtils
import org.slf4j.LoggerFactory
import org.slf4j.helpers.MessageFormatter
+import java.util.*
import kotlin.reflect.KClass
/**
fun <T : KClass<*>> logger(clazz: T) = LoggerFactory.getLogger(clazz.java)!!
+fun <T : Any> T?.defaultToEmpty(): String {
+ return this?.toString() ?: ""
+}
+
+fun <T : Any> T?.defaultToUUID(): String {
+ return this?.toString() ?: UUID.randomUUID().toString()
+}
fun <T : Any> T.bpClone(): T {
return ObjectUtils.clone(this)
fun <T> JsonNode.asType(clazzType: Class<T>): T {
return JacksonUtils.readValue(this, clazzType)
- ?: throw BluePrintException("couldn't convert JsonNode of type $clazzType")
+ ?: throw BluePrintException("couldn't convert JsonNode of type $clazzType")
}
fun JsonNode.asListOfString(): List<String> {
fun <T : JsonNode> T?.returnNullIfMissing(): JsonNode? {
return if (this == null || this is NullNode || this is MissingNode) {
null
- }
- else this
+ } else this
}
fun <T : JsonNode> T?.isNullOrMissing(): Boolean {