[Geoserver-devel] Switching anonymous inner classes with lambdas

Hi all,
playing with IntelliJ I’ve found a migration grabbing anonymous inner classes and
migrating them to lambdas. The code gets more compact for sure, often more readable
too (less boilerplate around), other times maybe less so (as in, it might not be evident what
interface the lambda is implementing).

Anyhow, the result is here for you to explore, for all projects:
https://github.com/geotools/geotools/pull/3318

https://github.com/GeoWebCache/geowebcache/pull/914

https://github.com/geoserver/geoserver/pull/4656

I don’t plan to add a PMD rule to enforce this though.

Opinions?

Cheers
Andrea

···

== GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.

I think its worth doing when (and only when) it makes the code more compact and readable. In cases where the result becomes complicated, then we shouldn’t do it. I recognise that is subjective, but I think there are cases where the result is worse, and the geoserver (in particular) code base is complicated enough already.

My preference would be to do this on a case-by-case basis. It is not a firm position though.

Brad

From: Andrea Aime andrea.aime@anonymised.com
Sent: Saturday, 16 January 2021 5:58 AM
To: Geotools-Devel list geotools-devel@anonymised.comceforge.net; Geoserver-devel geoserver-devel@lists.sourceforge.net
Subject: [Geoserver-devel] Switching anonymous inner classes with lambdas

Hi all,

playing with IntelliJ I’ve found a migration grabbing anonymous inner classes and

migrating them to lambdas. The code gets more compact for sure, often more readable

too (less boilerplate around), other times maybe less so (as in, it might not be evident what

interface the lambda is implementing).

Anyhow, the result is here for you to explore, for all projects:

https://github.com/geotools/geotools/pull/3318

https://github.com/GeoWebCache/geowebcache/pull/914

https://github.com/geoserver/geoserver/pull/4656

I don’t plan to add a PMD rule to enforce this though.

Opinions?

Cheers

Andrea

== GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.