當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。