GIScience / ohsome-api

API for analysing OpenStreetMap history data
https://api.ohsome.org
GNU Affero General Public License v3.0
47 stars 8 forks source link

Introducing Lombok to code to reduce verbosity #50

Closed FabiKo117 closed 4 years ago

FabiKo117 commented 4 years ago

See https://www.baeldung.com/intro-to-project-lombok

Could be used in response classes to reduce the code there.

bonaparten commented 4 years ago

I have implemented Lombok in our code. You can see the changes here #57. I used only annotations for getters, setters and constructors.

Complex Constructs cannot be handled, e.g.: public AggregateRequestExecutor(RequestResource requestResource, HttpServletRequest servletRequest, HttpServletResponse servletResponse, boolean isDensity) { super(servletRequest, servletResponse); this.requestResource = requestResource; inputProcessor = new InputProcessor(servletRequest, true, isDensity); processingData = inputProcessor.getProcessingData(); }

It could be possible to use the builder annotations in order to build objects instead of calling constructors but IMHO this way doesn't reduce verbosity and some changes has to be done in the code itself.
It also offers other functionalities like an annotation for close() methods in finally brackets, an annotation for toString methods, etc. But they would not be really useful for us, since the use of them is really seldom in the ohsome API.

IMHO Lombok is very useful for us for getters/setters and (not complex) constructors since it really reduces verbosity. If you like you can already merge the branch into master. I can open a confluence page about Lombok functionalities which should be used in the ohsome API.

Lombok features Good constructors guide

FabiKo117 commented 4 years ago

Nice 👍 I'll have a look at it this afternoon.