其实你可以这样折腾java enum
2012-06-21 17:59
357 查看
package com.geoway.pad.favourite.bean;
/**
* @author likehua
* @date 20120621
* */
public enum FavouriteGeometeyType {
POINT(1),
LINE(2),
POLYGON(2);
int type;
private FavouriteGeometeyType(int type){
this.type=type;
}
public int getOriginTypeValue(){
return this.type;
}
public static FavouriteGeometeyType parseGeometryType(int type){
if(type==1){
return FavouriteGeometeyType.POINT;
};
if(type==2){
return FavouriteGeometeyType.LINE;
};
if(type==3){
return FavouriteGeometeyType.POLYGON;
};
return null;
};
public static void main(String[] args){
// FavouriteGeometeyType type;
System.out.println(FavouriteGeometeyType.parseGeometryType(1).ordinal());
System.out.println(FavouriteGeometeyType.parseGeometryType(1).getOriginTypeValue());
}
}
/**
* @author likehua
* @date 20120621
* */
public enum FavouriteGeometeyType {
POINT(1),
LINE(2),
POLYGON(2);
int type;
private FavouriteGeometeyType(int type){
this.type=type;
}
public int getOriginTypeValue(){
return this.type;
}
public static FavouriteGeometeyType parseGeometryType(int type){
if(type==1){
return FavouriteGeometeyType.POINT;
};
if(type==2){
return FavouriteGeometeyType.LINE;
};
if(type==3){
return FavouriteGeometeyType.POLYGON;
};
return null;
};
public static void main(String[] args){
// FavouriteGeometeyType type;
System.out.println(FavouriteGeometeyType.parseGeometryType(1).ordinal());
System.out.println(FavouriteGeometeyType.parseGeometryType(1).getOriginTypeValue());
}
}
相关文章推荐
- 其实Editplus可以这样用!!
- 其实URL重写也可以这样简单
- 其实添加数据也可以这样简单——表单的第三步抽象(针对UI及后置代码)
- Java enum 枚举还可以这么用
- 指针结构体函数-其实可以这样详细理解
- Java enum 枚举还可以这么用
- (转)秒懂,Java 注解 (Annotation)你可以这样学 ---- 重要
- 这样的心情怎样编程?可以推荐一段实现“调整良好心态编程”功能的java源代码吗?
- 其实Editplus可以这样用!!
- Java命令行调用Python(其实可以调用任何其他语言)
- 汉字方法名和变量名!---- 原来JAVA还可以这样用啊!
- Java enum 枚举还可以这么用
- 原来Java还可以这样写——实现‘内部 接口’
- C++调用java方法——这样也可以?
- Ex32.java 题目:取一个整数a从右端开始的4~7位。 程序分析:可以这样考虑:
- 现实版“捉妖记”告诉我们,O2O其实可以这样玩
- 【转】秒懂,Java 注解 (Annotation)你可以这样学
- 秒懂,Java 注解 (Annotation)你可以这样学
- 幽默的经济学原理~其实经济学可以这样学
- 【分享】其实你的VS界面还可以是这样,VS界面美化