399 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
-1
votes
0
answers
100
views
Trying to parse XML string from OkHttp in Jackson to a kotlin data class. Don't understand how to translate xml structure to kotlin class?
I have an XML string that contains the following (bus data):
<Siri xmlns="http://www.siri.org.uk/siri" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0&...
1
vote
2
answers
141
views
How to represent the changes to an instance of a data class (diff)?
I maintain an application which helps users to track the progress of an activity in real time. In essence, we represent the state of said activity as a data class in the Android mobile app. Every time ...
2
votes
2
answers
115
views
How to de-structure a data class with private property in Kotlin?
When a data class has a private property, destructing syntax do not work.
For example, consider this data class
data class Product(
private val id: Int,
val name: String,
val description: ...
2
votes
1
answer
68
views
Kotlin data class with default constructor parameter
I want to use a data class with a property that has a default value in the constructor based on another constructor parameter. It works exactly as I want it if I use a normal (non-data) class:
import ...
2
votes
2
answers
96
views
How to change in place the values of a data class object through an iteration, Kotlin
I am looking for a way, without having to install a new library, to iterate through a Kotlin data class and to change the values according to their type.
The implementation I would like is the ...
1
vote
1
answer
123
views
Is it problematic to derive a default value of a member from other members in a data class?
I have a data class like this:
data class Calculation(
val calculationType: String = "Multiplication", // or "Division"
val firstOperand: Int,
val secondOperand: Int,
...
0
votes
1
answer
49
views
String interpolation returning unexpected result
I have a data class Shift:
@Serializable
data class Shift(
@SerialName("id") val id: String,
@SerialName("username") val username: String,
@SerialName("start")...
0
votes
3
answers
143
views
How to make data class copy with only properties initialized, to avoid StackOverflowError?
I have encountered a problem while trying to resolve problem with sensitive info in application logs — we have quite large data class object that at some time in processing flow we log. Problem is ...
user avatar
user25583367
3
votes
2
answers
2k
views
How do you animate the insertion of an item into a list?
I've developed a simple Android application where you can insert new items into a list on a button press. New items pop up instantly, it looks sloppy. I've tried to animate their insertion, but it's ...
-1
votes
1
answer
543
views
dataclasses for ORM models in SQLAlchemy
I am trying to define a dataclass for my model in the same class of the model, where i have defined the table.
this is my model class,
from dataclasses import dataclass, field
from sqlalchemy import ...
0
votes
1
answer
48
views
TextField keystrokes are not appearing when using a data class to hold the value and onValueChange parameters of the TextField
I'm trying to create multiple instances of the same TextField by iterating through them in a list rather than directly creating each instance. The problem is that none of the keystrokes are appearing ...
1
vote
2
answers
252
views
Pydanyic V2: how to write more intelligent `created_at`, `updated_at` fields
I wanna write a nice TimestampMixin class for my project, I hope it can:
created_at: autonow when creation, and never change since that
updated_at: autonow when creation
updated_at: auto update ...
1
vote
3
answers
683
views
How do you change data class variable values with outside functions in Jetpack Compose?
I'm trying to structure a simple application in a way that makes it easier to refactor by importing all values into a composable using data classes.
All the values are passed through successfully. ...
1
vote
0
answers
28
views
Getting right order of `declaredMemberProperties` in a `listOf<Any>` [duplicate]
Edit: The "already answered answer" doesn't get me the values of the data class object. I can only access the field name and the order id, but NOT the value (here "0", "A"...
0
votes
1
answer
289
views
Access a Data Class Variable that's Being Stored in List - Kotlin
I have a data class which takes in A LOT of variables. The object of this class is then stored in a mutable list. How do I search for the object that contains a specific user entered value and then ...