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())); 20 result.add(forDate("createDate", getClass())); 21 result.add(forDate("lastChangeDate", getClass())); 22 result.add(forReference("createdBy", getClass())); 23 result.add(forReference("lastChangedBy", getClass())); 24 result.add(forInteger("optimisticLockVersion", getClass())); 25 26 return result; 27 } 28 public static DefaultDescriptor forInteger(String column, Class cls){ 29 return new DefaultDescriptor(column,cls,Integer.TYPE); 30 } 31 public static DefaultDescriptor forDate(String column, Class cls){ 32 return new DefaultDescriptor(column,cls,Date.class); 33 } 34 public static ReferenceDescriptor forReference(String column, Class cls){ 35 return new ReferenceDescriptor(column, cls, User.class, RemoteUser.class); 36 } 37 38 } 39 40 class Integer { 41 public static int TYPE = 0; 42 } 43 44 class Date { 45 } 46 47 class User { 48 } 49 50 class RemoteUser { 51 } 52