public class ToOne<TARGET>
extends java.lang.Object
implements java.io.Serializable
If there is a ToMany relation linking back to this to-one relation (@Backlink),
the ToMany object will not be notified/updated about persisted changes here.
Call ToMany.reset() so it will update when next accessed.
| Constructor and Description |
|---|
ToOne(java.lang.Object sourceEntity,
RelationInfo<?,TARGET> relationInfo)
In Java, the constructor call is generated by the ObjectBox plugin.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj) |
TARGET |
getCachedTarget() |
TARGET |
getTarget() |
TARGET |
getTarget(long targetId)
If property backed, entities can pass the target ID to avoid reflection.
|
long |
getTargetId() |
int |
hashCode() |
void |
internalPutTarget(io.objectbox.Cursor<TARGET> targetCursor) |
boolean |
internalRequiresPutTarget() |
boolean |
isNull() |
boolean |
isResolved() |
boolean |
isResolvedAndNotNull() |
void |
setAndPutTarget(TARGET target)
Sets or clears the target entity and ID in the source entity, then puts the source entity to persist changes.
|
void |
setAndPutTargetAlways(TARGET target)
Sets or clears the target entity and ID in the source entity,
then puts the target (if not null) and source entity to persist changes.
|
void |
setTarget(TARGET target)
Sets or clears the target entity and ID in the source entity.
|
void |
setTargetId(long targetId)
Sets or clears the target ID in the source entity.
|
public ToOne(java.lang.Object sourceEntity,
RelationInfo<?,TARGET> relationInfo)
sourceEntity - The source entity that owns the to-one relation.relationInfo - Meta info as generated in the Entity_ (entity name plus underscore) classes.public TARGET getTarget()
@Internal public TARGET getTarget(long targetId)
public TARGET getCachedTarget()
public boolean isResolved()
public boolean isResolvedAndNotNull()
public boolean isNull()
public void setTargetId(long targetId)
Put the source entity to persist changes. If the ID is not 0 creates a relation to the target entity with this ID, otherwise dissolves it.
setTarget(TARGET)public void setTarget(@Nullable
TARGET target)
Put the source entity to persist changes. If the target entity was not put yet (its ID is 0), it will be stored when the source entity is put.
setTargetId(long)public void setAndPutTarget(@Nullable
TARGET target)
If the target entity was not put yet (its ID is 0), it will be put before the source entity.
public void setAndPutTargetAlways(@Nullable
TARGET target)
When clearing the target entity, this does not remove it from its box. This only dissolves the relation.
public long getTargetId()
@Internal public boolean internalRequiresPutTarget()
@Internal public void internalPutTarget(io.objectbox.Cursor<TARGET> targetCursor)
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object