Existing tools aren't really good in the Java world. Eclipse's XML-based styling rely on ...
In the following, I present examples formatted using the XML-configured Eclipse formatter. https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml
For example:
userService.updateUser(userDTO.getFirstName(), userDTO.getLastName(), userDTO.getEmail(),
userDTO.getLangKey(), userDTO.getImageUrl());
userService.updateUser(
userDTO.getFirstName(),
userDTO.getLastName(),
userDTO.getEmail(),
userDTO.getLangKey(),
userDTO.getImageUrl());
web.ignoring().antMatchers(HttpMethod.OPTIONS, "/**").antMatchers("/app/**/*.{js,html}")
.antMatchers("/i18n/**").antMatchers("/content/**").antMatchers("/h2-console/**")
.antMatchers("/swagger-ui/index.html").antMatchers("/test/**");
web.ignoring()
.antMatchers(HttpMethod.OPTIONS, "/**")
.antMatchers("/app/**/*.{js,html}")
.antMatchers("/i18n/**")
.antMatchers("/content/**")
.antMatchers("/h2-console/**")
.antMatchers("/swagger-ui/index.html")
.antMatchers("/test/**");
One case I could argue that the formatting is weird on long strings with many concatenations. This would be fixed with a string interpolation, which is something Java lacks right now.
return "User{" + "login='" + login + '\'' + ", firstName='" + firstName + '\''
+ ", lastName='" + lastName + '\'' + ", email='" + email + '\'' + ", imageUrl='"
+ imageUrl + '\'' + ", activated='" + activated + '\'' + ", langKey='" + langKey
+ '\'' + ", activationKey='" + activationKey + '\'' + "}";
return "User{"
+ "login='"
+ login
+ '\''
+ ", firstName='"
+ firstName
+ '\''
+ ", lastName='"
+ lastName
+ '\''
+ ", email='"
+ email
+ '\''
+ ", imageUrl='"
+ imageUrl
+ '\''
+ ", activated='"
+ activated
+ '\''
+ ", langKey='"
+ langKey
+ '\''
+ ", activationKey='"
+ activationKey
+ '\''
+ "}";
return Optional.ofNullable(securityContext.getAuthentication())
.map(authentication -> authentication.getAuthorities().stream()
.noneMatch(grantedAuthority -> grantedAuthority.getAuthority()
.equals(AuthoritiesConstants.ANONYMOUS)))
.orElse(false);
return Optional.ofNullable(securityContext.getAuthentication())
.map(
authentication ->
authentication
.getAuthorities()
.stream()
.noneMatch(
grantedAuthority ->
grantedAuthority.getAuthority().equals(AuthoritiesConstants.ANONYMOUS)))
.orElse(false);
return Optional.ofNullable(securityContext.getAuthentication())
.map(
authentication ->
authentication.getAuthorities().stream()
.noneMatch(
grantedAuthority ->
grantedAuthority.getAuthority().equals(AuthoritiesConstants.ANONYMOUS)))
.orElse(false);
How to integrate google-java-format
with a hook?