I have the following classes defined:
enum FruitTypeEnum {
APPLE,
BANANA,
NONE
}
// POGO
class FruitDTO {
FruitTypeEnum fruitType
}
// Hibernate Entity
abstract class Farm {
FruitTypeEnum fruitType
}
private getFruitDTO(Farm farm) {
def fruitDTO = new FruitDTO()
fruitDTO.fruitType = farm.fruitType
fruitDTO
}
When I attempt to execute the getFruitDTO function, 50% of the time the assignment fruitDTO.fruitType = farm.fruitType throws the following exception:
java.lang.IllegalArgumentException: java.lang.ClassCastException@564a5444
at FarmController.getFruitDTO(FarmController.groovy:126)
I have attached the debugger and verified that the left hand side and the right hand side of the assignment are both the same datatype. So how am I getting a ClassCastException?