1 import java.util.ArrayList; 2 import java.util.Iterator; 3 import java.util.List; 4 import descriptor.*; 5 6 public class Main { 7 public static void main(String[] args){ 8 Main main = new Main(); 9 List list = main.createAttributeDescriptors(); 10 Iterator it = list.iterator(); 11 while(it.hasNext()){ 12 System.out.println("class name is : " + it.next().getClass().getName()); 13 } 14 } 15 16 public List createAttributeDescriptors(){ 17 List result = new ArrayList(); 18 19 result.add(forInteger("remoteId", getClass(), Integer.TYPE)); 20 result.add(forDate("createDate", getClass(), Date.class)); 21 result.add(forDate("lastChangeDate", getClass(), Date.class)); 22 result.add(forReference("createdBy", getClass(), User.class, RemoteUser.class)); 23 result.add(forReference("lastChangedBy", getClass(), User.class, RemoteUser.class)); 24 result.add(forInteger("optimisticLockVersion", getClass(), Integer.TYPE)); 25 26 return result; 27 } 28 public static DefaultDescriptor forInteger(String column, Class cls,int type){ 29 return new DefaultDescriptor(column,cls,type); 30 } 31 public static DefaultDescriptor forDate(String column, Class cls,Class type){ 32 return new DefaultDescriptor(column,cls,type); 33 } 34 public static ReferenceDescriptor forReference(String column, Class cls,Class user,Class remoteUser){ 35 36 return new ReferenceDescriptor(column, cls, user, remoteUser); 37 } 38 39 } 40 41 class Integer { 42 public static int TYPE = 0; 43 } 44 45 class Date { 46 } 47 48 class User { 49 } 50 51 class RemoteUser { 52 } 53