[JAVA-1425] Make IDGenerator generic Created: 04/Sep/14  Updated: 08/Oct/15  Resolved: 14/Oct/14

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 3.0.0

Type: Improvement Priority: Major - P3
Reporter: Trisha Gee Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The IDGenerator currently returns an Object, when it would be better practice to make this generic:

public interface IdGenerator<T> {
T generate();
}

There are places where we need to resort to using Objects, but this is not one of them.



 Comments   
Comment by Jeffrey Yemin [ 07/Oct/14 ]

I think Object is actually correct in this case. IdGenerator will generally be passed as a parameter to a CollectibleCodec implementation and used to implement com.mongodb.codecs.CollectibleCodec#generateIdIfAbsentFromDocument. If IdGenerator was generic on the type of the id it generated, then the Codec itself would also have to be generic based on that type. But making a CollectibleCodec generic on anything besides the type that it decodes/encodes, because that type would be lost anyway once it's added to a CodecRegistry.

Let me know if you still disagree. Otherwise, let's close as won't fix.

Generated at Thu Feb 08 08:54:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.