If say I have some generic class, for example:
public class Attribute<T> {
}
Is it possible now to have specific methods for specific types? I.e. to extend the generic class for certain kinds of types?
For example:
I want to add extra methods to Attribute<String>, but not for say Attribute<Integer>.
There is no such direct possibility in Java.
But you can have
StringAttributethat extendsAttribute<String>and adds to it the methods you’d like to. You can make a kind of factory, in a dependency injection fashion, which will construct e.g.Attribute<Integer>forIntegerandStringAttributeforString.