码迷,mamicode.com
首页 > 其他好文 > 详细

一些基础巩巩固

时间:2016-08-23 19:09:58      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:java 基础

1)回调

jndi源码回调

public Object lookup(final String name) {

return execute(new JndiCallback<Object>() {

public Object doInContext(Context ctx) throws NamingException {

Object located = ctx.lookup(name);

return located;

} });  }



public <T> T execute(JndiCallback<T> contextCallback) throws NamingException {

Context ctx = getContext();

try { return contextCallback.doInContext(ctx); }

finally { releaseContext(ctx); } }


2) 枚举

public static enum ModelCategoryType{

V("V",1),AFA_P("AFA-P",2),AFA_N("AFA-N",3),U("U",4);

private final int priority;

private final String name;

ModelCategoryType(String name,int priority){

this.name=name;

this.priority=priority;

}

public int getPriority() {

return priority;

}

public String getName() {

return name;

}

public static int getPriorityFromName(String name){

if(name!=null){

for(ModelCategoryType modelCategoryType :ModelCategoryType.values()){

if(name.equals(modelCategoryType.getName())){

return modelCategoryType.getPriority();

}

}

}

return Integer.MAX_VALUE;

}

}




String newMdlCategory=RubyConstants.ModelCategoryType.V.getName();

RubyConstants.ModelCategoryType.getPriorityFromName(newMdlCategory)

<(RubyConstants.ModelCategoryType.getPriorityFromName(originalMdlCategory))


一些基础巩巩固

标签:java 基础

原文地址:http://2828408.blog.51cto.com/2818408/1841609

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!