Questions tagged [data-class]

Refers to data classes feature in Kotlin programming language.

380 questions
0
votes
1 answer

Kotlin data class and 30+ attributes

how do we create data classes in kotlin , where the class contains more than 25+ attributes. Use case is there is a class in java which has more than 25+ attributes and is needed to be converted to kotlin data class, morever the question would be…
chetank
  • 392
  • 3
  • 17
0
votes
1 answer

Is there a better way other than setting data class constructor values to null if its possible the data cannot be set

I have a situation whereby I am creating a rest client in kotlin as a practical learning exercise and have recently come up against this: data class ai constructor(val statusCode: Int, val a: Long?…
user1383163
  • 577
  • 1
  • 7
  • 24
0
votes
1 answer

How to hash data class with array property

I have data class ItemMainData(val title: String?, val fields: Array). What's the proper way to override hashCode()? I am aware of this answer (Equals method for data class in kotlin), but in that case the hash of the array is sufficient to…
Jack Guo
  • 3,959
  • 8
  • 39
  • 60
0
votes
1 answer

Kotlin data class definition is not in roundEnv.rootElements (annotation processing)

Inside an annotation processor that extends AbstractProcessor I have: override fun process(annotations: MutableSet, roundEnv: RoundEnvironment): Boolean { roundEnv.getElementsAnnotatedWith(FxBean::class.java) .forEach { …
Vitaly
  • 4,358
  • 7
  • 47
  • 59
0
votes
1 answer

copy/map json/data class structure in kotlin

I am newbie in kotlin and I try to copy a JSON structure to another one in an efficient way. I have an API called getData() how send back a data structure defined as below: data class DataA( var id: String, var cartItems: List,…
Seb
  • 2,929
  • 4
  • 30
  • 73
0
votes
1 answer

How to transition Java class to Kotlin Data Class

I used Android studio's Kotlin plugin to convert my Java class to Kotlin. The thing is it's not Kotlin style still. I want to have Kotlin Data Class instead. But whenever I create it with a primary and secondary constructors it won't work. What…
MikeB
  • 257
  • 1
  • 4
  • 15
0
votes
1 answer

Companion objects hide class -- bug or feature?

In Kotlin, the following seems to be reasonable code: data class Foo(val bar: String) { fun combine(other: Foo): Foo { return Foo(bar + other.bar) } companion object Foo { fun someHelper() {} } } However, it does…
Raphael
  • 9,779
  • 5
  • 63
  • 94
0
votes
0 answers

COM accessible data class c#

My COM interface: [ComVisible(true)] public interface IPersonAccessor { Person GetById(int id); } The Person Class is a simple data class as below: public class Person { public string Name { get; set; } public int Age { get; set;…
Victor Mukherjee
  • 10,487
  • 16
  • 54
  • 97
0
votes
1 answer

Copy input into different cells with jQuery and data-class

Multiple tables contain data in cells. If I change the data in a cell, they should also be changed in the same cell in other tables. ...
Severin
  • 183
  • 2
  • 15
-1
votes
1 answer

What is the best way to add information to a data class returned by a function without breaking existing code?

Here is my code:: data class User(val id: Int, name: String) fun getUsers(): List Now, I want to add an age field to the User data class, but I'm concerned about two things: Breaking the code that already using User. Loading memory with…
David Lev
  • 11
  • 3
-1
votes
1 answer

kotlin data class property not in equals method

example: data class Test(val name: String, val age: Int) val a = Test("a", 21) val b = Test("b", 31) val result = a == b // false want result return true, what to do?
tao xu
  • 11
  • 1
-1
votes
1 answer

Data class for API response structure?

I am using wikipedia API whose response structure is as { "batchcomplete": "", "continue": { "gpsoffset": 10, "continue": "gpsoffset||" }, "query": { "pages": { "27667": { "pageid": 27667, "ns": 0, "title": "Space", "index":…
WISHY
  • 11,067
  • 25
  • 105
  • 197
-1
votes
1 answer

how print the top sport by distance excluding eBikes in kotlin?

I want to print top sport by distance excluding eBikes in kotlin how can I achieve that below my Kotlin classes enum class Sport { HIKE, RUN, TOURING_BICYCLE, E_TOURING_BICYCLE } data class Summary(val sport: Sport, val distance: Int) fun main()…
Hacker One
  • 11
  • 5
-1
votes
1 answer

Convert attributes from one data class to another data class (subclasses)

hello) . Need some help.I know how to transfer data from A class to B class, but i dont know how to transfer data from subclass A.A1 - which included A class, to subclass B.B1 which included B class. My A class: data class SpaceXProperty( val …
bboy
  • 55
  • 5
-1
votes
4 answers

Text in button is not displayed

This is the class data class Crime( val id:UUID=UUID.randomUUID(), var title:String="", var date: Date= Date(), var isSolved:Boolean=false) I want to display current date as a text in button.(Below is the layout for button)
1 2 3
25
26