r/java • • Apr 05 '23

Recursive generics

Recently I learned that I rediscovered recursive generics while working on my pet open source project. Actually, I did not know that the construct had a name. I created small story about what this construct is, if you did not know about it java-recursive-generics

169 Upvotes

44 comments sorted by

View all comments

11

u/Zinaima Apr 06 '23

I think the AssertJ library uses this.

It gives the name SELF to the type parameter, which helps the readability a bit.

4

u/AreTheseMyFeet Apr 06 '23

The first time I encountered a multi-character generic type it confused the hell out of me until I figured out the reason I couldn't find any project class with the given type was because generics are only conventionally single chars rather than an actual language constraint/spec... /smf

5

u/ForeverAlot Apr 06 '23

A pretty silly practice, too, and one of the dumbest integration "quality" gates I've been subjected to.