Skip to content

Commit 2926e8e

Browse files
committed
Removed lombok
1 parent 36e15fa commit 2926e8e

15 files changed

Lines changed: 168 additions & 63 deletions

File tree

pom.xml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -390,15 +390,6 @@
390390
</exclusions>
391391
</dependency>
392392
<!-- ============================================== -->
393-
<!-- ================== LOMBOK ==================== -->
394-
<!-- ============================================== -->
395-
<dependency>
396-
<!-- Lombok -->
397-
<groupId>org.projectlombok</groupId>
398-
<artifactId>lombok</artifactId>
399-
<scope>provided</scope>
400-
</dependency>
401-
<!-- ============================================== -->
402393
<!-- ================== LOGGING =================== -->
403394
<!-- ============================================== -->
404395
<dependency>

src/main/java/com/bernardomg/example/spring/security/ws/oauth/resource/config/WebSecurityConfig.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import org.springframework.context.annotation.Configuration;
2929
import org.springframework.http.HttpMethod;
3030
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
31+
import org.springframework.security.config.annotation.web.configurers.FormLoginConfigurer;
32+
import org.springframework.security.config.annotation.web.configurers.LogoutConfigurer;
3133
import org.springframework.security.config.http.SessionCreationPolicy;
3234
import org.springframework.security.web.SecurityFilterChain;
3335
import org.springframework.security.web.servlet.util.matcher.MvcRequestMatcher;
@@ -94,8 +96,8 @@ public SecurityFilterChain getWebSecurityFilterChain(final HttpSecurity http,
9496
// Stateless
9597
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
9698
// Disable login and logout forms
97-
.formLogin(c -> c.disable())
98-
.logout(c -> c.disable());
99+
.formLogin(FormLoginConfigurer::disable)
100+
.logout(LogoutConfigurer::disable);
99101

100102
return http.build();
101103
}

src/main/java/com/bernardomg/example/spring/security/ws/oauth/resource/domain/entity/controller/ExampleEntityController.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,26 @@
3131
import com.bernardomg.example.spring.security.ws.oauth.resource.domain.entity.model.ExampleEntity;
3232
import com.bernardomg.example.spring.security.ws.oauth.resource.domain.entity.service.ExampleEntityService;
3333

