rethinkdb / rethinkdb-java

Official RethinkDB Java client
https://rethinkdb.com/api/java/
Apache License 2.0
21 stars 10 forks source link

Types utility class #26

Closed NotJustAnna closed 4 years ago

NotJustAnna commented 4 years ago

Creates a utility class Types, which aims to replace some TypeReference generic classes across the driver main and test code, as well as expose it to the driver users.

Examples:

new TypeReference<Map<String, Object>>() {};
// turns into
Types.mapOf(String.class, Object.class);
new TypeReference<List<String>>() {};
// turns into
Types.listOf(String.class);

Building generics types are faster than loading them from type information because that amounts to one class load per type reference, versus a few invoke calls and load constants.

Yes, I reverse-engineered the type system and Jackson type system to make this.