@Test public void setRelationshipDefinition() { String typeName = "org.example.model.TargetEntity"; importUtils.addType(SetProperty.class.getName()); importUtils.addType(typeName); ObjEntity entity = mock(ObjEntity.class); when(entity.getClassName()).thenReturn(typeName); when(entity.getName()).thenReturn("target"); ObjRelationship relationship = mock(ObjRelationship.class); when(relationship.isToMany()).thenReturn(true); when(relationship.getCollectionType()).thenReturn("java.util.Set"); when(relationship.getTargetEntityName()).thenReturn("target"); when(relationship.getName()).thenReturn("set_rel"); when(relationship.getTargetEntity()).thenReturn(entity); String definition = propertyUtils.propertyDefinition(relationship); assertEquals("public static final SetProperty<TargetEntity> SET_REL = PropertyFactory.createSet(\"set_rel\", TargetEntity.class);", definition); }
public String propertyDefinition(ObjEntity entity, DbAttribute attribute) throws ClassNotFoundException { StringUtils utils = StringUtils.getInstance(); String attributeType = TypesMapping.getJavaBySqlType(attribute.getType()); String propertyType = getPkPropertyTypeForType(TypesMapping.getJavaBySqlType(attribute.getType())); String propertyFactoryMethod = factoryMethodForPropertyType(propertyType); attributeType = importUtils.formatJavaType(attributeType, false); return String.format("public static final %s<%s> %s = PropertyFactory.%s(\"%s\", \"%s\", %s.class);", importUtils.formatJavaType(propertyType), attributeType, utils.capitalizedAsConstant(attribute.getName()) + PK_PROPERTY_SUFFIX, propertyFactoryMethod, attribute.getName(), entity.getName(), attributeType ); }
PropertyUtils { public String propertyDefinition(ObjEntity entity, DbAttribute attribute) throws ClassNotFoundException { StringUtils utils = StringUtils.getInstance(); String attributeType = TypesMapping.getJavaBySqlType(attribute.getType()); String propertyType = getPkPropertyTypeForType(TypesMapping.getJavaBySqlType(attribute.getType())); String propertyFactoryMethod = factoryMethodForPropertyType(propertyType); attributeType = importUtils.formatJavaType(attributeType, false); return String.format("public static final %s<%s> %s = PropertyFactory.%s(\"%s\", \"%s\", %s.class);", importUtils.formatJavaType(propertyType), attributeType, utils.capitalizedAsConstant(attribute.getName()) + PK_PROPERTY_SUFFIX, propertyFactoryMethod, attribute.getName(), entity.getName(), attributeType ); } }
PropertyUtils { public String propertyDefinition(ObjEntity entity, DbAttribute attribute) throws ClassNotFoundException { StringUtils utils = StringUtils.getInstance(); String attributeType = TypesMapping.getJavaBySqlType(attribute.getType()); String propertyType = getPkPropertyTypeForType(TypesMapping.getJavaBySqlType(attribute.getType())); String propertyFactoryMethod = factoryMethodForPropertyType(propertyType); attributeType = importUtils.formatJavaType(attributeType, false); return String.format("public static final %s<%s> %s = PropertyFactory.%s(\"%s\", \"%s\", %s.class);", importUtils.formatJavaType(propertyType), attributeType, utils.capitalizedAsConstant(attribute.getName()) + PK_PROPERTY_SUFFIX, propertyFactoryMethod, attribute.getName(), entity.getName(), attributeType ); } PropertyUtils(ImportUtils importUtils);  PropertyUtils(ImportUtils importUtils,
                         AdhocObjectFactory adhocObjectFactory,
                         List<PropertyDescriptorCreator> propertyList,
                         Logger logger); }
PropertyUtils { public String propertyDefinition(ObjEntity entity, DbAttribute attribute) throws ClassNotFoundException { StringUtils utils = StringUtils.getInstance(); String attributeType = TypesMapping.getJavaBySqlType(attribute.getType()); String propertyType = getPkPropertyTypeForType(TypesMapping.getJavaBySqlType(attribute.getType())); String propertyFactoryMethod = factoryMethodForPropertyType(propertyType); attributeType = importUtils.formatJavaType(attributeType, false); return String.format("public static final %s<%s> %s = PropertyFactory.%s(\"%s\", \"%s\", %s.class);", importUtils.formatJavaType(propertyType), attributeType, utils.capitalizedAsConstant(attribute.getName()) + PK_PROPERTY_SUFFIX, propertyFactoryMethod, attribute.getName(), entity.getName(), attributeType ); } PropertyUtils(ImportUtils importUtils);  PropertyUtils(ImportUtils importUtils,
                         AdhocObjectFactory adhocObjectFactory,
                         List<PropertyDescriptorCreator> propertyList,
                         Logger logger); void addImportForPK(EntityUtils entityUtils); void addImport(ObjAttribute attribute); void addImport(EmbeddedAttribute attribute); void addImport(EmbeddableAttribute attribute); void addImport(ObjRelationship relationship); void addImport(ObjRelationship relationship, boolean client); String propertyDefinition(ObjEntity entity, DbAttribute attribute); String propertyDefinition(ObjAttribute attribute, boolean client); String propertyDefinition(ObjAttribute attribute); String propertyDefinition(EmbeddedAttribute attribute); String propertyDefinition(EmbeddableAttribute attribute); String propertyDefinition(ObjRelationship relationship, boolean client); String propertyDefinition(ObjRelationship relationship); PropertyDescriptor getPropertyDescriptor(String attrType); }
PropertyUtils { public String propertyDefinition(ObjEntity entity, DbAttribute attribute) throws ClassNotFoundException { StringUtils utils = StringUtils.getInstance(); String attributeType = TypesMapping.getJavaBySqlType(attribute.getType()); String propertyType = getPkPropertyTypeForType(TypesMapping.getJavaBySqlType(attribute.getType())); String propertyFactoryMethod = factoryMethodForPropertyType(propertyType); attributeType = importUtils.formatJavaType(attributeType, false); return String.format("public static final %s<%s> %s = PropertyFactory.%s(\"%s\", \"%s\", %s.class);", importUtils.formatJavaType(propertyType), attributeType, utils.capitalizedAsConstant(attribute.getName()) + PK_PROPERTY_SUFFIX, propertyFactoryMethod, attribute.getName(), entity.getName(), attributeType ); } PropertyUtils(ImportUtils importUtils);  PropertyUtils(ImportUtils importUtils,
                         AdhocObjectFactory adhocObjectFactory,
                         List<PropertyDescriptorCreator> propertyList,
                         Logger logger); void addImportForPK(EntityUtils entityUtils); void addImport(ObjAttribute attribute); void addImport(EmbeddedAttribute attribute); void addImport(EmbeddableAttribute attribute); void addImport(ObjRelationship relationship); void addImport(ObjRelationship relationship, boolean client); String propertyDefinition(ObjEntity entity, DbAttribute attribute); String propertyDefinition(ObjAttribute attribute, boolean client); String propertyDefinition(ObjAttribute attribute); String propertyDefinition(EmbeddedAttribute attribute); String propertyDefinition(EmbeddableAttribute attribute); String propertyDefinition(ObjRelationship relationship, boolean client); String propertyDefinition(ObjRelationship relationship); PropertyDescriptor getPropertyDescriptor(String attrType);  }