Conversation
oschwald
left a comment
There was a problem hiding this comment.
I had one specific comment. I also wonder if some of these would be clearer as var.
| List<String> innerIPs = new ArrayList<>(); | ||
| while(networks.hasNext()){ | ||
| DatabaseRecord<Map<String,String>> iteration = networks.next(); | ||
| DatabaseRecord<?> iteration = networks.next(); |
There was a problem hiding this comment.
Why was this and the other ones that had specific types changed?
There was a problem hiding this comment.
Short answer: to avoid compiler warnings.
Long answer:
DatabaseRecordis<?>here becauseNetworksis<?>.Networks#next()returnsDatabaseRecord<T>, soiterationhas to use the same type parameter. Otherwise we get either a raw type or unchecked cast warning.Networks<?>is the only way to avoid raw type or unchecked cast warnings. The issue here is thatMap.classhas typeClass<Map>. ThereforeReader#networksWithinreturnNetworks<Map>which gives a raw type warning,Networks<?>avoids the warning. I'm not aware of a way to get aClass<Map<?, ?>>orClass<Map<String, String>>without a unchecked cast or raw type warning.
I had a look and added a second commit to use
Let me know what you think. |
oschwald
left a comment
There was a problem hiding this comment.
Thanks for the explanations! In regards to var, the primary reason it isn't used more widely is that this code is old and we only dropped Java 8 support a couple of years ago. I realize its usage can be a bit contentious among Java programmers.
No description provided.