@Test public void testGetNamesModel() throws Exception { EntityMeta entityMeta = entityMetaFactory.getEntityMeta(Aaa.class); NamesModel namesModel = namesModelFactory.getNamesModel(entityMeta); assertNotNull(namesModel); assertEquals("aaa.bbb", namesModel.getPackageName()); assertEquals("NamesModelFactoryImplTest$AaaNames", namesModel .getShortClassName()); assertEquals(3, namesModel.getNamesAttributeModelList().size()); NamesAttributeModel attributeModel = namesModel .getNamesAttributeModelList().get(0); assertEquals("id", attributeModel.getName()); assertEquals(Integer.class, attributeModel.getAttributeClass()); attributeModel = namesModel.getNamesAttributeModelList().get(1); assertEquals("name", attributeModel.getName()); assertEquals(String.class, attributeModel.getAttributeClass()); attributeModel = namesModel.getNamesAttributeModelList().get(2); assertEquals("bbbId", attributeModel.getName()); assertEquals(Integer.class, attributeModel.getAttributeClass()); assertEquals(1, namesModel.getNamesAssociationModelList().size()); NamesAssociationModel associationModel = namesModel .getNamesAssociationModelList().get(0); assertEquals("bbb", associationModel.getName()); assertEquals("_BbbNames", associationModel.getShortClassName()); assertEquals("aaa.bbb.BbbNames._BbbNames", associationModel .getClassName()); assertEquals(4, namesModel.getImportNameSet().size()); Iterator<String> iterator = namesModel.getImportNameSet().iterator(); assertEquals("aaa.bbb.BbbNames._BbbNames", iterator.next()); assertEquals(Generated.class.getCanonicalName(), iterator.next()); assertEquals(Aaa.class.getCanonicalName(), iterator.next()); assertEquals(PropertyName.class.getCanonicalName(), iterator.next()); }
public NamesModel getNamesModel(EntityMeta entityMeta) { NamesModel namesModel = new NamesModel(); namesModel.setPackageName(packageName); String shortClassName = entityMeta.getName() + namesClassNameSuffix; namesModel.setShortClassName(shortClassName); namesModel.setShortInnerClassName(INNER_CLASS_NAME_PREFIX + shortClassName); namesModel.setEntityClassName(entityMeta.getEntityClass().getName()); namesModel.setShortEntityClassName(entityMeta.getEntityClass() .getSimpleName()); for (PropertyMeta propertyMeta : entityMeta.getAllPropertyMeta()) { if (propertyMeta.isTransient()) { continue; } if (propertyMeta.isRelationship()) { doNamesAssociationModel(namesModel, propertyMeta); } else { doNamesAttributeModel(namesModel, propertyMeta); } } doImportName(namesModel, entityMeta); doGeneratedInfo(namesModel, entityMeta); return namesModel; }
NamesModelFactoryImpl implements NamesModelFactory { public NamesModel getNamesModel(EntityMeta entityMeta) { NamesModel namesModel = new NamesModel(); namesModel.setPackageName(packageName); String shortClassName = entityMeta.getName() + namesClassNameSuffix; namesModel.setShortClassName(shortClassName); namesModel.setShortInnerClassName(INNER_CLASS_NAME_PREFIX + shortClassName); namesModel.setEntityClassName(entityMeta.getEntityClass().getName()); namesModel.setShortEntityClassName(entityMeta.getEntityClass() .getSimpleName()); for (PropertyMeta propertyMeta : entityMeta.getAllPropertyMeta()) { if (propertyMeta.isTransient()) { continue; } if (propertyMeta.isRelationship()) { doNamesAssociationModel(namesModel, propertyMeta); } else { doNamesAttributeModel(namesModel, propertyMeta); } } doImportName(namesModel, entityMeta); doGeneratedInfo(namesModel, entityMeta); return namesModel; } }
NamesModelFactoryImpl implements NamesModelFactory { public NamesModel getNamesModel(EntityMeta entityMeta) { NamesModel namesModel = new NamesModel(); namesModel.setPackageName(packageName); String shortClassName = entityMeta.getName() + namesClassNameSuffix; namesModel.setShortClassName(shortClassName); namesModel.setShortInnerClassName(INNER_CLASS_NAME_PREFIX + shortClassName); namesModel.setEntityClassName(entityMeta.getEntityClass().getName()); namesModel.setShortEntityClassName(entityMeta.getEntityClass() .getSimpleName()); for (PropertyMeta propertyMeta : entityMeta.getAllPropertyMeta()) { if (propertyMeta.isTransient()) { continue; } if (propertyMeta.isRelationship()) { doNamesAssociationModel(namesModel, propertyMeta); } else { doNamesAttributeModel(namesModel, propertyMeta); } } doImportName(namesModel, entityMeta); doGeneratedInfo(namesModel, entityMeta); return namesModel; } NamesModelFactoryImpl(String packageName, String namesClassNameSuffix); }
NamesModelFactoryImpl implements NamesModelFactory { public NamesModel getNamesModel(EntityMeta entityMeta) { NamesModel namesModel = new NamesModel(); namesModel.setPackageName(packageName); String shortClassName = entityMeta.getName() + namesClassNameSuffix; namesModel.setShortClassName(shortClassName); namesModel.setShortInnerClassName(INNER_CLASS_NAME_PREFIX + shortClassName); namesModel.setEntityClassName(entityMeta.getEntityClass().getName()); namesModel.setShortEntityClassName(entityMeta.getEntityClass() .getSimpleName()); for (PropertyMeta propertyMeta : entityMeta.getAllPropertyMeta()) { if (propertyMeta.isTransient()) { continue; } if (propertyMeta.isRelationship()) { doNamesAssociationModel(namesModel, propertyMeta); } else { doNamesAttributeModel(namesModel, propertyMeta); } } doImportName(namesModel, entityMeta); doGeneratedInfo(namesModel, entityMeta); return namesModel; } NamesModelFactoryImpl(String packageName, String namesClassNameSuffix); NamesModel getNamesModel(EntityMeta entityMeta); }
NamesModelFactoryImpl implements NamesModelFactory { public NamesModel getNamesModel(EntityMeta entityMeta) { NamesModel namesModel = new NamesModel(); namesModel.setPackageName(packageName); String shortClassName = entityMeta.getName() + namesClassNameSuffix; namesModel.setShortClassName(shortClassName); namesModel.setShortInnerClassName(INNER_CLASS_NAME_PREFIX + shortClassName); namesModel.setEntityClassName(entityMeta.getEntityClass().getName()); namesModel.setShortEntityClassName(entityMeta.getEntityClass() .getSimpleName()); for (PropertyMeta propertyMeta : entityMeta.getAllPropertyMeta()) { if (propertyMeta.isTransient()) { continue; } if (propertyMeta.isRelationship()) { doNamesAssociationModel(namesModel, propertyMeta); } else { doNamesAttributeModel(namesModel, propertyMeta); } } doImportName(namesModel, entityMeta); doGeneratedInfo(namesModel, entityMeta); return namesModel; } NamesModelFactoryImpl(String packageName, String namesClassNameSuffix); NamesModel getNamesModel(EntityMeta entityMeta);  }