apache / netbeans

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

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

Closed lkishalmi closed 1 month ago

lkishalmi commented 1 month ago

Some cheap new tricks for Java Wizards!

mbien commented 1 month ago

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

mbien commented 1 month ago

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

lkishalmi commented 1 month 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 1 month ago

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

Where i would stand for?

mbien commented 1 month 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 1 month 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...