当前位置: 首页>>代码示例>>Java>>正文


Java Entity.getClassName方法代码示例

本文整理汇总了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());
}
 
开发者ID:xsingHu,项目名称:xs-android-architecture,代码行数:20,代码来源:SimpleDaoGeneratorTest.java

示例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());
}
 
开发者ID:itsmechlark,项目名称:greendao-cipher,代码行数:20,代码来源:SimpleDaoGeneratorTest.java

示例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);
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:40,代码来源:Generator.java

示例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);
        }
    }
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:32,代码来源:Generator.java

示例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());
}
 
开发者ID:scifiswapnil,项目名称:gadgetbridge_artikcloud,代码行数:9,代码来源:GBDaoGenerator.java

示例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());
}
 
开发者ID:scifiswapnil,项目名称:gadgetbridge_artikcloud,代码行数:9,代码来源:GBDaoGenerator.java


注:本文中的de.greenrobot.daogenerator.Entity.getClassName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。