标签: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