1 16 package net.sf.cglib.core; 17 18 import java.util.Set ; 19 20 30 public class DefaultNamingPolicy implements NamingPolicy { 31 public static final DefaultNamingPolicy INSTANCE = new DefaultNamingPolicy(); 32 33 public String getClassName(String prefix, String source, Object key, Predicate names) { 34 35 36 StringBuffer sb = new StringBuffer (); 37 sb.append( 38 (prefix != null) ? 39 ( 40 prefix.startsWith("java") ? 41 "$" + prefix : prefix 42 ) 43 : "net.sf.cglib.empty.Object" 44 ); 45 sb.append("$$"); 46 sb.append(source.substring(source.lastIndexOf('.') + 1)); 47 sb.append("ByCGLIB$$"); 48 sb.append(Integer.toHexString(key.hashCode())); 49 String base = sb.toString(); 50 String attempt = base; 51 int index = 2; 52 while (names.evaluate(attempt)) { 53 attempt = base + "_" + index++; 54 } 55 56 return attempt; 57 } 58 } 59 | Popular Tags |