I currently have
class A {...} interface B {...}
What I would like to have is some equivalent
HashMap<String, A implements B>
ie, that a String maps to any instance of A that implements B But this syntax does not compile. Is there a way to map a class that implements an interface? Also note that A not generic, so I cannot do something like
String
A
B
A<? implements B>
This can be done in a general context, for example, in a general method:
public <T extends A & B> void method() { Map<String, T> map = new HashMap<>(); }
Unfortunately, we cannot apply these multiple restrictions to wildcards.
Source: https://habr.com/ru/post/1260718/More articles:Schedule an anonymous function without explicit variable names - anonymous-functionFirebase is not used in iOS application extensions since version 3.8.0 due to GTMSessionFetcher sharedApplication #AskFirebase - iosWhy is this a syntax error for matches in the case of matching strings without additional indentation, and what recommended style is bypassed? - syntaxSynchronize a nested asynchronous task - asynchronousHow to make non-random splitting of Dataset on Apache Spark? - apache-sparkDocFX: creating API documentation for multiple projects - documentation-generationHow to distinguish component instances in Vue Devtools - vue.jsFile gtk / gtk.h not found. Even with pkg-config - cHow to hide property in pom.xml? - mavenShow massage after pjax success by clicking only on a specific input - javascriptAll Articles