java – Spring roo,field枚举

我是 Spring MVC和 Spring Roo的新手.

什么是字段枚举?

如何枚举所有允许的值?

它是使用查找表还是检查约束来实现?

解决方法

Roo的字段枚举–fieldName –type命令添加指定枚举类型的私有字段.

您可以手动创建枚举类型或使用roo命令:

roo> enum type --class ~.domain.Colors
roo> enum constant --name BLAU
roo> enum constant --name VERMELL

这将创建一个颜色枚举:

public Enum Colors {
  BLAU,VERMELL
}

然后可以使用枚举类型来定义实体字段:

roo> entity --class ~.domain.Foo
roo> field enum --fieldName color --type ~.domain.Colors

这将定义Foo实体:

//Annotations and imports ommited for brevity
public class Foo{
     private Colors color;
}

有关roo命令的完整参考,请参见http://static.springsource.org/spring-roo/reference/html/command-index.html.

相关文章

最近看了一下学习资料,感觉进制转换其实还是挺有意思的,尤...
/*HashSet 基本操作 * --set:元素是无序的,存入和取出顺序不...
/*list 基本操作 * * List a=new List(); * 增 * a.add(inde...
/* * 内部类 * */ 1 class OutClass{ 2 //定义外部类的成员变...
集合的操作Iterator、Collection、Set和HashSet关系Iterator...
接口中常量的修饰关键字:public,static,final(常量)函数...