I am employing mapstruct to map between my network and database data objects within my current Android project.
api 'org.mapstruct:mapstruct:1.5.2.Final'
kapt 'org.mapstruct:mapstruct-processor:1.5.2.Final'
my network data class resembles this
@Keep
@Serializable
data class Item(
@SerialName("actionTested")
val actionTested: String? = null,
@SerialName("agonistAntagonist")
val agonistAntagonist: String = "",
@SerialName("cellOrigin")
val cellOrigin: String? = null,
@SerialName("cmmnt")
val comment: String? = null,
@SerialName("displayDose")
val displayDose: String = "",
@SerialName("displayValue")
val displayValue: String = "",
@SerialName("document")
val document: Document = Document(),
@SerialName("documentYear")
val documentYear: Int = 0,
@SerialName("dose")
val dose: String = "",
@SerialName("doseUnit")
val doseUnit: String? = null,
@SerialName("drug")
val drug: String = "",
@SerialName("errorType")
val errorType: String? = null,
@SerialName("errorValue")
val errorValue: String? = null,
@SerialName("experimentType")
val experimentType: String? = null,
@SerialName("hash")
val hash: String = "",
@SerialName("id")
val id: String = "",
@SerialName("isPrimaryTarget")
val isPrimaryTarget: String? = null,
@SerialName("mutationDetail")
val mutationDetail: String? = null,
@SerialName("otherExpDetails")
val otherExpDetails: String? = null,
@SerialName("parameter")
val parameter: String = "",
@SerialName("sharpN")
val sharpN: String? = null,
@SerialName("smiles")
val smiles: String? = null,
@SerialName("source")
val source: String = "",
@SerialName("specie")
val specie: String = "",
@SerialName("strainRace")
val strainRace: String? = null,
@SerialName("studyType")
val studyType: String = "",
@SerialName("target")
val target: String = "",
@SerialName("targetType")
val targetType: String = "",
@SerialName("testSystem")
val testSystem: String = "",
@SerialName("transfection")
val transfection: String = "",
@SerialName("unitNormalized")
val unitNormalized: String? = null,
@SerialName("unitOriginal")
val unitOriginal: String? = null,
@SerialName("valueNormalized")
val valueNormalized: String = "",
@SerialName("valueOriginal")
val valueOriginal: String = ""
)
My database data object resembles this
data class ActivitySearchItemDO(
@ColumnInfo(name = "action_tested") val actionTested: String?,
@ColumnInfo(name = "agonist_antagonist") val agonistAntagonist: String,
@ColumnInfo(name = "cell_origin") val cellOrigin: String?,
@ColumnInfo(name = "comment") val comment: String?,
@ColumnInfo(name = "display_dose") val displayDose: String,
@ColumnInfo(name = "display_value") val displayValue: String,
@ColumnInfo(name = "document") val document: DocumentVO,
@ColumnInfo(name = "document_year") val documentYear: Int,
@ColumnInfo(name = "dose") val dose: String,
@ColumnInfo(name = "dose_unit") val doseUnit: String?,
@ColumnInfo(name = "drug") val drug: String,
@ColumnInfo(name = "error_type") val errorType: String?,
@ColumnInfo(name = "error_value") val errorValue: String?,
@ColumnInfo(name = "experiment_type") val experimentType: String?,
@ColumnInfo(name = "hash") val hash: String,
@ColumnInfo(name = "id") val id: String,
@ColumnInfo(name = "is_primary_target") val isPrimaryTarget: String? = null,
@ColumnInfo(name = "mutation_detail") val mutationDetail: String?,
@ColumnInfo(name = "other_exp_details") val otherExpDetails: String?,
@ColumnInfo(name = "parameter") val parameter: String,
@ColumnInfo(name = "sharp_N") val sharpN: String?,
@ColumnInfo(name = "smiles") val smiles: String?,
@ColumnInfo(name = "source") val source: String,
@ColumnInfo(name = "specie") val specie: String,
@ColumnInfo(name = "strain_race") val strainRace: String?,
@ColumnInfo(name = "study_type") val studyType: String,
@ColumnInfo(name = "target") val target: String,
@ColumnInfo(name = "target_type") val targetType: String,
@ColumnInfo(name = "test_system") val testSystem: String,
@ColumnInfo(name = "transfection") val transfection: String,
@ColumnInfo(name = "unit_normalized") val unitNormalized: String?,
@ColumnInfo(name = "unit_original") val unitOriginal: String?,
@ColumnInfo(name = "value_normalized") val valueNormalized: String,
@ColumnInfo(name = "value_original") val valueOriginal: String
)
when i build my project i get the following warning and do not understand why
warning: Unmapped target property: "isPrimaryTarget".
public abstract com.myapp.model.database.ActivitySearchItemDO map(@org.jetbrains.annotations.NotNull()
my mapper resembles this
@InheritInverseConfiguration(name = "map")
fun map(dataFields: Item): ActivitySearchItemDO
why is mapstruct reporting that the isPrimaryTarget is not being mapped?
UPDATE
it appears to be the "is" prefix that is causing the issue, when i remove is from the variable names it maps ok. which i am happy with as this field is not a boolean type but a String.
however i now have another case that is boolean and its generating a similar warning. why does mapstruct have an issue when mapping boolean fields.