本文整理汇总了Java中de.greenrobot.daogenerator.Entity.getClassName方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.getClassName方法的具体用法?Java Entity.getClassName怎么用?Java Entity.getClassName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.greenrobot.daogenerator.Entity
的用法示例。
在下文中一共展示了Entity.getClassName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMinimalSchema
import de.greenrobot.daogenerator.Entity; //导入方法依赖的package包/类
@Test
public void testMinimalSchema() throws Exception {
Schema schema = new Schema(1, "de.greenrobot.testdao");
Entity addressEntity = schema.addEntity("Addresse");
Property idProperty = addressEntity.addIdProperty().getProperty();
addressEntity.addIntProperty("count").index();
addressEntity.addIntProperty("dummy").notNull();
assertEquals(1, schema.getEntities().size());
assertEquals(3, addressEntity.getProperties().size());
File daoFile = new File("test-out/de/greenrobot/testdao/" + addressEntity.getClassName() + "Dao.java");
daoFile.delete();
assertFalse(daoFile.exists());
new DaoGenerator().generateAll(schema, "test-out");
assertEquals("PRIMARY KEY", idProperty.getConstraints());
assertTrue(daoFile.toString(), daoFile.exists());
}
示例2: testMinimalSchema
import de.greenrobot.daogenerator.Entity; //导入方法依赖的package包/类
@Test
public void testMinimalSchema() throws Exception {
Schema schema = new Schema(1, "de.greenrobot.testdao");
Entity adressTable = schema.addEntity("Adresse");
Property idProperty = adressTable.addIdProperty().getProperty();
adressTable.addIntProperty("count").index();
adressTable.addIntProperty("dummy").notNull();
assertEquals(1, schema.getEntities().size());
assertEquals(3, adressTable.getProperties().size());
File daoFile = new File("test-out/de/greenrobot/testdao/" + adressTable.getClassName() + "Dao.java");
daoFile.delete();
assertFalse(daoFile.exists());
new DaoGenerator().generateAll(schema, "test-out");
assertEquals("PRIMARY KEY", idProperty.getConstraints());
assertTrue(daoFile.toString(), daoFile.exists());
}
示例3: setBidirectionalToMany
import de.greenrobot.daogenerator.Entity; //导入方法依赖的package包/类
/**
* Adds a toMany relationship to oneEntity, and a toOne relationship to manyEntity.
* The property names will be the names specified, and the Ids will be the names of the
* respective entities with the suffix of "DaoId"
*
*
* @param oneEntity entity that only will be linking to manyEntities
* @param manyEntity entity that will be linking to oneEntity
* @param toOnePropertyName to specify the property name, otherwise null works
* @param toManyPropertyName to specify the property name, otherwise null works
*
*/
private static void setBidirectionalToMany(Entity oneEntity, Entity manyEntity,
String toOnePropertyName,
String toManyPropertyName){
Property manyIdProp;
if (toOnePropertyName == null) {
manyIdProp = manyEntity.addLongProperty(oneEntity.getClassName() + "DaoId").getProperty();
}else{
manyIdProp = manyEntity.addLongProperty(toOnePropertyName + "DaoId").getProperty();
}
ToOne toOne = manyEntity.addToOne(oneEntity, manyIdProp);
ToMany toMany = oneEntity.addToMany(manyEntity, manyIdProp);
if(toOnePropertyName == null){
toOnePropertyName = oneEntity.getClassName();
toOnePropertyName = toOnePropertyName.substring(0, 1).toLowerCase() +
toOnePropertyName.substring(1);
}
if(toManyPropertyName == null){
toManyPropertyName = oneEntity.getClassName();
toManyPropertyName = toManyPropertyName.substring(0, 1).toLowerCase() +
toManyPropertyName.substring(1) + "s";
}
toOne.setName(toOnePropertyName);
toMany.setName(toManyPropertyName);
}
示例4: setManyToMany
import de.greenrobot.daogenerator.Entity; //导入方法依赖的package包/类
private static void setManyToMany(Entity linkEntity, Entity entityOne, Entity entityTwo){
Property entityOneProp;
Property entityTwoProp;
String entityOneName = entityOne.getClassName();
String entityTwoName = entityTwo.getClassName();
// Distinguish entity links if they are to the same entity type
if(entityOne.getClassName().equals(entityTwo.getClassName())) {
entityTwoName = "linkOwner" + entityTwoName;
}
entityOneProp = linkEntity.addLongProperty(entityOneName + "DaoId").getProperty();
entityTwoProp = linkEntity.addLongProperty(entityTwoName + "DaoId").getProperty();
linkEntity.addToOne(entityOne, entityOneProp).setName(entityOneName);
linkEntity.addToOne(entityTwo, entityTwoProp).setName(entityTwoName);
String linkEntityName = linkEntity.getClassName();
linkEntityName = linkEntityName.substring(0, 1).toLowerCase() +
linkEntityName.substring(1) + "s";
ToMany linkFromEntityOne = entityOne.addToMany(linkEntity, entityOneProp);
linkFromEntityOne.setName(linkEntityName);
// If the entities are not the same they each need a property
if(!entityOne.getClassName().equals(entityTwo.getClassName())) {
ToMany linkFromEntityTwo = entityTwo.addToMany(linkEntity, entityTwoProp);
linkFromEntityTwo.setName(linkEntityName);
}
}
示例5: getPropertyByName
import de.greenrobot.daogenerator.Entity; //导入方法依赖的package包/类
private static Property getPropertyByName(Entity entity, String propertyName) {
for (Property prop : entity.getProperties()) {
if (propertyName.equals(prop.getPropertyName())) {
return prop;
}
}
throw new IllegalStateException("Could not find property " + propertyName + " in entity " + entity.getClassName());
}
示例6: findProperty
import de.greenrobot.daogenerator.Entity; //导入方法依赖的package包/类
private static Property findProperty(Entity entity, String propertyName) {
for (Property prop : entity.getProperties()) {
if (propertyName.equals(prop.getPropertyName())) {
return prop;
}
}
throw new IllegalArgumentException("Property " + propertyName + " not found in Entity " + entity.getClassName());
}