Currently I pass a Type Attribute to a class.
public class MyClass<Type> {...}
But now I want the condition to exist that the given Type implements an interface. This is my vain attempt to solve this problem:
public class MyClass<Type implements MyInterface> {...}
Maybe this helps to understand what I want to achieve.
Thank you in advance!
CodePudding user response:
In TypeScript these are called generic constraints.
This is how you would write it in your case:
public class MyClass<Type extends MyInterface> {...}