mirror of
https://github.com/corda/corda.git
synced 2024-12-19 04:57:58 +00:00
Minor: reformat SerializerFactory.kt
This commit is contained in:
parent
040de41e27
commit
b3433c2a46
@ -145,9 +145,11 @@ open class SerializerFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Enum::class.java.isAssignableFrom(actualClass ?: declaredClass) -> {
|
Enum::class.java.isAssignableFrom(actualClass ?: declaredClass) -> {
|
||||||
logger.info("class=[${actualClass?.simpleName} | $declaredClass] is an enumeration "
|
logger.trace {
|
||||||
+ "declaredType=${declaredType.typeName} "
|
"class=[${actualClass?.simpleName} | $declaredClass] is an enumeration " +
|
||||||
+ "isEnum=${declaredType::class.java.isEnum}")
|
"declaredType=${declaredType.typeName} " +
|
||||||
|
"isEnum=${declaredType::class.java.isEnum}"
|
||||||
|
}
|
||||||
|
|
||||||
serializersByType.computeIfAbsent(actualClass ?: declaredClass) {
|
serializersByType.computeIfAbsent(actualClass ?: declaredClass) {
|
||||||
whitelist.requireWhitelisted(actualType)
|
whitelist.requireWhitelisted(actualType)
|
||||||
@ -255,7 +257,7 @@ open class SerializerFactory(
|
|||||||
* that expects to find getters and a constructor with a parameter for each property.
|
* that expects to find getters and a constructor with a parameter for each property.
|
||||||
*/
|
*/
|
||||||
open fun register(customSerializer: CustomSerializer<out Any>) {
|
open fun register(customSerializer: CustomSerializer<out Any>) {
|
||||||
logger.info ("action=\"Registering custom serializer\", class=\"${customSerializer.type}\"")
|
logger.trace("action=\"Registering custom serializer\", class=\"${customSerializer.type}\"")
|
||||||
if (!serializersByDescriptor.containsKey(customSerializer.typeDescriptor)) {
|
if (!serializersByDescriptor.containsKey(customSerializer.typeDescriptor)) {
|
||||||
customSerializers += customSerializer
|
customSerializers += customSerializer
|
||||||
serializersByDescriptor[customSerializer.typeDescriptor] = customSerializer
|
serializersByDescriptor[customSerializer.typeDescriptor] = customSerializer
|
||||||
@ -266,7 +268,7 @@ open class SerializerFactory(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun registerExternal(customSerializer: CorDappCustomSerializer) {
|
fun registerExternal(customSerializer: CorDappCustomSerializer) {
|
||||||
logger.info ("action=\"Registering external serializer\", class=\"${customSerializer.type}\"")
|
logger.trace("action=\"Registering external serializer\", class=\"${customSerializer.type}\"")
|
||||||
if (!serializersByDescriptor.containsKey(customSerializer.typeDescriptor)) {
|
if (!serializersByDescriptor.containsKey(customSerializer.typeDescriptor)) {
|
||||||
customSerializers += customSerializer
|
customSerializers += customSerializer
|
||||||
serializersByDescriptor[customSerializer.typeDescriptor] = customSerializer
|
serializersByDescriptor[customSerializer.typeDescriptor] = customSerializer
|
||||||
@ -280,14 +282,14 @@ open class SerializerFactory(
|
|||||||
private fun processSchema(schemaAndDescriptor: FactorySchemaAndDescriptor, sentinel: Boolean = false) {
|
private fun processSchema(schemaAndDescriptor: FactorySchemaAndDescriptor, sentinel: Boolean = false) {
|
||||||
val metaSchema = CarpenterMetaSchema.newInstance()
|
val metaSchema = CarpenterMetaSchema.newInstance()
|
||||||
for (typeNotation in schemaAndDescriptor.schemas.schema.types) {
|
for (typeNotation in schemaAndDescriptor.schemas.schema.types) {
|
||||||
logger.debug { "descriptor=${schemaAndDescriptor.typeDescriptor}, typeNotation=${typeNotation.name}" }
|
logger.trace { "descriptor=${schemaAndDescriptor.typeDescriptor}, typeNotation=${typeNotation.name}" }
|
||||||
try {
|
try {
|
||||||
val serialiser = processSchemaEntry(typeNotation)
|
val serialiser = processSchemaEntry(typeNotation)
|
||||||
// if we just successfully built a serializer for the type but the type fingerprint
|
// if we just successfully built a serializer for the type but the type fingerprint
|
||||||
// doesn't match that of the serialised object then we are dealing with different
|
// doesn't match that of the serialised object then we are dealing with different
|
||||||
// instance of the class, as such we need to build an EvolutionSerializer
|
// instance of the class, as such we need to build an EvolutionSerializer
|
||||||
if (serialiser.typeDescriptor != typeNotation.descriptor.name) {
|
if (serialiser.typeDescriptor != typeNotation.descriptor.name) {
|
||||||
logger.info("typeNotation=${typeNotation.name} action=\"requires Evolution\"")
|
logger.trace { "typeNotation=${typeNotation.name} action=\"requires Evolution\"" }
|
||||||
getEvolutionSerializer(typeNotation, serialiser, schemaAndDescriptor.schemas)
|
getEvolutionSerializer(typeNotation, serialiser, schemaAndDescriptor.schemas)
|
||||||
}
|
}
|
||||||
} catch (e: ClassNotFoundException) {
|
} catch (e: ClassNotFoundException) {
|
||||||
@ -296,7 +298,7 @@ open class SerializerFactory(
|
|||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.info("typeNotation=\"${typeNotation.name}\" action=\"carpentry required\"")
|
logger.trace { "typeNotation=\"${typeNotation.name}\" action=\"carpentry required\"" }
|
||||||
}
|
}
|
||||||
metaSchema.buildFor(typeNotation, classloader)
|
metaSchema.buildFor(typeNotation, classloader)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user