mirror of
https://github.com/corda/corda.git
synced 2025-05-28 21:24:24 +00:00
Review comments
Rename rtn to serializer Some whatspace reformatting
This commit is contained in:
parent
2d28cb01d5
commit
ae72d4d788
@ -63,25 +63,23 @@ class SerializerFactory(val whitelist: ClassWhitelist = AllWhitelist) {
|
|||||||
|
|
||||||
val actualType: Type = inferTypeVariables(actualClass, declaredClass, declaredType) ?: declaredType
|
val actualType: Type = inferTypeVariables(actualClass, declaredClass, declaredType) ?: declaredType
|
||||||
|
|
||||||
val rtn = let {
|
val serializer = if (Collection::class.java.isAssignableFrom(declaredClass)) {
|
||||||
if (Collection::class.java.isAssignableFrom(declaredClass)) {
|
serializersByType.computeIfAbsent(declaredType) {
|
||||||
serializersByType.computeIfAbsent(declaredType) {
|
CollectionSerializer(declaredType as? ParameterizedType ?: DeserializedParameterizedType(
|
||||||
CollectionSerializer(declaredType as? ParameterizedType ?: DeserializedParameterizedType(
|
declaredClass, arrayOf(AnyType), null), this)
|
||||||
declaredClass, arrayOf(AnyType), null), this)
|
|
||||||
}
|
|
||||||
} else if (Map::class.java.isAssignableFrom(declaredClass)) {
|
|
||||||
serializersByType.computeIfAbsent(declaredClass) {
|
|
||||||
makeMapSerializer(declaredType as? ParameterizedType ?: DeserializedParameterizedType(
|
|
||||||
declaredClass, arrayOf(AnyType, AnyType), null))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
makeClassSerializer(actualClass ?: declaredClass, actualType, declaredType)
|
|
||||||
}
|
}
|
||||||
|
} else if (Map::class.java.isAssignableFrom(declaredClass)) {
|
||||||
|
serializersByType.computeIfAbsent(declaredClass) {
|
||||||
|
makeMapSerializer(declaredType as? ParameterizedType ?: DeserializedParameterizedType(
|
||||||
|
declaredClass, arrayOf(AnyType, AnyType), null))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
makeClassSerializer(actualClass ?: declaredClass, actualType, declaredType)
|
||||||
}
|
}
|
||||||
|
|
||||||
serializersByDescriptor.putIfAbsent(rtn.typeDescriptor, rtn)
|
serializersByDescriptor.putIfAbsent(serializer.typeDescriptor, serializer)
|
||||||
|
|
||||||
return rtn
|
return serializer
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -219,24 +217,24 @@ class SerializerFactory(val whitelist: ClassWhitelist = AllWhitelist) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun makeClassSerializer(clazz: Class<*>, type: Type, declaredType: Type): AMQPSerializer<Any> = serializersByType.computeIfAbsent(type) {
|
private fun makeClassSerializer(clazz: Class<*>, type: Type, declaredType: Type): AMQPSerializer<Any> = serializersByType.computeIfAbsent(type) {
|
||||||
if (isPrimitive(clazz)) {
|
if (isPrimitive(clazz)) {
|
||||||
AMQPPrimitiveSerializer(clazz)
|
AMQPPrimitiveSerializer(clazz)
|
||||||
} else {
|
} else {
|
||||||
findCustomSerializer(clazz, declaredType) ?: run {
|
findCustomSerializer(clazz, declaredType) ?: run {
|
||||||
if (type.isArray()) {
|
if (type.isArray()) {
|
||||||
whitelisted(type.componentType())
|
whitelisted(type.componentType())
|
||||||
if (clazz.componentType.isPrimitive) PrimArraySerializer.make(type, this)
|
if (clazz.componentType.isPrimitive) PrimArraySerializer.make(type, this)
|
||||||
else ArraySerializer.make(type, this)
|
else ArraySerializer.make(type, this)
|
||||||
} else if (clazz.kotlin.objectInstance != null) {
|
} else if (clazz.kotlin.objectInstance != null) {
|
||||||
whitelisted(clazz)
|
whitelisted(clazz)
|
||||||
SingletonSerializer(clazz, clazz.kotlin.objectInstance!!, this)
|
SingletonSerializer(clazz, clazz.kotlin.objectInstance!!, this)
|
||||||
} else {
|
} else {
|
||||||
whitelisted(type)
|
whitelisted(type)
|
||||||
ObjectSerializer(type, this)
|
ObjectSerializer(type, this)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal fun findCustomSerializer(clazz: Class<*>, declaredType: Type): AMQPSerializer<Any>? {
|
internal fun findCustomSerializer(clazz: Class<*>, declaredType: Type): AMQPSerializer<Any>? {
|
||||||
// e.g. Imagine if we provided a Map serializer this way, then it won't work if the declared type is AbstractMap, only Map.
|
// e.g. Imagine if we provided a Map serializer this way, then it won't work if the declared type is AbstractMap, only Map.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user