JIT

<< JDK中的动态代理:Dynamic Proxy | 首页 | Spring method replacement >> 2004-11-23 Enum example of Java Tag: Java技术文章 版权声明 :转载时请以超链接形式标明文章原始出处和作者信息及 本声明 http://jit.blogbus.com/logs/511311.html public class CreditCardType implements Serializable { private final int code; private final String debugName; public static final CreditCardType MASTERCARD = new CreditCardType(1, "Mastercard"); public static final CreditCardType VISA = new CreditCardType(2, "Visa"); public static final CreditCardType AMEX = new CreditCardType(3, "American Express"); private static final Map INSTANCES = new HashMap(); static { INSTANCES.put(MASTERCARD.toInteger(), MASTERCARD); INSTANCES.put(VISA.toInteger(), VISA); INSTANCES.put(AMEX.toInteger(), AMEX); } /** * Prevent instantiation and subclassing with a private constructor. */ private CreditCardType(int code, String debugName) { this.debugName = debugName; this.code = code; } // ********************** Common Methods ********************** // public String toString() { return debugName; } public Integer toInteger() { return new Integer(code); } Object readResolve() { return getInstance(code); } public static CreditCardType getInstance(int code) { return (CreditCardType) INSTANCES.get(new Integer(code)); } // ********************** Business Methods ********************** // public boolean isValid(CreditCard cc) { // TODO: Implement syntactical validation of credit card information. return true; } } 随机文章: J2EE without EJB 读书笔记(chapter 3) 2004-09-08 良好定义的service层应该这样。。。 2004-09-08 我眼中的J2EE 2004-09-03 为hibernate生成建表文件 2004-05-27 在 Java 应用程序中计划重复执行的任务 2004-05-27 收藏到: Del.icio.us 引用地址: 发表于 11:15 | 编辑 | 继续话题 | 转发 | 推荐 发表评论

原始快照:web.archive.org