Page 1 of 1

Casting Object to EnumerationLiteral

PostPosted: Mon Jul 22, 2019 4:25 am
by amra.ramic@siemens.com
Hello everyone,

the method of the class PropertyChangeEvent getOldValue() is returning an object. The problem that I have is to cast this object into any other, in this case into EnumerationLiteral, class.
Here is a part of my code:
public void adjustValueOfFailureToFailureRate(PropertyChangeEvent evt) {
if(evt.getSource() instanceof Property) {
Property property = (Property) evt.getSource();

EnumerationLiteral old = (EnumerationLiteral) evt.getOldValue();
String oldLambda = CftRetrieval.getLambda((Property)old);

I have also tried to cast in other classes like StringLiteral or just Property, but I always get the same error that the object can not be casted.
Can someone help?