Package io.objectbox.generator.model
Class Property
- java.lang.Object
-
- io.objectbox.generator.model.Property
-
- All Implemented Interfaces:
HasParsedElement
public class Property extends java.lang.Object implements HasParsedElement
Model class for an entity's property: a Java property mapped to a data base representation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classProperty.PropertyBuilder
-
Constructor Summary
Constructors Constructor Description Property(Schema schema, Entity entity, PropertyType propertyType, java.lang.String propertyName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcomputePropertyFlags()Based on this properties attributes computes requiredPropertyFlags.java.lang.StringgetConverter()java.lang.StringgetConverterClassName()java.lang.StringgetCustomType()java.lang.StringgetCustomTypeClassName()java.lang.StringgetDatabaseValueExpression()java.lang.StringgetDatabaseValueExpression(java.lang.String entityValue)java.lang.StringgetDbName()java.lang.StringgetDbType()String representation of aPropertyTypeenum.java.lang.ShortgetDbTypeId()ID of thePropertyType.EntitygetEntity()java.lang.StringgetGetterMethodName()io.objectbox.generator.model.IndexgetIndex()Note: index is not set until after finishing schema.java.lang.StringgetJavaRawType()If the Java type is generic, returns the raw type.java.lang.StringgetJavaType()Returns the type including type parameters, e.g.java.lang.StringgetJavaTypeInEntity()io.objectbox.generator.IdUidgetModelId()io.objectbox.generator.IdUidgetModelIndexId()intgetOrdinal()java.lang.ObjectgetParsedElement()java.util.Set<java.lang.String>getPropertyFlagsForGeneratedCode()Returns names ofPropertyFlagsto be used in generated model builder code.java.lang.IntegergetPropertyFlagsForModelFile()Returns combinedPropertyFlagsvalue of only those flags that should be stored in the model file.java.lang.StringgetPropertyName()PropertyTypegetPropertyType()java.lang.StringgetSetValueExpression(java.lang.String value)EntitygetTargetEntity()java.lang.StringgetValueExpression()java.lang.StringgetVirtualTargetName()java.lang.StringgetVirtualTargetValueExpression()booleanisIdAssignable()IfPropertyFlags.ID_SELF_ASSIGNABLEshould be set on this property.booleanisIdCompanion()IfPropertyFlags.ID_COMPANIONshould be set on this property.booleanisNonPrimitiveFlag()IfPropertyFlags.NON_PRIMITIVE_TYPEshould be set on this property.booleanisNotNullFlag()IfPropertyFlags.NOT_NULLshould be set on this property.booleanisPrimaryKey()If this property is a primary key andPropertyFlags.IDshould be set.booleanisTypeNotNull()If a property value may never be null, so e.g.booleanisUnsigned()IfPropertyFlags.UNSIGNEDshould be set on this property.booleanisVirtual()If this property does not actually exist in the entity class, but only in the model andPropertyFlags.VIRTUALshould be set.voidsetIndex(io.objectbox.generator.model.Index index)voidsetModelId(io.objectbox.generator.IdUid modelId)voidsetModelIndexId(io.objectbox.generator.IdUid modelIndexId)voidsetParsedElement(java.lang.Object parsedElement)java.lang.StringtoString()
-
-
-
Constructor Detail
-
Property
public Property(Schema schema, Entity entity, PropertyType propertyType, java.lang.String propertyName)
-
-
Method Detail
-
getPropertyName
public java.lang.String getPropertyName()
-
getPropertyType
public PropertyType getPropertyType()
-
getModelId
public io.objectbox.generator.IdUid getModelId()
-
setModelId
public void setModelId(io.objectbox.generator.IdUid modelId)
-
getModelIndexId
public io.objectbox.generator.IdUid getModelIndexId()
-
setModelIndexId
public void setModelIndexId(io.objectbox.generator.IdUid modelIndexId)
-
getDbName
public java.lang.String getDbName()
-
getDbType
public java.lang.String getDbType()
String representation of aPropertyTypeenum.
-
getDbTypeId
public java.lang.Short getDbTypeId()
ID of thePropertyType.
-
isPrimaryKey
public boolean isPrimaryKey()
If this property is a primary key andPropertyFlags.IDshould be set.
-
isIdCompanion
public boolean isIdCompanion()
IfPropertyFlags.ID_COMPANIONshould be set on this property.
-
isTypeNotNull
public boolean isTypeNotNull()
If a property value may never be null, so e.g. null checks in generated code are not necessary.Note: this is not related to
PropertyFlags.NOT_NULL, useisNotNullFlag()instead.
-
isNotNullFlag
public boolean isNotNullFlag()
IfPropertyFlags.NOT_NULLshould be set on this property.Note: this does not indicate if the property value may never be null, use
isTypeNotNull()instead.
-
isNonPrimitiveFlag
public boolean isNonPrimitiveFlag()
IfPropertyFlags.NON_PRIMITIVE_TYPEshould be set on this property.Note: use
isTypeNotNull()instead to check if the property value can be null.
-
isUnsigned
public boolean isUnsigned()
IfPropertyFlags.UNSIGNEDshould be set on this property.
-
isIdAssignable
public boolean isIdAssignable()
IfPropertyFlags.ID_SELF_ASSIGNABLEshould be set on this property.
-
getJavaType
public java.lang.String getJavaType()
Returns the type including type parameters, e.g.List<String>.
-
getJavaRawType
public java.lang.String getJavaRawType()
If the Java type is generic, returns the raw type. E.g.Listinstead ofList<String>. Otherwise, returns the same asgetJavaType().
-
getJavaTypeInEntity
public java.lang.String getJavaTypeInEntity()
-
getOrdinal
public int getOrdinal()
-
getCustomType
public java.lang.String getCustomType()
-
getCustomTypeClassName
public java.lang.String getCustomTypeClassName()
-
getConverter
public java.lang.String getConverter()
-
getConverterClassName
public java.lang.String getConverterClassName()
-
isVirtual
public boolean isVirtual()
If this property does not actually exist in the entity class, but only in the model andPropertyFlags.VIRTUALshould be set.
-
getVirtualTargetValueExpression
public java.lang.String getVirtualTargetValueExpression()
-
getVirtualTargetName
public java.lang.String getVirtualTargetName()
-
getGetterMethodName
public java.lang.String getGetterMethodName()
-
getTargetEntity
public Entity getTargetEntity()
-
getValueExpression
public java.lang.String getValueExpression()
-
getSetValueExpression
public java.lang.String getSetValueExpression(java.lang.String value)
-
getDatabaseValueExpression
public java.lang.String getDatabaseValueExpression()
-
getDatabaseValueExpression
public java.lang.String getDatabaseValueExpression(java.lang.String entityValue)
-
getEntity
public Entity getEntity()
-
getIndex
@Nullable public io.objectbox.generator.model.Index getIndex()
Note: index is not set until after finishing schema.
-
setIndex
public void setIndex(io.objectbox.generator.model.Index index)
-
getParsedElement
public java.lang.Object getParsedElement()
- Specified by:
getParsedElementin interfaceHasParsedElement
-
setParsedElement
public void setParsedElement(java.lang.Object parsedElement)
- Specified by:
setParsedElementin interfaceHasParsedElement
-
computePropertyFlags
public void computePropertyFlags()
Based on this properties attributes computes requiredPropertyFlags.
-
getPropertyFlagsForModelFile
@Nullable public java.lang.Integer getPropertyFlagsForModelFile()
Returns combinedPropertyFlagsvalue of only those flags that should be stored in the model file. Returns null if there would be no flags.These may be different from
getPropertyFlagsForGeneratedCode(), seecomputePropertyFlags().
-
getPropertyFlagsForGeneratedCode
public java.util.Set<java.lang.String> getPropertyFlagsForGeneratedCode()
Returns names ofPropertyFlagsto be used in generated model builder code.These may be different from
getPropertyFlagsForModelFile(), seecomputePropertyFlags().
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-