Class Entity
- java.lang.Object
-
- org.greenrobot.greendao.generator.Entity
-
public class Entity extends java.lang.ObjectModel class for an entity: a Java data object mapped to a data base table. A new entity is added to aSchemaby the methodSchema.addEntity(String)(there is no public constructor forEntityitself).
Use the various addXXX methods to add entity properties, indexes, and relations to other entities (addToOne, addToMany).
There are further configuration possibilities:implementsInterface(String...)andimplementsSerializable()to specify interfaces the entity will implementsetSuperclass(String)to specify a class of which the entity will extend from- Various setXXX methods
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Property.PropertyBuilderaddBooleanProperty(java.lang.String propertyName)Property.PropertyBuilderaddByteArrayProperty(java.lang.String propertyName)Property.PropertyBuilderaddByteProperty(java.lang.String propertyName)ContentProvideraddContentProvider()Property.PropertyBuilderaddDateProperty(java.lang.String propertyName)Property.PropertyBuilderaddDoubleProperty(java.lang.String propertyName)Property.PropertyBuilderaddFloatProperty(java.lang.String propertyName)Property.PropertyBuilderaddIdProperty()Adds a standard _id column required by standard Android classes, e.g.EntityaddImport(java.lang.String additionalImport)protected voidaddIncomingToMany(ToMany toMany)EntityaddIndex(Index index)Adds a new index to the entity.Property.PropertyBuilderaddIntProperty(java.lang.String propertyName)Property.PropertyBuilderaddLongProperty(java.lang.String propertyName)Property.PropertyBuilderaddProperty(PropertyType propertyType, java.lang.String propertyName)Property.PropertyBuilderaddShortProperty(java.lang.String propertyName)Property.PropertyBuilderaddStringProperty(java.lang.String propertyName)ToManyWithJoinEntityaddToMany(Entity target, Entity joinEntity, Property id1, Property id2)ToManyaddToMany(Entity target, Property targetProperty)Adds a to-many relationship; the target entity is joined to the PK property of this entity (typically the ID).ToManyaddToMany(Entity target, Property targetProperty, java.lang.String name)Convenience method foraddToMany(Entity, Property)with a subsequent call toToManyBase.setName(String).ToManyaddToMany(Property[] sourceProperties, Entity target, Property[] targetProperties)ToManyaddToMany(Property sourceProperty, Entity target, Property targetProperty)Add a to-many relationship; the target entity is joined using the given target property (of the target entity) and given source property (of this entity).ToOneaddToOne(Entity target, Property fkProperty)Adds a to-one relationship to the given target entity using the given given foreign key property (which belongs to this entity).ToOneaddToOne(Entity target, Property fkProperty, java.lang.String name)Convenience foraddToOne(Entity, Property)with a subsequent call toToOne.setName(String).ToOneaddToOneWithoutProperty(java.lang.String name, Entity target, java.lang.String fkColumnName)ToOneaddToOneWithoutProperty(java.lang.String name, Entity target, java.lang.String fkColumnName, boolean notNull, boolean unique)java.lang.BooleangetActive()java.util.Collection<java.lang.String>getAdditionalImportsDao()java.util.Collection<java.lang.String>getAdditionalImportsEntity()java.lang.StringgetClassName()java.lang.StringgetClassNameDao()java.lang.StringgetClassNameTest()java.lang.StringgetCodeBeforeClass()java.util.List<ContentProvider>getContentProviders()java.lang.StringgetDbName()java.lang.BooleangetHasKeepSections()java.util.List<ToManyBase>getIncomingToManyRelations()java.util.List<Index>getIndexes()java.util.List<java.lang.String>getInterfacesToImplement()java.lang.StringgetJavaDoc()java.lang.StringgetJavaPackage()java.lang.StringgetJavaPackageDao()java.lang.StringgetJavaPackageTest()java.util.List<Index>getMultiIndexes()PropertygetPkProperty()Internal property used by templates, don't use during entity definition.java.lang.StringgetPkType()Internal property used by templates, don't use during entity definition.java.util.List<Property>getProperties()java.util.List<Property>getPropertiesColumns()java.util.List<Property>getPropertiesNonPk()Internal property used by templates, don't use during entity definition.java.util.List<Property>getPropertiesPk()Internal property used by templates, don't use during entity definition.SchemagetSchema()java.lang.StringgetSuperclass()java.util.List<ToManyBase>getToManyRelations()java.util.List<ToOne>getToOneRelations()voidimplementsInterface(java.lang.String... interfaces)voidimplementsSerializable()protected voidinit2ndPassIndexNamesWithDefaults()protected voidinit2ndPassNamesWithDefaults()booleanisConstructors()booleanisNonDefaultDbName()booleanisProtobuf()booleanisSkipCreationInDb()booleanisSkipGeneration()booleanisSkipGenerationTest()voidsetActive(java.lang.Boolean active)Entities with relations are active, but this method allows to make the entities active even if it does not have relations.voidsetClassNameDao(java.lang.String classNameDao)voidsetClassNameTest(java.lang.String classNameTest)voidsetCodeBeforeClass(java.lang.String codeBeforeClass)voidsetConstructors(boolean constructors)Flag to define if constructors should be generated.voidsetDbName(java.lang.String dbName)voidsetHasKeepSections(java.lang.Boolean hasKeepSections)voidsetJavaDoc(java.lang.String javaDoc)voidsetJavaPackage(java.lang.String javaPackage)voidsetJavaPackageDao(java.lang.String javaPackageDao)voidsetJavaPackageTest(java.lang.String javaPackageTest)voidsetSkipCreationInDb(boolean skipCreationInDb)Flag if CREATE and DROP TABLE scripts should be skipped in Dao.voidsetSkipGeneration(boolean skipGeneration)Flag if the entity's code generation should be skipped.voidsetSkipGenerationTest(boolean skipGenerationTest)voidsetSkipTableCreation(boolean skipTableCreation)Deprecated.voidsetSuperclass(java.lang.String classToExtend)voidsetTableName(java.lang.String tableName)Deprecated.java.lang.StringtoString()voidvalidatePropertyExists(Property property)
-
-
-
Method Detail
-
addBooleanProperty
public Property.PropertyBuilder addBooleanProperty(java.lang.String propertyName)
-
addByteProperty
public Property.PropertyBuilder addByteProperty(java.lang.String propertyName)
-
addShortProperty
public Property.PropertyBuilder addShortProperty(java.lang.String propertyName)
-
addIntProperty
public Property.PropertyBuilder addIntProperty(java.lang.String propertyName)
-
addLongProperty
public Property.PropertyBuilder addLongProperty(java.lang.String propertyName)
-
addFloatProperty
public Property.PropertyBuilder addFloatProperty(java.lang.String propertyName)
-
addDoubleProperty
public Property.PropertyBuilder addDoubleProperty(java.lang.String propertyName)
-
addByteArrayProperty
public Property.PropertyBuilder addByteArrayProperty(java.lang.String propertyName)
-
addStringProperty
public Property.PropertyBuilder addStringProperty(java.lang.String propertyName)
-
addDateProperty
public Property.PropertyBuilder addDateProperty(java.lang.String propertyName)
-
addProperty
public Property.PropertyBuilder addProperty(PropertyType propertyType, java.lang.String propertyName)
-
addIdProperty
public Property.PropertyBuilder addIdProperty()
Adds a standard _id column required by standard Android classes, e.g. list adapters.
-
addToMany
public ToMany addToMany(Entity target, Property targetProperty)
Adds a to-many relationship; the target entity is joined to the PK property of this entity (typically the ID).
-
addToMany
public ToMany addToMany(Entity target, Property targetProperty, java.lang.String name)
Convenience method foraddToMany(Entity, Property)with a subsequent call toToManyBase.setName(String).
-
addToMany
public ToMany addToMany(Property sourceProperty, Entity target, Property targetProperty)
Add a to-many relationship; the target entity is joined using the given target property (of the target entity) and given source property (of this entity).
-
addToMany
public ToMany addToMany(Property[] sourceProperties, Entity target, Property[] targetProperties)
-
addToMany
public ToManyWithJoinEntity addToMany(Entity target, Entity joinEntity, Property id1, Property id2)
-
addToOne
public ToOne addToOne(Entity target, Property fkProperty)
Adds a to-one relationship to the given target entity using the given given foreign key property (which belongs to this entity).
-
addToOne
public ToOne addToOne(Entity target, Property fkProperty, java.lang.String name)
Convenience foraddToOne(Entity, Property)with a subsequent call toToOne.setName(String).
-
addToOneWithoutProperty
public ToOne addToOneWithoutProperty(java.lang.String name, Entity target, java.lang.String fkColumnName)
-
addToOneWithoutProperty
public ToOne addToOneWithoutProperty(java.lang.String name, Entity target, java.lang.String fkColumnName, boolean notNull, boolean unique)
-
addIncomingToMany
protected void addIncomingToMany(ToMany toMany)
-
addContentProvider
public ContentProvider addContentProvider()
-
addImport
public Entity addImport(java.lang.String additionalImport)
-
isProtobuf
public boolean isProtobuf()
-
getSchema
public Schema getSchema()
-
getDbName
public java.lang.String getDbName()
-
setTableName
@Deprecated public void setTableName(java.lang.String tableName)
Deprecated.
-
setDbName
public void setDbName(java.lang.String dbName)
-
getClassName
public java.lang.String getClassName()
-
getProperties
public java.util.List<Property> getProperties()
-
getPropertiesColumns
public java.util.List<Property> getPropertiesColumns()
-
getJavaPackage
public java.lang.String getJavaPackage()
-
setJavaPackage
public void setJavaPackage(java.lang.String javaPackage)
-
getJavaPackageDao
public java.lang.String getJavaPackageDao()
-
setJavaPackageDao
public void setJavaPackageDao(java.lang.String javaPackageDao)
-
getClassNameDao
public java.lang.String getClassNameDao()
-
setClassNameDao
public void setClassNameDao(java.lang.String classNameDao)
-
getClassNameTest
public java.lang.String getClassNameTest()
-
setClassNameTest
public void setClassNameTest(java.lang.String classNameTest)
-
getJavaPackageTest
public java.lang.String getJavaPackageTest()
-
setJavaPackageTest
public void setJavaPackageTest(java.lang.String javaPackageTest)
-
getPropertiesPk
public java.util.List<Property> getPropertiesPk()
Internal property used by templates, don't use during entity definition.
-
getPropertiesNonPk
public java.util.List<Property> getPropertiesNonPk()
Internal property used by templates, don't use during entity definition.
-
getPkProperty
public Property getPkProperty()
Internal property used by templates, don't use during entity definition.
-
getIndexes
public java.util.List<Index> getIndexes()
-
getPkType
public java.lang.String getPkType()
Internal property used by templates, don't use during entity definition.
-
isConstructors
public boolean isConstructors()
-
setConstructors
public void setConstructors(boolean constructors)
Flag to define if constructors should be generated.
-
isSkipGeneration
public boolean isSkipGeneration()
-
setSkipGeneration
public void setSkipGeneration(boolean skipGeneration)
Flag if the entity's code generation should be skipped. E.g. if you need to change the class after initial generation.
-
setSkipTableCreation
@Deprecated public void setSkipTableCreation(boolean skipTableCreation)
Deprecated.
-
setSkipCreationInDb
public void setSkipCreationInDb(boolean skipCreationInDb)
Flag if CREATE and DROP TABLE scripts should be skipped in Dao.
-
isSkipCreationInDb
public boolean isSkipCreationInDb()
-
isSkipGenerationTest
public boolean isSkipGenerationTest()
-
setSkipGenerationTest
public void setSkipGenerationTest(boolean skipGenerationTest)
-
getToOneRelations
public java.util.List<ToOne> getToOneRelations()
-
getToManyRelations
public java.util.List<ToManyBase> getToManyRelations()
-
getIncomingToManyRelations
public java.util.List<ToManyBase> getIncomingToManyRelations()
-
setActive
public void setActive(java.lang.Boolean active)
Entities with relations are active, but this method allows to make the entities active even if it does not have relations.
-
getActive
public java.lang.Boolean getActive()
-
getHasKeepSections
public java.lang.Boolean getHasKeepSections()
-
getAdditionalImportsEntity
public java.util.Collection<java.lang.String> getAdditionalImportsEntity()
-
getAdditionalImportsDao
public java.util.Collection<java.lang.String> getAdditionalImportsDao()
-
setHasKeepSections
public void setHasKeepSections(java.lang.Boolean hasKeepSections)
-
getInterfacesToImplement
public java.util.List<java.lang.String> getInterfacesToImplement()
-
getContentProviders
public java.util.List<ContentProvider> getContentProviders()
-
implementsInterface
public void implementsInterface(java.lang.String... interfaces)
-
implementsSerializable
public void implementsSerializable()
-
getSuperclass
public java.lang.String getSuperclass()
-
setSuperclass
public void setSuperclass(java.lang.String classToExtend)
-
getJavaDoc
public java.lang.String getJavaDoc()
-
setJavaDoc
public void setJavaDoc(java.lang.String javaDoc)
-
getCodeBeforeClass
public java.lang.String getCodeBeforeClass()
-
setCodeBeforeClass
public void setCodeBeforeClass(java.lang.String codeBeforeClass)
-
init2ndPassNamesWithDefaults
protected void init2ndPassNamesWithDefaults()
-
init2ndPassIndexNamesWithDefaults
protected void init2ndPassIndexNamesWithDefaults()
-
validatePropertyExists
public void validatePropertyExists(Property property)
-
getMultiIndexes
public java.util.List<Index> getMultiIndexes()
-
isNonDefaultDbName
public boolean isNonDefaultDbName()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-