Skip to content
Advertisement

Tag: type-erasure

Why java lets me add a Box(Raw type) to a List<Box>

This code works, and I dont understand how the list is able to add a raw type box, I thought type erasure will set the type to their indicated bounds. note: Paper class doesn’t extends Bakery class. EDIT: Is my understanding correct? the compiler typecasts the raw box type so that it can be added to the list? does this

Custom Jackson Deserialization of a Generic Abstract class

I am having issues when trying to deserializing the following class: My generic abstract class: I have two concrete classes which implement MetricValueDto: IntMetricValueDto: FloatMetricValueDto: Any idea of what’s the correct strategy to deserialize MetricValueDto so I can parse it through ObjectMapper or an RestTemplate? Whenever I run: I get Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of com.resson.dto.MetricValueDto: abstract

Java erasure with generic overloading (not overriding)

I have FinanceRequests and CommisionTransactions in my domain. If I have a list of FinanceRequests each FinanceRequest could contain multiple CommisionTransactions that need to be clawed back. Dont worry how exactly that is done. The class below (very bottom) makes me feel all fuzzy and warm since its succint and reuses existing code nicely. One problem Type erasure. They both

Advertisement