File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
objectbox-java/src/main/java/io/objectbox/relation Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -55,10 +55,10 @@ public class ToOne<TARGET> implements Serializable {
55
55
* @param relationInfo Meta info as generated in the Entity_ (entity name plus underscore) classes.
56
56
*/
57
57
public ToOne (Object sourceEntity , RelationInfo relationInfo ) {
58
- if (sourceEntity == null ) {
58
+ if (sourceEntity == null ) {
59
59
throw new IllegalArgumentException ("No source entity given (null)" );
60
60
}
61
- if (relationInfo == null ) {
61
+ if (relationInfo == null ) {
62
62
throw new IllegalArgumentException ("No relation info given (null)" );
63
63
}
64
64
this .entity = sourceEntity ;
@@ -274,4 +274,17 @@ public void internalPutTarget(Cursor<TARGET> targetCursor) {
274
274
Object getEntity () {
275
275
return entity ;
276
276
}
277
+
278
+ @ Override
279
+ public boolean equals (Object obj ) {
280
+ if (!(obj instanceof ToOne )) return false ;
281
+ ToOne other = (ToOne ) obj ;
282
+ return relationInfo == other .relationInfo && getTargetId () == other .getTargetId ();
283
+ }
284
+
285
+ @ Override
286
+ public int hashCode () {
287
+ long targetId = getTargetId ();
288
+ return (int ) (targetId ^ targetId >>> 32 );
289
+ }
277
290
}
You can’t perform that action at this time.
0 commit comments