Archived
This forum has been archived. Please start a new discussion on GitHub.
Java: going from String to Enum Type
In Java:
I have an ice interface that contains enum declarations.
Does ICE generate a class/method where I can convert a String of enum value, so that I can assign the converted value to the member variable of the same enum type?
Currently I have to do it this way
i.e
enum EmployeePaidType { salary, hourly };
EmployeePaidType myEmployeePaidType;
if( "salary".equals(paidType) )
myEmployeePaidType = EmployeePaidType.salary;
else if( "hourly".equals(paidType) )
myEmployeePaidType = EmployeePaidType.hourly;
I am using ICE 3.0.1 on Windows XP
I have an ice interface that contains enum declarations.
Does ICE generate a class/method where I can convert a String of enum value, so that I can assign the converted value to the member variable of the same enum type?
Currently I have to do it this way
i.e
enum EmployeePaidType { salary, hourly };
EmployeePaidType myEmployeePaidType;
if( "salary".equals(paidType) )
myEmployeePaidType = EmployeePaidType.salary;
else if( "hourly".equals(paidType) )
myEmployeePaidType = EmployeePaidType.hourly;
I am using ICE 3.0.1 on Windows XP
0
Comments
-
Hi David,
I'm afraid there isn't a more convenient way to perform this conversion.
Take care,
- Mark0 -
It would seem that this should be a standard for the generated code.
Also it would be nice to have the size be public accessible by variable or getter.0