Skip to content

Commit

Permalink
Unchecked warnings: fix type params for ToOneGetter/ToManyGetter (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
greenrobot-team committed Dec 5, 2022
1 parent e109699 commit e5f579d
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
import io.objectbox.annotation.apihint.Internal;

@Internal
public interface ToManyGetter<SOURCE> extends Serializable {
<TARGET> List<TARGET> getToMany(SOURCE object);
public interface ToManyGetter<SOURCE, TARGET> extends Serializable {
List<TARGET> getToMany(SOURCE object);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
import io.objectbox.relation.ToOne;

@Internal
public interface ToOneGetter<SOURCE> extends Serializable {
<TARGET> ToOne<TARGET> getToOne(SOURCE object);
public interface ToOneGetter<SOURCE, TARGET> extends Serializable {
ToOne<TARGET> getToOne(SOURCE object);
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ public class RelationInfo<SOURCE, TARGET> implements Serializable {
public final int targetRelationId;

/** Only set for ToOne relations */
public final ToOneGetter<SOURCE> toOneGetter;
public final ToOneGetter<SOURCE, TARGET> toOneGetter;

/** Only set for ToMany relations */
public final ToManyGetter<SOURCE> toManyGetter;
public final ToManyGetter<SOURCE, TARGET> toManyGetter;

/** For ToMany relations based on ToOne backlinks (null otherwise). */
public final ToOneGetter<TARGET> backlinkToOneGetter;
public final ToOneGetter<TARGET, SOURCE> backlinkToOneGetter;

/** For ToMany relations based on ToMany backlinks (null otherwise). */
public final ToManyGetter<TARGET> backlinkToManyGetter;
public final ToManyGetter<TARGET, SOURCE> backlinkToManyGetter;

/** For stand-alone to-many relations (0 otherwise). */
public final int relationId;
Expand All @@ -64,7 +64,7 @@ public class RelationInfo<SOURCE, TARGET> implements Serializable {
* ToOne
*/
public RelationInfo(EntityInfo<SOURCE> sourceInfo, EntityInfo<TARGET> targetInfo, Property<SOURCE> targetIdProperty,
ToOneGetter<SOURCE> toOneGetter) {
ToOneGetter<SOURCE, TARGET> toOneGetter) {
this.sourceInfo = sourceInfo;
this.targetInfo = targetInfo;
this.targetIdProperty = targetIdProperty;
Expand All @@ -79,8 +79,8 @@ public RelationInfo(EntityInfo<SOURCE> sourceInfo, EntityInfo<TARGET> targetInfo
/**
* ToMany as a ToOne backlink
*/
public RelationInfo(EntityInfo<SOURCE> sourceInfo, EntityInfo<TARGET> targetInfo, ToManyGetter<SOURCE> toManyGetter,
Property<TARGET> targetIdProperty, ToOneGetter<TARGET> backlinkToOneGetter) {
public RelationInfo(EntityInfo<SOURCE> sourceInfo, EntityInfo<TARGET> targetInfo, ToManyGetter<SOURCE, TARGET> toManyGetter,
Property<TARGET> targetIdProperty, ToOneGetter<TARGET, SOURCE> backlinkToOneGetter) {
this.sourceInfo = sourceInfo;
this.targetInfo = targetInfo;
this.targetIdProperty = targetIdProperty;
Expand All @@ -95,8 +95,8 @@ public RelationInfo(EntityInfo<SOURCE> sourceInfo, EntityInfo<TARGET> targetInfo
/**
* ToMany as a ToMany backlink
*/
public RelationInfo(EntityInfo<SOURCE> sourceInfo, EntityInfo<TARGET> targetInfo, ToManyGetter<SOURCE> toManyGetter,
ToManyGetter<TARGET> backlinkToManyGetter, int targetRelationId) {
public RelationInfo(EntityInfo<SOURCE> sourceInfo, EntityInfo<TARGET> targetInfo, ToManyGetter<SOURCE, TARGET> toManyGetter,
ToManyGetter<TARGET, SOURCE> backlinkToManyGetter, int targetRelationId) {
this.sourceInfo = sourceInfo;
this.targetInfo = targetInfo;
this.toManyGetter = toManyGetter;
Expand All @@ -111,7 +111,7 @@ public RelationInfo(EntityInfo<SOURCE> sourceInfo, EntityInfo<TARGET> targetInfo
/**
* Stand-alone ToMany.
*/
public RelationInfo(EntityInfo<SOURCE> sourceInfo, EntityInfo<TARGET> targetInfo, ToManyGetter<SOURCE> toManyGetter,
public RelationInfo(EntityInfo<SOURCE> sourceInfo, EntityInfo<TARGET> targetInfo, ToManyGetter<SOURCE, TARGET> toManyGetter,
int relationId) {
this.sourceInfo = sourceInfo;
this.targetInfo = targetInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ public boolean internalCheckApplyToDbRequired() {

private boolean prepareToManyBacklinkEntitiesForDb(long entityId, IdGetter<TARGET> idGetter,
@Nullable Map<TARGET, Boolean> setAdded, @Nullable Map<TARGET, Boolean> setRemoved) {
ToManyGetter<TARGET> backlinkToManyGetter = relationInfo.backlinkToManyGetter;
ToManyGetter<TARGET, Object> backlinkToManyGetter = relationInfo.backlinkToManyGetter;

synchronized (this) {
if (setAdded != null && !setAdded.isEmpty()) {
Expand Down Expand Up @@ -740,7 +740,7 @@ private boolean prepareToManyBacklinkEntitiesForDb(long entityId, IdGetter<TARGE

private boolean prepareToOneBacklinkEntitiesForDb(long entityId, IdGetter<TARGET> idGetter,
@Nullable Map<TARGET, Boolean> setAdded, @Nullable Map<TARGET, Boolean> setRemoved) {
ToOneGetter<TARGET> backlinkToOneGetter = relationInfo.backlinkToOneGetter;
ToOneGetter<TARGET, Object> backlinkToOneGetter = relationInfo.backlinkToOneGetter;

synchronized (this) {
if (setAdded != null && !setAdded.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,20 @@ public long getId(Customer object) {
}

public static final RelationInfo<Customer, Order> orders =
new RelationInfo<>(Customer_.__INSTANCE, Order_.__INSTANCE, new ToManyGetter<Customer>() {
new RelationInfo<>(Customer_.__INSTANCE, Order_.__INSTANCE, new ToManyGetter<Customer, Order>() {
@Override
public List<Order> getToMany(Customer customer) {
return customer.getOrders();
}
}, Order_.customerId, new ToOneGetter<Order>() {
}, Order_.customerId, new ToOneGetter<Order, Customer>() {
@Override
public ToOne<Customer> getToOne(Order order) {
return order.getCustomer();
}
});

public static final RelationInfo<Customer, Order> ordersStandalone =
new RelationInfo<>(Customer_.__INSTANCE, Order_.__INSTANCE, new ToManyGetter<Customer>() {
new RelationInfo<>(Customer_.__INSTANCE, Order_.__INSTANCE, new ToManyGetter<Customer, Order>() {
@Override
public List<Order> getToMany(Customer customer) {
return customer.getOrders();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public long getId(Order object) {
}
}

public static final RelationInfo<Order, Customer> customer = new RelationInfo<>(Order_.__INSTANCE, Customer_.__INSTANCE, customerId, new ToOneGetter<Order>() {
public static final RelationInfo<Order, Customer> customer = new RelationInfo<>(Order_.__INSTANCE, Customer_.__INSTANCE, customerId, new ToOneGetter<Order, Customer>() {
@Override
public ToOne<Customer> getToOne(Order object) {
return object.getCustomer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public long getId(DataBranch object) {

/** To-one relation "parent" to target entity "DataBranch". */
public static final RelationInfo<DataBranch, DataBranch> parent =
new RelationInfo<>(DataBranch_.__INSTANCE, DataBranch_.__INSTANCE, parentId, new ToOneGetter<DataBranch>() {
new RelationInfo<>(DataBranch_.__INSTANCE, DataBranch_.__INSTANCE, parentId, new ToOneGetter<DataBranch, DataBranch>() {
@Override
public ToOne<DataBranch> getToOne(DataBranch entity) {
return entity.parent;
Expand All @@ -115,7 +115,7 @@ public ToOne<DataBranch> getToOne(DataBranch entity) {

/** To-one relation "metaBranch" to target entity "MetaBranch". */
public static final RelationInfo<DataBranch, MetaBranch> metaBranch =
new RelationInfo<>(DataBranch_.__INSTANCE, MetaBranch_.__INSTANCE, metaBranchId, new ToOneGetter<DataBranch>() {
new RelationInfo<>(DataBranch_.__INSTANCE, MetaBranch_.__INSTANCE, metaBranchId, new ToOneGetter<DataBranch, MetaBranch>() {
@Override
public ToOne<MetaBranch> getToOne(DataBranch entity) {
return entity.metaBranch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public long getId(DataLeaf object) {

/** To-one relation "dataBranch" to target entity "DataBranch". */
public static final RelationInfo<DataLeaf, DataBranch> dataBranch =
new RelationInfo<>(DataLeaf_.__INSTANCE, io.objectbox.tree.DataBranch_.__INSTANCE, dataBranchId, new ToOneGetter<DataLeaf>() {
new RelationInfo<>(DataLeaf_.__INSTANCE, io.objectbox.tree.DataBranch_.__INSTANCE, dataBranchId, new ToOneGetter<DataLeaf, DataBranch>() {
@Override
public ToOne<DataBranch> getToOne(DataLeaf entity) {
return entity.dataBranch;
Expand All @@ -127,7 +127,7 @@ public ToOne<DataBranch> getToOne(DataLeaf entity) {

/** To-one relation "metaLeaf" to target entity "MetaLeaf". */
public static final RelationInfo<DataLeaf, MetaLeaf> metaLeaf =
new RelationInfo<>(DataLeaf_.__INSTANCE, io.objectbox.tree.MetaLeaf_.__INSTANCE, metaLeafId, new ToOneGetter<DataLeaf>() {
new RelationInfo<>(DataLeaf_.__INSTANCE, io.objectbox.tree.MetaLeaf_.__INSTANCE, metaLeafId, new ToOneGetter<DataLeaf, MetaLeaf>() {
@Override
public ToOne<MetaLeaf> getToOne(DataLeaf entity) {
return entity.metaLeaf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public long getId(MetaBranch object) {

/** To-one relation "parent" to target entity "MetaBranch". */
public static final RelationInfo<MetaBranch, MetaBranch> parent =
new RelationInfo<>(MetaBranch_.__INSTANCE, MetaBranch_.__INSTANCE, parentId, new ToOneGetter<MetaBranch>() {
new RelationInfo<>(MetaBranch_.__INSTANCE, MetaBranch_.__INSTANCE, parentId, new ToOneGetter<MetaBranch, MetaBranch>() {
@Override
public ToOne<MetaBranch> getToOne(MetaBranch entity) {
return entity.parent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public long getId(MetaLeaf object) {

/** To-one relation "branch" to target entity "MetaBranch". */
public static final RelationInfo<MetaLeaf, MetaBranch> branch =
new RelationInfo<>(MetaLeaf_.__INSTANCE, MetaBranch_.__INSTANCE, branchId, new ToOneGetter<MetaLeaf>() {
new RelationInfo<>(MetaLeaf_.__INSTANCE, MetaBranch_.__INSTANCE, branchId, new ToOneGetter<MetaLeaf, MetaBranch>() {
@Override
public ToOne<MetaBranch> getToOne(MetaLeaf entity) {
return entity.branch;
Expand Down

0 comments on commit e5f579d

Please sign in to comment.