本文整理汇总了Java中de.greenrobot.daogenerator.Property类的典型用法代码示例。如果您正苦于以下问题:Java Property类的具体用法?Java Property怎么用?Java Property使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Property类属于de.greenrobot.daogenerator包,在下文中一共展示了Property类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addThread
import de.greenrobot.daogenerator.Property; //导入依赖的package包/类
private static Property addThread(Schema schema) {
Property threadId;
thread = schema.addEntity(EntityProperties.BThread);
thread.addIdProperty();
threadId = thread.addStringProperty(EntityProperties.EntityID).getProperty();
thread.addDateProperty(EntityProperties.CreationDate);
thread.addBooleanProperty(EntityProperties.HasUnreadMessaged);
thread.addBooleanProperty(EntityProperties.BDeleted);
thread.addStringProperty(EntityProperties.Name);
thread.addDateProperty(EntityProperties.LastMessageAdded);
thread.addIntProperty(EntityProperties.Type);
thread.addStringProperty(EntityProperties.CreatorEntityID);
thread.addStringProperty(EntityProperties.BThreadImageUrl);
thread.addStringProperty(EntityProperties.RootKey).columnName(EntityProperties.C_RootKey);
thread.addStringProperty(EntityProperties.ApiKey).columnName(EntityProperties.C_ApiKey);
Property threadPropCreator = thread.addLongProperty(EntityProperties.CreatorID).getProperty();
ToOne threadToOneCreator = thread.addToOne(user, threadPropCreator);
threadToOneCreator.setName(EntityProperties.Creator);
return threadId;
}
示例2: addMessages
import de.greenrobot.daogenerator.Property; //导入依赖的package包/类
private static Property addMessages(Schema schema){
Property messageId;
message = schema.addEntity(EntityProperties.BMessage);
message.addIdProperty();
messageId = message.addStringProperty(EntityProperties.EntityID).getProperty();
message.addDateProperty(EntityProperties.Date);
message.addBooleanProperty(EntityProperties.isRead);
message.addStringProperty(EntityProperties.Resource);
message.addStringProperty(EntityProperties.ResourcePath);
message.addStringProperty(EntityProperties.Text);
message.addStringProperty(EntityProperties.ImageDimensions);
message.addIntProperty(EntityProperties.Type);
message.addIntProperty(EntityProperties.Status);
message.addIntProperty(EntityProperties.Delivered);
// The sender ID
Property messagePropSender = message.addLongProperty("Sender").getProperty();
ToOne messageToOneSender = message.addToOne(user, messagePropSender);
messageToOneSender.setName("BUserSender");
return messageId;
}
示例3: addCustomerOrder
import de.greenrobot.daogenerator.Property; //导入依赖的package包/类
/**
* @author:keivn
* @param schema
*/
private static void addCustomerOrder(Schema schema) {
Entity customer = schema.addEntity("Customer");
customer.addIdProperty();
customer.addStringProperty("name").notNull();
Entity order = schema.addEntity("Order");
order.setTableName("ORDERS"); // "ORDER" is a reserved keyword
order.addIdProperty();
Property orderDate = order.addDateProperty("date").getProperty();
Property customerId = order.addLongProperty("customerId").notNull().getProperty();
order.addToOne(customer, customerId);
ToMany customerToOrders = customer.addToMany(order, customerId);
customerToOrders.setName("orders");
customerToOrders.orderAsc(orderDate);
}
示例4: getAddedProperties
import de.greenrobot.daogenerator.Property; //导入依赖的package包/类
/**
* Get a list of the properties that were added when going from one entity to the other
*
* @param prev The entity from which we are migrating
* @param cur The entity to which we are migrating
* @return The list of added properties
*/
public static List<Property> getAddedProperties(Entity prev, Entity cur) {
final AbstractList<String> prevPropertyNameList = propertyNameList(prev);
final AbstractList<String> curPropertyNameList = propertyNameList(cur);
//Remove all properties from the current list that are present in the older list
curPropertyNameList.removeAll(prevPropertyNameList);
if (curPropertyNameList.size() > 0) {
//We have entities that have been added
final Map<String, Property> propertyMap = propertyMapFromEntity(cur);
final Iterator<Map.Entry<String, Property>> iterator = propertyMap.entrySet().iterator();
Map.Entry<String, Property> next;
while (iterator.hasNext()) {
next = iterator.next();
if (!curPropertyNameList.contains(next.getKey())) {
iterator.remove();
}
}
return new ArrayList<>(propertyMap.values());
} else {
return Collections.emptyList();
}
}
示例5: getRemovedProperties
import de.greenrobot.daogenerator.Property; //导入依赖的package包/类
/**
* Get a list of the properties that were removed when going from one entity to the other
*
* @param prev The entity from which we are migrating
* @param cur The entity to which we are migrating
* @return The list of removed properties
*/
public static List<Property> getRemovedProperties(Entity prev, Entity cur) {
final AbstractList<String> prevPropertyNameList = propertyNameList(prev);
final AbstractList<String> curPropertyNameList = propertyNameList(cur);
//Remove all properties from the current list that are present in the older list
prevPropertyNameList.removeAll(curPropertyNameList);
if (prevPropertyNameList.size() > 0) {
//We have entities that have been added
final Map<String, Property> propertyMap = propertyMapFromEntity(prev);
final Iterator<Map.Entry<String, Property>> iterator = propertyMap.entrySet().iterator();
Map.Entry<String, Property> next;
while (iterator.hasNext()) {
next = iterator.next();
if (!prevPropertyNameList.contains(next.getKey())) {
iterator.remove();
}
}
return new ArrayList<>(propertyMap.values());
} else {
return Collections.emptyList();
}
}
示例6: entityPropertiesWithoutPrimaryKey
import de.greenrobot.daogenerator.Property; //导入依赖的package包/类
/**
* Gets a list of properties from the entity, excluding the primary key property
*
* @param entity The entity for which to generate the list
* @return The list of properties, sans the Primary Key property
*/
public static List<Property> entityPropertiesWithoutPrimaryKey(Entity entity) {
final List<Property> properties = new ArrayList<>(entity.getProperties());
final Iterator<Property> iterator = properties.iterator();
Property property;
while (iterator.hasNext()) {
property = iterator.next();
if (property.isPrimaryKey()) {
iterator.remove();
break;
}
}
return properties;
}
示例7: getCommonPropertiesAsMap
import de.greenrobot.daogenerator.Property; //导入依赖的package包/类
public static Map<Property, Property> getCommonPropertiesAsMap(Entity prev, Entity cur) {
final AbstractList<String> prevPropertyNameList = propertyNameList(prev);
final AbstractList<String> curPropertyNameList = propertyNameList(cur);
//Retain all properties from the current list that are present in the older list
curPropertyNameList.retainAll(prevPropertyNameList);
if (curPropertyNameList.size() > 0) {
final Map<String, Property> prevPropertyMap = propertyMapFromEntity(prev);
final Map<String, Property> curPropertyMap = propertyMapFromEntity(cur);
final Map<Property, Property> commonPropertyMap = new HashMap<>((int) (curPropertyNameList.size() * 1.33F));
for (String propertyName : curPropertyNameList) {
commonPropertyMap.put(prevPropertyMap.get(propertyName), curPropertyMap.get(propertyName));
}
return commonPropertyMap;
} else {
return Collections.emptyMap();
}
}
示例8: addHtml
import de.greenrobot.daogenerator.Property; //导入依赖的package包/类
private static void addHtml(Schema schema) {
// 实体类
Entity mHtmlEntity = schema.addEntity("HtmlEntity");//表名
//列名
mHtmlEntity.addIdProperty();//主键id
mHtmlEntity.addStringProperty("url");//连接
mHtmlEntity.addStringProperty("type");//类型
mHtmlEntity.addStringProperty("title");//标题
mHtmlEntity.addStringProperty("html");//html
mHtmlEntity.addStringProperty("summary");//总结
mHtmlEntity.addStringProperty("collect");//是否收藏
mHtmlEntity.addDateProperty("hireDate");
// 收藏实体类
Entity mCollectEntity = schema.addEntity("CollectEntity");//表名
mCollectEntity.addIdProperty();//主键id
Property htmlID = mCollectEntity.addLongProperty("html_id").getProperty();//收藏的id
mCollectEntity.addStringProperty("collect");//是否收藏
mCollectEntity.addToOne(mHtmlEntity, htmlID);
}
示例9: testMinimalSchema
import de.greenrobot.daogenerator.Property; //导入依赖的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());
}
示例10: addMeal
import de.greenrobot.daogenerator.Property; //导入依赖的package包/类
private static void addMeal(Schema schema, Entity food) {
Entity meal = schema.addEntity("MealEntity");
meal.setSuperclass("MealEntityBase");
meal.addIdProperty().autoincrement().primaryKey();
meal.addDateProperty("date").notNull();
meal.addIntProperty("mealtime").notNull();
meal.addIntProperty("grams").notNull();
meal.addDoubleProperty("calories").notNull();
meal.addDoubleProperty("fats").notNull();
meal.addDoubleProperty("carbohydrates").notNull();
meal.addDoubleProperty("proteins").notNull();
meal.addStringProperty("foodName");
Property foodId = meal.addLongProperty("foodId").getProperty();
meal.addToOne(food, foodId);
}
示例11: addAddress
import de.greenrobot.daogenerator.Property; //导入依赖的package包/类
private Entity addAddress(Entity user) {
Entity address = this.getSchema().addEntity("Address");
address.addIdProperty();
address.addIntProperty("number").notNull();
address.addStringProperty("street").notNull();
address.addStringProperty("zipCode").notNull();
address.addStringProperty("city").notNull();
address.addStringProperty("country").notNull();
Property userProperty = address.addLongProperty("userId").getProperty();
address.addToOne(user, userProperty, "user");
user.addToMany(address, userProperty, "addresses");
return address;
}
示例12: addRule
import de.greenrobot.daogenerator.Property; //导入依赖的package包/类
/**
* Add rule entity.
*
* @param schema - database schema
*/
private static void addRule(Schema schema) {
rule = schema.addEntity("Rule");
rule.addLongProperty("ruleId").primaryKey();
rule.addStringProperty("name").notNull();
rule.addStringProperty("semesterFormat");
rule.addStringProperty("semesterPattern");
rule.addIntProperty("semesterStartSummer");
rule.addIntProperty("semesterStartWinter");
rule.addDoubleProperty("gradeFactor");
rule.addDateProperty("lastUpdated");
rule.addBooleanProperty("overview");
rule.addStringProperty("type");
// add 1:n relation for university -> rules
Property universityId = rule.addLongProperty("universityId").notNull().getProperty();
university.addToMany(rule, universityId, "rules");
// add "keep" sections
rule.setHasKeepSections(true);
}
示例13: addAction
import de.greenrobot.daogenerator.Property; //导入依赖的package包/类
/**
* Add action entity.
*
* @param schema - database schema
*/
private static void addAction(Schema schema) {
action = schema.addEntity("Action");
action.addLongProperty("actionId").primaryKey();
action.addIntProperty("position").notNull();
action.addStringProperty("type");
action.addStringProperty("method").notNull();
action.addStringProperty("url");
action.addStringProperty("parseExpression");
// add 1:n relation for rule -> actions
Property ruleId = action.addLongProperty("ruleId").notNull().getProperty();
rule.addToMany(action, ruleId, "actions");
// add "keep" sections
action.setHasKeepSections(true);
}
示例14: addOverview
import de.greenrobot.daogenerator.Property; //导入依赖的package包/类
/**
* Add overview entity.
*
* @param schema - database schema
*/
private static void addOverview(Schema schema) {
overview = schema.addEntity("Overview");
overview.addLongProperty("overviewId").primaryKey().autoincrement();
overview.addDoubleProperty("average");
overview.addIntProperty("participants");
overview.addIntProperty("section1");
overview.addIntProperty("section2");
overview.addIntProperty("section3");
overview.addIntProperty("section4");
overview.addIntProperty("section5");
overview.addIntProperty("userSection");
overview.addStringProperty("gradeEntryHash");
overview.setHasKeepSections(true);
// add 1:1 relation for gradeEntry -> overview
Property overviewId = gradeEntry.addLongProperty("overviewId").getProperty();
gradeEntry.addToOne(overview, overviewId);
}
示例15: main
import de.greenrobot.daogenerator.Property; //导入依赖的package包/类
public static void main(String[] args) {
Schema schema = new Schema(1, "br.com.leofarage.ckl.challenge.database.DAO");
article = schema.addEntity("Article");
article.addIdProperty();
Property webSiteProperty = article.addStringProperty("website").unique().notNull().getProperty();
Property titleProperty = article.addStringProperty("title").unique().notNull().getProperty();
article.addDateProperty("date").notNull();
Property authorsProperty = article.addStringProperty("authors").unique().notNull().getProperty();
Index index = new Index();
index.addProperty(authorsProperty);
index.addProperty(titleProperty);
index.addProperty(webSiteProperty);
article.addIndex(index);
extracted(schema);
}