mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-18 11:25:50 +00:00
deps: Refactor dependencies (#3224)
* remove spring dep move junit, logging, mockito under dep mgmt * upgrade anti-corruption-layer deps * async method invocation * balking, bloc * bridge to bytecode * caching * callback - cqrs * component - health check * hexagonal - metadata mapping * rest of the patterns * remove checkstyle, take spotless into use
This commit is contained in:
@@ -30,20 +30,18 @@ import java.util.Scanner;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* The Execute Around idiom specifies executable code before and after a method. Typically,
|
||||
* the idiom is used when the API has methods to be executed in pairs, such as resource
|
||||
* The Execute Around idiom specifies executable code before and after a method. Typically, the
|
||||
* idiom is used when the API has methods to be executed in pairs, such as resource
|
||||
* allocation/deallocation or lock acquisition/release.
|
||||
*
|
||||
* <p>In this example, we have {@link SimpleFileWriter} class that opens and closes the file for
|
||||
* the user. The user specifies only what to do with the file by providing the {@link
|
||||
* FileWriterAction} implementation.
|
||||
* <p>In this example, we have {@link SimpleFileWriter} class that opens and closes the file for the
|
||||
* user. The user specifies only what to do with the file by providing the {@link FileWriterAction}
|
||||
* implementation.
|
||||
*/
|
||||
@Slf4j
|
||||
public class App {
|
||||
|
||||
/**
|
||||
* Program entry point.
|
||||
*/
|
||||
/** Program entry point. */
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
// create the file writer and execute the custom action
|
||||
|
||||
@@ -27,12 +27,9 @@ package com.iluwatar.execute.around;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Interface for specifying what to do with the file resource.
|
||||
*/
|
||||
/** Interface for specifying what to do with the file resource. */
|
||||
@FunctionalInterface
|
||||
public interface FileWriterAction {
|
||||
|
||||
void writeFile(FileWriter writer) throws IOException;
|
||||
|
||||
}
|
||||
|
||||
@@ -35,9 +35,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Slf4j
|
||||
public class SimpleFileWriter {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
/** Constructor. */
|
||||
public SimpleFileWriter(String filename, FileWriterAction action) throws IOException {
|
||||
LOGGER.info("Opening the file");
|
||||
try (var writer = new FileWriter(filename)) {
|
||||
|
||||
Reference in New Issue
Block a user