У меня есть следующий класс
data class ExtraAttributeFlatGroupEntity(
@ColumnInfo(name = ID)
@SerializedName(ID)
val id: Int,
@ColumnInfo(name = TYPE)
@SerializedName(TYPE)
val type: String,
@ColumnInfo(name = NAME_AR)
@SerializedName(NAME_AR)
val nameAr: String,
@ColumnInfo(name = NAME_EN)
@SerializedName(NAME_EN)
val nameEn: String,
@ColumnInfo(name = SYSTEM_NAME)
@SerializedName(SYSTEM_NAME)
val systemName: String,
@ColumnInfo(name = IS_REQUIRED)
@SerializedName(IS_REQUIRED)
val isRequired: Int,
@ColumnInfo(name = DISPLAY_ORDER)
@SerializedName(DISPLAY_ORDER)
val displayOrder: Int,
@ColumnInfo(name = MIN)
@SerializedName(MIN)
val min: Int,
@ColumnInfo(name = MAX)
@SerializedName(MAX)
val max: Int,
@ColumnInfo(name = VALIDATE_MIN)
@SerializedName(VALIDATE_MIN)
val validateMin: Int,
@ColumnInfo(name = VALIDATE_MAX)
@SerializedName(VALIDATE_MAX)
val validateMax: Int,
@ColumnInfo(name = SLIDER_STEPS)
@SerializedName(SLIDER_STEPS)
val sliderSteps: Int?,
@ColumnInfo(name = IS_INT)
@SerializedName(IS_INT)
val isInt: Int,
@ColumnInfo(name = IMAGE)
@SerializedName(IMAGE)
val image: String,
@ColumnInfo(name = EXTRA_ATTRIBUTE_GROUP_ID)
@SerializedName(EXTRA_ATTRIBUTE_GROUP_ID)
val extraAttributeGroupId: Int?,
@ColumnInfo(name = SUB_TYPE)
@SerializedName(SUB_TYPE)
val subType: String?,
@ColumnInfo(name = SCOPE)
@SerializedName(SCOPE)
val scope: String,
@ColumnInfo(name = GROUP_ID)
@SerializedName(GROUP_ID)
val groupId: Int,
@ColumnInfo(name = GROUP_NAME_AR)
@SerializedName(GROUP_NAME_AR)
val groupNameAr: String,
@ColumnInfo(name = GROUP_NAME_EN)
@SerializedName(GROUP_NAME_EN)
val groupNameEn: String,
@ColumnInfo(name = GROUP_DISPLAY_ORDER)
@SerializedName(GROUP_DISPLAY_ORDER)
val groupDisplayOrder: Int
) {
companion object {
const val EXTRA_ATTRIBUTES_FLAT_GROUP_TABLE = "extra_attributes_flat_group"
const val ID = "id"
const val NAME_AR = "name_ar"
const val NAME_EN = "name_en"
const val SYSTEM_NAME = "system_name"
const val REGION_ID = "region_id"
const val DISPLAY_ORDER = "display_order"
const val IMAGE = "image"
const val TYPE = "type"
const val IS_REQUIRED = "is_required"
const val MIN = "min"
const val MAX = "max"
const val VALIDATE_MIN = "validate_min"
const val VALIDATE_MAX = "validate_max"
const val SLIDER_STEPS = "slider_steps"
const val IS_INT = "is_int"
const val EXTRA_ATTRIBUTE_GROUP_ID = "extra_attribute_group_id"
const val SUB_TYPE = "sub_type"
const val SCOPE = "scope"
const val IS_ACTIVE = "is_active"
const val GROUP_ID = "group_id"
const val GROUP_NAME_AR = "group_name_ar"
const val GROUP_NAME_EN = "group_name_en"
const val GROUP_DISPLAY_ORDER = "group_display_order"
}
}
Он объединяет результаты из двух таблиц и заполняется запросом SQLite из двух таблиц
Мне нужно преобразовать это в отображение группы какключ и список элементов внутри него или даже простой объект, такой как
data class AttributeGroup(
val attributeGroup: ExtraAttributeGroupEntity,
val attributes: List<ExtraAttributeEntity>
)
Класс ExtraAttributeGroupEntity похож на
data class ExtraAttributeGroupEntity(
@PrimaryKey()
@ColumnInfo(name = ID)
@SerializedName(ID)
var id: Int,
@ColumnInfo(name = NAME_EN)
@SerializedName(NAME_EN)
val nameEn: String,
@ColumnInfo(name = NAME_AR)
@SerializedName(NAME_AR)
val nameAr: String,
@ColumnInfo(name = DISPLAY_ORDER)
@SerializedName(DISPLAY_ORDER)
val displayOrder: Int
) {}
А другой класс имеет другие значения