34-
import lombok.AllArgsConstructor;
35-
3634
/**
3735
* Rest controller for the example entities.
3836
*
3937
* @author Bernardo Mart&iacute;nez Garrido
4038
*/
4139
@RestController
4240
@RequestMapping("/entity")
43-
@AllArgsConstructor
4441
public class ExampleEntityController {
4542

4643
/**
4744
* Example entity service.
4845
*/
4946
private final ExampleEntityService exampleEntityService;
5047

48+
public ExampleEntityController(final ExampleEntityService service) {
49+
super();
50+
51+
exampleEntityService = service;
52+
}
53+
5154
/**
5255
* Returns a collection of entities.
5356
*

src/main/java/com/bernardomg/example/spring/security/ws/oauth/resource/domain/entity/model/PersistentExampleEntity.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import jakarta.persistence.Id;
3232
import jakarta.persistence.Table;
3333
import jakarta.persistence.Transient;
34-
import lombok.Data;
3534

3635
/**
3736
* Persistent entity for the example application.
@@ -42,7 +41,6 @@
4241
*/
4342
@Entity(name = "ExampleEntity")
4443
@Table(name = "example_entities")
45-
@Data
4644
public class PersistentExampleEntity implements ExampleEntity {
4745

4846
/**
@@ -67,4 +65,24 @@ public class PersistentExampleEntity implements ExampleEntity {
6765
@Column(name = "name", nullable = false, unique = true)
6866
private String name = "";
6967

68+
@Override
69+
public Integer getId() {
70+
return id;
71+
}
72+
73+
@Override
74+
public String getName() {
75+
return name;
76+
}
77+
78+
@Override
79+
public void setId(final Integer id) {
80+
this.id = id;
81+
}
82+
83+
@Override
84+
public void setName(final String name) {
85+
this.name = name;
86+
}
87+
7088
}

src/main/java/com/bernardomg/example/spring/security/ws/oauth/resource/domain/entity/service/DefaultExampleEntityService.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,26 @@
2929
import com.bernardomg.example.spring.security.ws.oauth.resource.domain.entity.model.PersistentExampleEntity;
3030
import com.bernardomg.example.spring.security.ws.oauth.resource.domain.entity.persistence.repository.ExampleEntityRepository;
3131

32-
import lombok.AllArgsConstructor;
33-
3432
/**
3533
* Default implementation of the example entity service.
3634
*
3735
* @author Bernardo Mart&iacute;nez Garrido
3836
*
3937
*/
4038
@Service
41-
@AllArgsConstructor
4239
public class DefaultExampleEntityService implements ExampleEntityService {
4340

4441
/**
4542
* Repository for the domain entities handled by the service.
4643
*/
4744
private final ExampleEntityRepository entityRepository;
4845

46+
public DefaultExampleEntityService(final ExampleEntityRepository repository) {
47+
super();
48+
49+
entityRepository = repository;
50+
}
51+
4952
@Override
5053
public final Iterable<PersistentExampleEntity> getAllEntities() {
5154
return entityRepository.findAll();

src/main/java/com/bernardomg/example/spring/security/ws/oauth/resource/mvc/error/handler/GlobalExceptionHandler.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
package com.bernardomg.example.spring.security.ws.oauth.resource.mvc.error.handler;
2626

27+
import org.slf4j.Logger;
28+
import org.slf4j.LoggerFactory;
2729
import org.springframework.http.HttpHeaders;
2830
import org.springframework.http.HttpStatus;
2931
import org.springframework.http.HttpStatusCode;
@@ -40,17 +42,19 @@
4042
import com.bernardomg.example.spring.security.ws.oauth.resource.mvc.response.model.ErrorResponse;
4143
import com.bernardomg.example.spring.security.ws.oauth.resource.mvc.response.model.Response;
4244

43-
import lombok.extern.slf4j.Slf4j;
44-
4545
/**
4646
* Captures and handles exceptions for all the controllers.
4747
*
4848
* @author Bernardo Mart&iacute;nez Garrido
4949
*/
5050
@ControllerAdvice
51-
@Slf4j
5251
public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
5352

53+
/**
54+
* Class logger.
55+
*/
56+
private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
57+
5458
/**
5559
* Default constructor.
5660
*/

src/main/java/com/bernardomg/example/spring/security/ws/oauth/resource/mvc/error/model/ImmutableError.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,28 @@
2424

2525
package com.bernardomg.example.spring.security.ws.oauth.resource.mvc.error.model;
2626

27-
import lombok.Data;
28-
import lombok.NonNull;
29-
3027
/**
3128
* Immutable error.
3229
*
3330
* @author Bernardo Mart&iacute;nez Garrido
3431
*
3532
*/
36-
@Data
3733
public class ImmutableError implements Error {
3834

3935
/**
4036
* Failure message.
4137
*/
42-
@NonNull
4338
private final String message;
4439

40+
public ImmutableError(final String message) {
41+
super();
42+
43+
this.message = message;
44+
}
45+
46+
@Override
47+
public String getMessage() {
48+
return message;
49+
}
50+
4551
}

src/main/java/com/bernardomg/example/spring/security/ws/oauth/resource/mvc/response/controller/ResponseAdvice.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
package com.bernardomg.example.spring.security.ws.oauth.resource.mvc.response.controller;
2626

27+
import org.slf4j.Logger;
28+
import org.slf4j.LoggerFactory;
2729
import org.springframework.core.MethodParameter;
2830
import org.springframework.http.MediaType;
2931
import org.springframework.http.ResponseEntity;
@@ -36,8 +38,6 @@
3638
import com.bernardomg.example.spring.security.ws.oauth.resource.mvc.response.model.ErrorResponse;
3739
import com.bernardomg.example.spring.security.ws.oauth.resource.mvc.response.model.Response;
3840

39-
import lombok.extern.slf4j.Slf4j;
40-
4141
/**
4242
* Advice to wrap all the responses into the response object.
4343
* <p>
@@ -48,9 +48,13 @@
4848
*
4949
*/
5050
@ControllerAdvice("com.bernardomg.example.spring.security.ws")
51-
@Slf4j
5251
public class ResponseAdvice implements ResponseBodyAdvice<Object> {
5352

53+
/**
54+
* Class logger.
55+
*/
56+
private static final Logger log = LoggerFactory.getLogger(ResponseAdvice.class);
57+
5458
/**
5559
* Default constructor.
5660
*/
@@ -65,15 +69,9 @@ public Object beforeBodyWrite(final Object body, final MethodParameter returnTyp
6569
final Object result;
6670

6771
log.trace("Received {} as response body", body);
68-
if (body instanceof ResponseEntity<?>) {
72+
if ((body instanceof ResponseEntity<?>) || (body instanceof Response) || (body instanceof ErrorResponse)) {
6973
// Avoid wrapping Spring responses
7074
result = body;
71-
} else if (body instanceof Response) {
72-
// Avoid wrapping responses
73-
result = body;
74-
} else if (body instanceof ErrorResponse) {
75-
// Avoid wrapping error responses
76-
result = body;
7775
} else if (body == null) {
7876
log.debug("Received null as response body");
7977
result = Response.empty();

src/main/java/com/bernardomg/example/spring/security/ws/oauth/resource/mvc/response/model/ImmutableErrorResponse.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,11 @@
2929

3030
import com.bernardomg.example.spring.security.ws.oauth.resource.mvc.error.model.Error;
3131

32-
import lombok.Data;
33-
import lombok.NonNull;
34-
3532
/**
3633
* Immutable implementation of the error response.
3734
*
3835
* @author Bernardo Mart&iacute;nez Garrido
3936
*/
40-
@Data
4137
public class ImmutableErrorResponse implements ErrorResponse {
4238

4339
/**
@@ -51,10 +47,15 @@ public class ImmutableErrorResponse implements ErrorResponse {
5147
* @param errs
5248
* errors
5349
*/
54-
public ImmutableErrorResponse(@NonNull final Collection<Error> errs) {
50+
public ImmutableErrorResponse(final Collection<Error> errs) {
5551
super();
5652

5753
errors = Collections.unmodifiableCollection(errs);
5854
}
5955

56+
@Override
57+
public Collection<Error> getErrors() {
58+
return errors;
59+
}
60+
6061
}

src/main/java/com/bernardomg/example/spring/security/ws/oauth/resource/mvc/response/model/ImmutableResponse.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424

2525
package com.bernardomg.example.spring.security.ws.oauth.resource.mvc.response.model;
2626

27-
import lombok.Data;
28-
import lombok.NonNull;
29-
3027
/**
3128
* Immutable implementation of the response.
3229
*
@@ -35,7 +32,6 @@
3532
* @param <T>
3633
* response content type
3734
*/
38-
@Data
3935
public class ImmutableResponse<T> implements Response<T> {
4036

4137
/**
@@ -58,10 +54,15 @@ public ImmutableResponse() {
5854
* @param cont
5955
* content
6056
*/
61-
public ImmutableResponse(@NonNull final T cont) {
57+
public ImmutableResponse(final T cont) {
6258
super();
6359

6460
content = cont;
6561
}
6662

63+
@Override
64+
public T getContent() {
65+
return content;
66+
}
67+
6768
}

0 commit comments

Comments
 (0)