Java Generic Class Exclude Collections from Type Parameter -


i've found proper way implement logic looking for, i'm curious why following doesn't work. half hour searching yielded no answers possible i'm not wording question properly.

what wanted limit type parameter such collections not accepted. while can test parameter type, i'd rather have ide indicate class doesn't accept collection type parameter. i'm aware keyword excludes doesn't exist hope helps illustrate question @ hand.

public class foo<k excludes collection, v> {   //todo: carry out collectionist operations }  

is there way in java? presume isn't best practice, if possible, i'd satiate curiosity in effort expand understanding of generics.

thank time , consideration!

excluding types not possible. due way how java types interfaces, roll own collection has exact same operations, , not excluded.

just sake of curiosity fair question, not aware of way of achieving @ compile time though. can place runtime check in foo's constructor.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -