tags:

views:

194

answers:

1

Disclaimer: I don't have a whole ton of experience with Java Generics, but my colleagues and I just spent a solid hour trying to decipher an interface that was structured like this:

Interface HasAttributes<a extends HasAttributes<a,b>, 
    b extends HasAttributesType<b>> extends Identification<a>

What exactly does it mean when an interface generic takes a type parameter that is itself? What does this do?

+3  A: 

There is meaning to this - Java's Enum class is a good example of a simliar situation:

public abstract class Enum<E extends Enum<E>>
    implements Comparable<E>, Serializable

There are some enlightening answers in this Stack Overflow question about Enum that should shed some light on this particular use of generics for you, as well as answer this more elegantly than I could.

Joshua McKinnon
Thank you, that helps immensely. We were very, very confused by this.
Daniel Bingham