apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.61k stars 836 forks source link

Java Code Templates for List.of(), Map.of(), and Set.of() #7102

Closed lkishalmi closed 5 months ago

lkishalmi commented 5 months ago

Some cheap new tricks for Java Wizards!

mbien commented 5 months ago

(not sure about using var for collections by default, since types often matter but it is just a template)

mbien commented 5 months ago

@lkishalmi what would you think about also adding ilof imof and isof?

lkishalmi commented 5 months ago

(not sure about using var for collections by default, since types often matter but it is just a template)

Well, since the resulted collection is immutable, I do not think the type would really matter.

Personally I would mainly use them in education space, creating sort code for demonstration purposes, and yes they are just templates.

lkishalmi commented 5 months ago

@lkishalmi what would you think about also adding ilof imof and isof?

Where i would stand for?

mbien commented 5 months ago

i for the interface on the left hand side.

ilof would be List<|> list = List.of()

it might have to put the cursor between <> first, since I am not quite sure how to automatically set the generics once the type is modified on the right hand side.

lkishalmi commented 5 months ago

Could be done, I'd probably use llof, mmof, andssoffor abbrevs.isofis pretty close to the commonly usediof`.

Also popped in my mind, that the List.copyOf(), etc would be more common with records, and then records with compact constructor...