Package io.objectbox.generator.model
Class Entity
- java.lang.Object
-
- io.objectbox.generator.model.Entity
-
- All Implemented Interfaces:
HasParsedElement
public class Entity extends java.lang.Object implements HasParsedElement
Model class for an entity: a Java data object mapped to a data base representation. A new entity is added to aSchemabySchema.addEntity(String).Use the various add methods to add entity properties, indexes, and relations to other entities (addToOne, addToMany).
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Property.PropertyBuilderaddIdProperty()Adds a standard id property.EntityaddIndex(io.objectbox.generator.model.Index index)Adds a new index to the entity.Property.PropertyBuilderaddProperty(PropertyType propertyType, java.lang.String propertyName)io.objectbox.generator.model.ToManyStandaloneaddToMany(io.objectbox.generator.model.ToManyStandalone toMany, Entity target)Adds a (stand-alone) to-many relation (ToManyStandalone) to another entity.io.objectbox.generator.model.ToManyByBacklinkaddToManyByToManyBacklink(io.objectbox.generator.model.ToManyByBacklink toMany, Entity targetEntity, io.objectbox.generator.model.ToManyStandalone targetToMany)Adds a to-many relation based on a (stand-alone) to-many relation (addToMany(io.objectbox.generator.model.ToManyStandalone, io.objectbox.generator.model.Entity)) from another entity to this entity.io.objectbox.generator.model.ToManyByBacklinkaddToManyByToOneBacklink(io.objectbox.generator.model.ToManyByBacklink toMany, Entity targetEntity, io.objectbox.generator.model.ToOne targetToOne)Adds a to-many relation based on a to-one relation (addToOne(io.objectbox.generator.model.ToOne, io.objectbox.generator.model.Entity)) from another entity to this entity.io.objectbox.generator.model.ToOneaddToOne(io.objectbox.generator.model.ToOne toOne, Entity target)Adds a to-one relationship to the given target entity.voidcomputeEntityFlags()Based on this entities attributes computes requiredEntityFlags.PropertyfindPropertyByName(java.lang.String name)java.util.Collection<java.lang.String>getAdditionalImportsDao()java.lang.StringgetClassName()java.lang.StringgetClassNameDao()java.lang.StringgetDbName()intgetEntityFlags()Returns combinedEntityFlagsvalue.java.lang.IntegergetEntityFlagsForModelFile()Returns combinedEntityFlagsvalue of only those flags that should be stored in the model file.java.util.Set<java.lang.String>getEntityFlagsNames()Returns names ofEntityFlags.booleangetHasBoxStoreField()java.util.List<ToManyBase>getIncomingToManyRelations()java.util.List<io.objectbox.generator.model.Index>getIndexes()java.lang.StringgetJavaPackage()java.lang.StringgetJavaPackageDao()io.objectbox.generator.IdUidgetLastPropertyId()java.lang.IntegergetModelId()java.lang.LonggetModelUid()java.util.List<io.objectbox.generator.model.Index>getMultiIndexes()java.lang.ObjectgetParsedElement()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>getPropertiesPk()Internal property used by templates, don't use during entity definition.SchemagetSchema()java.util.List<ToManyBase>getToManyRelations()java.util.List<io.objectbox.generator.model.ToOne>getToOneRelations()booleanhasAllArgsConstructor()booleanhasRelations()protected voidinit2ndPassNamesWithDefaults()booleanisSyncEnabled()booleanisSyncSharedGlobalIds()voidsetClassNameDao(java.lang.String classNameDao)voidsetDbName(java.lang.String dbName)voidsetHasAllArgsConstructor(boolean hasAllArgsConstructor)Set to indicate the associated class has a constructor with an argument for every property available.voidsetHasBoxStoreField(boolean hasBoxStoreField)voidsetJavaPackage(java.lang.String javaPackage)voidsetJavaPackageDao(java.lang.String javaPackageDao)EntitysetLastPropertyId(io.objectbox.generator.IdUid lastPropertyId)EntitysetModelId(java.lang.Integer modelId)EntitysetModelUid(java.lang.Long modelUid)voidsetParsedElement(java.lang.Object parsedElement)voidsetSyncEnabled(boolean syncEnabled)voidsetSyncSharedGlobalIds(boolean enabled)java.lang.StringtoString()
-
-
-
Method Detail
-
setModelId
public Entity setModelId(java.lang.Integer modelId)
-
getModelId
public java.lang.Integer getModelId()
-
setModelUid
public Entity setModelUid(java.lang.Long modelUid)
-
getModelUid
public java.lang.Long getModelUid()
-
getLastPropertyId
public io.objectbox.generator.IdUid getLastPropertyId()
-
setLastPropertyId
public Entity setLastPropertyId(io.objectbox.generator.IdUid lastPropertyId)
-
addProperty
public Property.PropertyBuilder addProperty(PropertyType propertyType, java.lang.String propertyName) throws ModelException
- Throws:
ModelException
-
addIdProperty
public Property.PropertyBuilder addIdProperty() throws ModelException
Adds a standard id property.- Throws:
ModelException
-
addToManyByToOneBacklink
public io.objectbox.generator.model.ToManyByBacklink addToManyByToOneBacklink(io.objectbox.generator.model.ToManyByBacklink toMany, Entity targetEntity, io.objectbox.generator.model.ToOne targetToOne) throws ModelExceptionAdds a to-many relation based on a to-one relation (addToOne(io.objectbox.generator.model.ToOne, io.objectbox.generator.model.Entity)) from another entity to this entity.- Throws:
ModelException- if this entity already has a property or relation withname.
-
addToManyByToManyBacklink
public io.objectbox.generator.model.ToManyByBacklink addToManyByToManyBacklink(io.objectbox.generator.model.ToManyByBacklink toMany, Entity targetEntity, io.objectbox.generator.model.ToManyStandalone targetToMany) throws ModelExceptionAdds a to-many relation based on a (stand-alone) to-many relation (addToMany(io.objectbox.generator.model.ToManyStandalone, io.objectbox.generator.model.Entity)) from another entity to this entity.- Throws:
ModelException- if this entity already has a property or relation withname.
-
addToMany
public io.objectbox.generator.model.ToManyStandalone addToMany(io.objectbox.generator.model.ToManyStandalone toMany, Entity target) throws ModelExceptionAdds a (stand-alone) to-many relation (ToManyStandalone) to another entity.- Throws:
ModelException- if this entity already has a property or relation withname.
-
addToOne
public io.objectbox.generator.model.ToOne addToOne(io.objectbox.generator.model.ToOne toOne, Entity target) throws ModelExceptionAdds a to-one relationship to the given target entity.- Throws:
ModelException- if this entity already has a property or relation withname.
-
addIndex
public Entity addIndex(io.objectbox.generator.model.Index index)
Adds a new index to the entity.
-
getSchema
public Schema getSchema()
-
getDbName
public java.lang.String getDbName()
-
setDbName
public void setDbName(java.lang.String dbName)
-
getClassName
public java.lang.String getClassName()
-
getProperties
public java.util.List<Property> getProperties()
-
findPropertyByName
public Property findPropertyByName(java.lang.String name)
-
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)
-
getPropertiesPk
public java.util.List<Property> getPropertiesPk()
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<io.objectbox.generator.model.Index> getIndexes()
-
getPkType
public java.lang.String getPkType()
Internal property used by templates, don't use during entity definition.
-
hasAllArgsConstructor
public boolean hasAllArgsConstructor()
-
setHasAllArgsConstructor
public void setHasAllArgsConstructor(boolean hasAllArgsConstructor)
Set to indicate the associated class has a constructor with an argument for every property available.
-
hasRelations
public boolean hasRelations()
-
getToOneRelations
public java.util.List<io.objectbox.generator.model.ToOne> getToOneRelations()
-
getToManyRelations
public java.util.List<ToManyBase> getToManyRelations()
-
getIncomingToManyRelations
public java.util.List<ToManyBase> getIncomingToManyRelations()
-
getAdditionalImportsDao
public java.util.Collection<java.lang.String> getAdditionalImportsDao()
-
getHasBoxStoreField
public boolean getHasBoxStoreField()
-
setHasBoxStoreField
public void setHasBoxStoreField(boolean hasBoxStoreField)
-
init2ndPassNamesWithDefaults
protected void init2ndPassNamesWithDefaults()
-
getMultiIndexes
public java.util.List<io.objectbox.generator.model.Index> getMultiIndexes()
-
getParsedElement
public java.lang.Object getParsedElement()
- Specified by:
getParsedElementin interfaceHasParsedElement
-
setParsedElement
public void setParsedElement(java.lang.Object parsedElement)
- Specified by:
setParsedElementin interfaceHasParsedElement
-
isSyncEnabled
public boolean isSyncEnabled()
-
setSyncEnabled
public void setSyncEnabled(boolean syncEnabled)
-
isSyncSharedGlobalIds
public boolean isSyncSharedGlobalIds()
-
setSyncSharedGlobalIds
public void setSyncSharedGlobalIds(boolean enabled)
-
computeEntityFlags
public void computeEntityFlags()
Based on this entities attributes computes requiredEntityFlags.
-
getEntityFlags
public int getEntityFlags()
Returns combinedEntityFlagsvalue.
-
getEntityFlagsForModelFile
@Nullable public java.lang.Integer getEntityFlagsForModelFile()
Returns combinedEntityFlagsvalue of only those flags that should be stored in the model file. Returns null if there would be no flags.
-
getEntityFlagsNames
public java.util.Set<java.lang.String> getEntityFlagsNames()
Returns names ofEntityFlags.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-