From 12cd06559ab0eb7e2ae0f8713c077710e8d2ae41 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 12 Jul 2024 17:45:42 +0000 Subject: [PATCH] feat : reduce access modifier where possible --- .../InventoryServiceApplication.java | 2 +- .../inventoryservice/config/Initializer.java | 4 ++-- .../config/KafkaListenerConfig.java | 4 ++-- .../config/RestTemplateConfig.java | 2 +- .../config/SwaggerConfig.java | 2 +- .../inventoryservice/config/WebMvcConfig.java | 7 ++++--- .../config/logging/LoggingAspect.java | 4 ++-- .../web/controllers/InventoryController.java | 19 +++++++++---------- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/inventory-service/src/main/java/com/example/inventoryservice/InventoryServiceApplication.java b/inventory-service/src/main/java/com/example/inventoryservice/InventoryServiceApplication.java index 44f9feaf..90d75afb 100644 --- a/inventory-service/src/main/java/com/example/inventoryservice/InventoryServiceApplication.java +++ b/inventory-service/src/main/java/com/example/inventoryservice/InventoryServiceApplication.java @@ -13,7 +13,7 @@ Licensed under MIT License Copyright (c) 2021-2022 Raja Kolli. @SpringBootApplication @EnableConfigurationProperties({ApplicationProperties.class}) -public class InventoryServiceApplication { +class InventoryServiceApplication { public static void main(String[] args) { SpringApplication.run(InventoryServiceApplication.class, args); diff --git a/inventory-service/src/main/java/com/example/inventoryservice/config/Initializer.java b/inventory-service/src/main/java/com/example/inventoryservice/config/Initializer.java index d984e27e..6e8d98db 100644 --- a/inventory-service/src/main/java/com/example/inventoryservice/config/Initializer.java +++ b/inventory-service/src/main/java/com/example/inventoryservice/config/Initializer.java @@ -19,13 +19,13 @@ Licensed under MIT License Copyright (c) 2021-2022 Raja Kolli. @Component @Profile("local") -public class Initializer implements CommandLineRunner { +class Initializer implements CommandLineRunner { private final Logger log = LoggerFactory.getLogger(this.getClass()); private final InventoryRepository inventoryRepository; - public Initializer(InventoryRepository inventoryRepository) { + Initializer(InventoryRepository inventoryRepository) { this.inventoryRepository = inventoryRepository; } diff --git a/inventory-service/src/main/java/com/example/inventoryservice/config/KafkaListenerConfig.java b/inventory-service/src/main/java/com/example/inventoryservice/config/KafkaListenerConfig.java index 90626de9..4b010d20 100644 --- a/inventory-service/src/main/java/com/example/inventoryservice/config/KafkaListenerConfig.java +++ b/inventory-service/src/main/java/com/example/inventoryservice/config/KafkaListenerConfig.java @@ -27,14 +27,14 @@ Licensed under MIT License Copyright (c) 2022 Raja Kolli. @EnableKafka @Configuration(proxyBeanMethods = false) -public class KafkaListenerConfig { +class KafkaListenerConfig { private final Logger log = LoggerFactory.getLogger(this.getClass()); private final InventoryOrderManageService orderManageService; private final ProductManageService productManageService; - public KafkaListenerConfig( + KafkaListenerConfig( InventoryOrderManageService orderManageService, ProductManageService productManageService) { this.orderManageService = orderManageService; diff --git a/inventory-service/src/main/java/com/example/inventoryservice/config/RestTemplateConfig.java b/inventory-service/src/main/java/com/example/inventoryservice/config/RestTemplateConfig.java index 4556dce6..9ad86b92 100644 --- a/inventory-service/src/main/java/com/example/inventoryservice/config/RestTemplateConfig.java +++ b/inventory-service/src/main/java/com/example/inventoryservice/config/RestTemplateConfig.java @@ -12,7 +12,7 @@ Licensed under MIT License Copyright (c) 2022 Raja Kolli. import org.springframework.web.client.RestTemplate; @Configuration(proxyBeanMethods = false) -public class RestTemplateConfig { +class RestTemplateConfig { // IMPORTANT! To instrument RestTemplate you must inject the RestTemplateBuilder @Bean diff --git a/inventory-service/src/main/java/com/example/inventoryservice/config/SwaggerConfig.java b/inventory-service/src/main/java/com/example/inventoryservice/config/SwaggerConfig.java index 0dc522b0..0552f972 100644 --- a/inventory-service/src/main/java/com/example/inventoryservice/config/SwaggerConfig.java +++ b/inventory-service/src/main/java/com/example/inventoryservice/config/SwaggerConfig.java @@ -15,4 +15,4 @@ Licensed under MIT License Copyright (c) 2022-2023 Raja Kolli. @OpenAPIDefinition( info = @Info(title = "inventory-service", version = "v1"), servers = @Server(url = "${server.servlet.contextPath}")) -public class SwaggerConfig {} +class SwaggerConfig {} diff --git a/inventory-service/src/main/java/com/example/inventoryservice/config/WebMvcConfig.java b/inventory-service/src/main/java/com/example/inventoryservice/config/WebMvcConfig.java index 6cca96e2..56961e36 100644 --- a/inventory-service/src/main/java/com/example/inventoryservice/config/WebMvcConfig.java +++ b/inventory-service/src/main/java/com/example/inventoryservice/config/WebMvcConfig.java @@ -8,20 +8,21 @@ Licensed under MIT License Copyright (c) 2021-2023 Raja Kolli. import com.example.inventoryservice.config.ApplicationProperties.Cors; import org.springframework.context.annotation.Configuration; +import org.springframework.lang.NonNull; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration(proxyBeanMethods = false) -public class WebMvcConfig implements WebMvcConfigurer { +class WebMvcConfig implements WebMvcConfigurer { private final ApplicationProperties properties; - public WebMvcConfig(ApplicationProperties properties) { + WebMvcConfig(ApplicationProperties properties) { this.properties = properties; } @Override - public void addCorsMappings(CorsRegistry registry) { + public void addCorsMappings(@NonNull CorsRegistry registry) { Cors cors = properties.getCors(); registry.addMapping(cors.getPathPattern()) .allowedMethods(cors.getAllowedHeaders()) diff --git a/inventory-service/src/main/java/com/example/inventoryservice/config/logging/LoggingAspect.java b/inventory-service/src/main/java/com/example/inventoryservice/config/logging/LoggingAspect.java index 3d9b3d46..72f3e1b5 100644 --- a/inventory-service/src/main/java/com/example/inventoryservice/config/logging/LoggingAspect.java +++ b/inventory-service/src/main/java/com/example/inventoryservice/config/logging/LoggingAspect.java @@ -29,13 +29,13 @@ Licensed under MIT License Copyright (c) 2021-2024 Raja Kolli. @Aspect @Component -public class LoggingAspect { +class LoggingAspect { private static final Logger log = LoggerFactory.getLogger(LoggingAspect.class); private final Environment env; - public LoggingAspect(Environment env) { + LoggingAspect(Environment env) { this.env = env; } diff --git a/inventory-service/src/main/java/com/example/inventoryservice/web/controllers/InventoryController.java b/inventory-service/src/main/java/com/example/inventoryservice/web/controllers/InventoryController.java index 00968e1d..a43a987c 100644 --- a/inventory-service/src/main/java/com/example/inventoryservice/web/controllers/InventoryController.java +++ b/inventory-service/src/main/java/com/example/inventoryservice/web/controllers/InventoryController.java @@ -30,16 +30,16 @@ Licensed under MIT License Copyright (c) 2021-2024 Raja Kolli. @RestController @RequestMapping("/api/inventory") @Loggable -public class InventoryController { +class InventoryController { private final InventoryService inventoryService; - public InventoryController(InventoryService inventoryService) { + InventoryController(InventoryService inventoryService) { this.inventoryService = inventoryService; } @GetMapping - public PagedResult getAllInventories( + PagedResult getAllInventories( @RequestParam(defaultValue = AppConstants.DEFAULT_PAGE_NUMBER, required = false) int pageNo, @RequestParam(defaultValue = AppConstants.DEFAULT_PAGE_SIZE, required = false) @@ -56,7 +56,7 @@ public PagedResult getAllInventories( // @CircuitBreaker(name = "default", fallbackMethod = "hardcodedResponse") // @RateLimiter(name = "default") // @Bulkhead(name = "inventory-api") - public ResponseEntity getInventoryByProductCode(@PathVariable String productCode) { + ResponseEntity getInventoryByProductCode(@PathVariable String productCode) { return inventoryService .findInventoryByProductCode(productCode) .map(ResponseEntity::ok) @@ -64,25 +64,24 @@ public ResponseEntity getInventoryByProductCode(@PathVariable String } @GetMapping("/product") - public ResponseEntity> getInventoryByProductCodes( - @RequestParam List codes) { + ResponseEntity> getInventoryByProductCodes(@RequestParam List codes) { return ResponseEntity.ok(inventoryService.getInventoryByProductCodes(codes)); } @GetMapping("/generate") - public boolean updateInventoryWithRandomValue() { + boolean updateInventoryWithRandomValue() { inventoryService.updateGeneratedInventory(); return true; } @PostMapping @ResponseStatus(HttpStatus.CREATED) - public Inventory createInventory(@RequestBody @Validated InventoryRequest inventoryRequest) { + Inventory createInventory(@RequestBody @Validated InventoryRequest inventoryRequest) { return inventoryService.saveInventory(inventoryRequest); } @PutMapping("/{id}") - public ResponseEntity updateInventory( + ResponseEntity updateInventory( @PathVariable Long id, @RequestBody @Validated InventoryRequest inventoryRequest) { return inventoryService .updateInventoryById(id, inventoryRequest) @@ -91,7 +90,7 @@ public ResponseEntity updateInventory( } @DeleteMapping("/{id}") - public ResponseEntity deleteInventory(@PathVariable Long id) { + ResponseEntity deleteInventory(@PathVariable Long id) { return inventoryService .findInventoryById(id) .map(