1 22 23 24 package com.mchange.v2.codegen.bean; 25 26 import java.util.*; 27 import java.lang.reflect.Modifier ; 28 import java.io.IOException ; 29 import com.mchange.v2.codegen.CodegenUtils; 30 import com.mchange.v2.codegen.IndentedWriter; 31 32 public class SimpleStateBeanImportExportGeneratorExtension implements GeneratorExtension 33 { 34 int ctor_modifiers = Modifier.PUBLIC; 35 36 public Collection extraGeneralImports() 37 { return Collections.EMPTY_SET; } 38 39 public Collection extraSpecificImports() 40 { return Collections.EMPTY_SET; } 41 42 public Collection extraInterfaceNames() 43 { return Collections.EMPTY_SET; } 44 45 static class SimplePropertyMask implements Property 46 { 47 Property p; 48 49 SimplePropertyMask(Property p) 50 { this.p = p; } 51 52 public int getVariableModifiers() 53 { return Modifier.PRIVATE; } 54 55 public String getName() 56 { return p.getName(); } 57 58 public String getSimpleTypeName() 59 { return p.getSimpleTypeName(); } 60 61 public String getDefensiveCopyExpression() 62 { return null; } 63 64 public String getDefaultValueExpression() 65 { return null; } 66 67 public int getGetterModifiers() 68 { return Modifier.PUBLIC; } 69 70 public int getSetterModifiers() 71 { return Modifier.PUBLIC; } 72 73 public boolean isReadOnly() 74 { return false; } 75 76 public boolean isBound() 77 { return false; } 78 79 public boolean isConstrained() 80 { return false; } 81 } 82 83 public void generate(ClassInfo info, Class superclassType, Property[] props, Class [] propTypes, IndentedWriter iw) 84 throws IOException 85 { 86 int num_props = props.length; 87 Property[] masked = new Property[ num_props ]; 88 for (int i = 0; i < num_props; ++i) 89 masked[i] = new SimplePropertyMask( props[i] ); 90 91 iw.println("protected static class SimpleStateBean implements ExportedState"); 92 iw.println("{"); 93 iw.upIndent(); 94 95 for (int i = 0; i < num_props; ++i) 96 { 97 masked[i] = new SimplePropertyMask( props[i] ); 98 BeangenUtils.writePropertyMember( masked[i], iw ); 99 iw.println(); 100 BeangenUtils.writePropertyGetter( masked[i], iw ); 101 iw.println(); 102 BeangenUtils.writePropertySetter( masked[i], iw ); 103 } 104 105 iw.downIndent(); 106 iw.println("}"); 107 } 108 } 109 | Popular Tags |