Package io.objectbox.relation
Class RelationInfo<SOURCE,TARGET>
- java.lang.Object
-
- io.objectbox.relation.RelationInfo<SOURCE,TARGET>
-
- All Implemented Interfaces:
java.io.Serializable
@Internal @Immutable public class RelationInfo<SOURCE,TARGET> extends java.lang.Object implements java.io.Serializable
Meta info describing a relation including source and target entity.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description io.objectbox.internal.ToManyGetter<TARGET,SOURCE>
backlinkToManyGetter
For ToMany relations based on ToMany backlinks (null otherwise).io.objectbox.internal.ToOneGetter<TARGET,SOURCE>
backlinkToOneGetter
For ToMany relations based on ToOne backlinks (null otherwise).int
relationId
For stand-alone to-many relations (0 otherwise).EntityInfo<SOURCE>
sourceInfo
Property<?>
targetIdProperty
For relations based on a target ID property (null otherwise).EntityInfo<TARGET>
targetInfo
int
targetRelationId
For ToMany relations based on ToMany backlinks (0 otherwise).io.objectbox.internal.ToManyGetter<SOURCE,TARGET>
toManyGetter
Only set for ToMany relationsio.objectbox.internal.ToOneGetter<SOURCE,TARGET>
toOneGetter
Only set for ToOne relations
-
Constructor Summary
Constructors Constructor Description RelationInfo(EntityInfo<SOURCE> sourceInfo, EntityInfo<TARGET> targetInfo, io.objectbox.internal.ToManyGetter<SOURCE,TARGET> toManyGetter, int relationId)
Stand-alone ToMany.RelationInfo(EntityInfo<SOURCE> sourceInfo, EntityInfo<TARGET> targetInfo, io.objectbox.internal.ToManyGetter<SOURCE,TARGET> toManyGetter, io.objectbox.internal.ToManyGetter<TARGET,SOURCE> backlinkToManyGetter, int targetRelationId)
ToMany as a ToMany backlinkRelationInfo(EntityInfo<SOURCE> sourceInfo, EntityInfo<TARGET> targetInfo, io.objectbox.internal.ToManyGetter<SOURCE,TARGET> toManyGetter, Property<TARGET> targetIdProperty, io.objectbox.internal.ToOneGetter<TARGET,SOURCE> backlinkToOneGetter)
ToMany as a ToOne backlinkRelationInfo(EntityInfo<SOURCE> sourceInfo, EntityInfo<TARGET> targetInfo, Property<SOURCE> targetIdProperty, io.objectbox.internal.ToOneGetter<SOURCE,TARGET> toOneGetter)
ToOne
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isBacklink()
QueryCondition<SOURCE>
relationCount(int relationCount)
Creates a condition to match objects that haverelationCount
related objects pointing to them.java.lang.String
toString()
-
-
-
Field Detail
-
sourceInfo
public final EntityInfo<SOURCE> sourceInfo
-
targetInfo
public final EntityInfo<TARGET> targetInfo
-
targetIdProperty
public final Property<?> targetIdProperty
For relations based on a target ID property (null otherwise).
-
targetRelationId
public final int targetRelationId
For ToMany relations based on ToMany backlinks (0 otherwise).
-
toOneGetter
public final io.objectbox.internal.ToOneGetter<SOURCE,TARGET> toOneGetter
Only set for ToOne relations
-
toManyGetter
public final io.objectbox.internal.ToManyGetter<SOURCE,TARGET> toManyGetter
Only set for ToMany relations
-
backlinkToOneGetter
public final io.objectbox.internal.ToOneGetter<TARGET,SOURCE> backlinkToOneGetter
For ToMany relations based on ToOne backlinks (null otherwise).
-
backlinkToManyGetter
public final io.objectbox.internal.ToManyGetter<TARGET,SOURCE> backlinkToManyGetter
For ToMany relations based on ToMany backlinks (null otherwise).
-
relationId
public final int relationId
For stand-alone to-many relations (0 otherwise).
-
-
Constructor Detail
-
RelationInfo
public RelationInfo(EntityInfo<SOURCE> sourceInfo, EntityInfo<TARGET> targetInfo, Property<SOURCE> targetIdProperty, io.objectbox.internal.ToOneGetter<SOURCE,TARGET> toOneGetter)
ToOne
-
RelationInfo
public RelationInfo(EntityInfo<SOURCE> sourceInfo, EntityInfo<TARGET> targetInfo, io.objectbox.internal.ToManyGetter<SOURCE,TARGET> toManyGetter, Property<TARGET> targetIdProperty, io.objectbox.internal.ToOneGetter<TARGET,SOURCE> backlinkToOneGetter)
ToMany as a ToOne backlink
-
RelationInfo
public RelationInfo(EntityInfo<SOURCE> sourceInfo, EntityInfo<TARGET> targetInfo, io.objectbox.internal.ToManyGetter<SOURCE,TARGET> toManyGetter, io.objectbox.internal.ToManyGetter<TARGET,SOURCE> backlinkToManyGetter, int targetRelationId)
ToMany as a ToMany backlink
-
RelationInfo
public RelationInfo(EntityInfo<SOURCE> sourceInfo, EntityInfo<TARGET> targetInfo, io.objectbox.internal.ToManyGetter<SOURCE,TARGET> toManyGetter, int relationId)
Stand-alone ToMany.
-
-
Method Detail
-
isBacklink
public boolean isBacklink()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
relationCount
public QueryCondition<SOURCE> relationCount(int relationCount)
Creates a condition to match objects that haverelationCount
related objects pointing to them.try (Query<Customer> query = customerBox .query(Customer_.orders.relationCount(2)) .build()) { List<Customer> customersWithTwoOrders = query.find(); }
relationCount
may be 0 to match objects that do not have related objects. It typically should be a low number.This condition has some limitations:
- only 1:N (ToMany using @Backlink) relations are supported,
- the complexity is
O(n * (relationCount + 1))
and cannot be improved via indexes, - the relation count cannot be changed with setParameter once the query is built.
-
-