mirror of
https://github.com/fankes/moshi.git
synced 2025-10-19 16:09:21 +08:00
Omit adapter field names now that we directly instantiate annotations (#1436)
This commit is contained in:
@@ -270,8 +270,7 @@ public class AdapterGenerator(
|
|||||||
uniqueAdapter.delegateKey.generateProperty(
|
uniqueAdapter.delegateKey.generateProperty(
|
||||||
nameAllocator,
|
nameAllocator,
|
||||||
typeRenderer,
|
typeRenderer,
|
||||||
moshiParam,
|
moshiParam
|
||||||
uniqueAdapter.name
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -45,8 +45,7 @@ public data class DelegateKey(
|
|||||||
internal fun generateProperty(
|
internal fun generateProperty(
|
||||||
nameAllocator: NameAllocator,
|
nameAllocator: NameAllocator,
|
||||||
typeRenderer: TypeRenderer,
|
typeRenderer: TypeRenderer,
|
||||||
moshiParameter: ParameterSpec,
|
moshiParameter: ParameterSpec
|
||||||
propertyName: String
|
|
||||||
): PropertySpec {
|
): PropertySpec {
|
||||||
val qualifierNames = jsonQualifiers.joinToString("") {
|
val qualifierNames = jsonQualifiers.joinToString("") {
|
||||||
"At${it.typeName.rawType().simpleName}"
|
"At${it.typeName.rawType().simpleName}"
|
||||||
@@ -68,10 +67,10 @@ public data class DelegateKey(
|
|||||||
", setOf(%L)" to arrayOf(jsonQualifiers.map { it.asInstantiationExpression() }.joinToCode())
|
", setOf(%L)" to arrayOf(jsonQualifiers.map { it.asInstantiationExpression() }.joinToCode())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val finalArgs = arrayOf(*standardArgs, *args, propertyName)
|
val finalArgs = arrayOf(*standardArgs, *args)
|
||||||
|
|
||||||
return PropertySpec.builder(adapterName, adapterTypeName, KModifier.PRIVATE)
|
return PropertySpec.builder(adapterName, adapterTypeName, KModifier.PRIVATE)
|
||||||
.initializer("%N.adapter(%L$initializerString, %S)", *finalArgs)
|
.initializer("%N.adapter(%L$initializerString)", *finalArgs)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -109,7 +109,10 @@ public final class Moshi {
|
|||||||
/**
|
/**
|
||||||
* @param fieldName An optional field name associated with this type. The field name is used as a
|
* @param fieldName An optional field name associated with this type. The field name is used as a
|
||||||
* hint for better adapter lookup error messages for nested structures.
|
* hint for better adapter lookup error messages for nested structures.
|
||||||
|
* @deprecated this is no longer needed in Kotlin 1.6.0 (which has direct annotation
|
||||||
|
* instantiation) and should no longer be used.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
@CheckReturnValue
|
@CheckReturnValue
|
||||||
@SuppressWarnings("unchecked") // Factories are required to return only matching JsonAdapters.
|
@SuppressWarnings("unchecked") // Factories are required to return only matching JsonAdapters.
|
||||||
public <T> JsonAdapter<T> adapter(
|
public <T> JsonAdapter<T> adapter(
|
||||||
|
Reference in New Issue
Block a user