现在的位置: 首页 > 综合 > 正文

其实你可以这样折腾java enum

2012年06月09日 ⁄ 综合 ⁄ 共 801字 ⁄ 字号 评论关闭

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());
     
    }
}

【上篇】
【下篇】

抱歉!评论已关闭.