REST, Spring

Implementing inheritance for JSON objects

Our App developers wanted to send slightly different JSON elements in a single list, in order to make the App side implementation far less complicated. In order to make it possible to, I decided to implement inheritance hierarchy for the JSON input and the related java DTO classes. The other possibility would be to have… Continue reading Implementing inheritance for JSON objects

Advertisement
REST, Spring Boot

Custom validator for REST parameter in Spring Boot

Using Spring boot applications, it is very easy to let the Spring framework to do the validation of the REST input parameter. You only need to add the corresponding validation annotations to the properties of the parameter class, and mark the parameter with @Valid annotation in the method header. @RequestMapping(value = "/register", method = {… Continue reading Custom validator for REST parameter in Spring Boot

Java

Different ways to use assertions in Java code

In order to create a clean and save code, I prefer implement as many state checks in my code, as possible or necessary. If a state check fails, you usually want to throw an exception and stop processing the current business step. Failure in state check is always a sign of an implementation problem. As… Continue reading Different ways to use assertions in Java code