Skip to content

Commit

Permalink
feat : reduce access modifier where possible (#799)
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli authored Jul 12, 2024
1 parent c0e1fce commit b692e61
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Inventory> getAllInventories(
PagedResult<Inventory> getAllInventories(
@RequestParam(defaultValue = AppConstants.DEFAULT_PAGE_NUMBER, required = false)
int pageNo,
@RequestParam(defaultValue = AppConstants.DEFAULT_PAGE_SIZE, required = false)
Expand All @@ -56,33 +56,32 @@ public PagedResult<Inventory> getAllInventories(
// @CircuitBreaker(name = "default", fallbackMethod = "hardcodedResponse")
// @RateLimiter(name = "default")
// @Bulkhead(name = "inventory-api")
public ResponseEntity<Inventory> getInventoryByProductCode(@PathVariable String productCode) {
ResponseEntity<Inventory> getInventoryByProductCode(@PathVariable String productCode) {
return inventoryService
.findInventoryByProductCode(productCode)
.map(ResponseEntity::ok)
.orElseGet(() -> ResponseEntity.notFound().build());
}

@GetMapping("/product")
public ResponseEntity<List<Inventory>> getInventoryByProductCodes(
@RequestParam List<String> codes) {
ResponseEntity<List<Inventory>> getInventoryByProductCodes(@RequestParam List<String> 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<Inventory> updateInventory(
ResponseEntity<Inventory> updateInventory(
@PathVariable Long id, @RequestBody @Validated InventoryRequest inventoryRequest) {
return inventoryService
.updateInventoryById(id, inventoryRequest)
Expand All @@ -91,7 +90,7 @@ public ResponseEntity<Inventory> updateInventory(
}

@DeleteMapping("/{id}")
public ResponseEntity<Inventory> deleteInventory(@PathVariable Long id) {
ResponseEntity<Inventory> deleteInventory(@PathVariable Long id) {
return inventoryService
.findInventoryById(id)
.map(
Expand Down

0 comments on commit b692e61

Please sign in to comment.