0
我在Grails项目中有一个位于src/java中的枚举文件。在Grails中动态改变src/java文件中的枚举值
此枚举具有在代码上定义的值,我可以动态更改此值吗?
public enum Status
{
value_one, value_two, value_three;
public String getOtherString()
{
switch (this)
{
case value_one:
return "value one";
case value_two:
return "value two";
case value_three:
return "value three";
default:
return "problem";
}
}
@Override
public String toString()
{
switch (this)
{
case value_one:
return "VALUE 1";
case value_two:
return "VALUE 2";
case value_three:
return "VALUE 3";
default:
return "problem happens";
}
}
}
你究竟想要改变什么?添加/删除一个新的枚举?更改枚举名称?改变toString()的响应?改变getOtherString()的响应? – 2012-08-07 13:27:25
我要改变字符串的响应与数据库的东西,像这样: '情况value_one: 回报MyDomain.getValueOne();' 这样,我有一个名为MYDOMAIN域其中有一些atributes是可以改变的在数据库上。 – 2012-08-07 13:30:54