I have am android project I took over that that mixes Kotlin and Java, and I'm going through and converting all the Kotlin to Java, since our teams knows Java. The problem I'm running into is "Raw use of parameterized class 'ArrayList'. I can't figure out what class I'm supposed to pass to ArrayList<?> to get rid of the warning.
Here is my code:
ArrayList amenities = new ArrayList<>();
amenities.add(MapsKt.hashMapOf(
TuplesKt.to("ID", q.amenityID),
TuplesKt.to("bExists", q.getAnswer().equals("1")),
TuplesKt.to("Notes", Utils.CleanStringForUpload(q.amenityNotes))
));
Sounds like List<Map<String, Object>> - the list contains maps (you're adding the result of invoking hashMapOf.
That map, then, seems to map Strings, such as ID, to a grab bag of weird stuff. This is a code smell and something that needs a refactor sooner rather than later - why don't you have something like:
class WhateverThisMightBe {
String id;
boolean exists;
String notesHtml;
}
and then have a List<WhateverThisMightBe> instead? That is idiomatic java/kotlin. a List<Map<String, Object>> is trying to reinvent javascript/PHP in a very cruddy fashion in java. Not a good idea.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With