Resolves checkstyle errors for delegation dependency-injection dirty-flag double-buffer double-checked-locking double-dispatch (#1068)
* Reduces checkstyle errors in delegation * Reduces checkstyle errors in dependency-injection * Reduces checkstyle errors in dirty-flag * Reduces checkstyle errors in double-buffer * Reduces checkstyle errors in double-checked-locking * Reduces checkstyle errors in double-dispatch
This commit is contained in:
committed by
Ilkka Seppälä
parent
01e489c77b
commit
f2c91eb836
@ -28,23 +28,25 @@ import com.iluwatar.delegation.simple.printers.EpsonPrinter;
|
||||
import com.iluwatar.delegation.simple.printers.HpPrinter;
|
||||
|
||||
/**
|
||||
* The delegate pattern provides a mechanism to abstract away the implementation and control of the desired action.
|
||||
* The class being called in this case {@link PrinterController} is not responsible for the actual desired action,
|
||||
* but is actually delegated to a helper class either {@link CanonPrinter}, {@link EpsonPrinter} or {@link HpPrinter}.
|
||||
* The consumer does not have or require knowledge of the actual class carrying out the action, only the
|
||||
* container on which they are calling.
|
||||
* The delegate pattern provides a mechanism to abstract away the implementation and control of the
|
||||
* desired action. The class being called in this case {@link PrinterController} is not responsible
|
||||
* for the actual desired action, but is actually delegated to a helper class either {@link
|
||||
* CanonPrinter}, {@link EpsonPrinter} or {@link HpPrinter}. The consumer does not have or require
|
||||
* knowledge of the actual class carrying out the action, only the container on which they are
|
||||
* calling.
|
||||
*
|
||||
* In this example the delegates are {@link EpsonPrinter}, {@link HpPrinter} and {@link CanonPrinter} they all implement
|
||||
* {@link Printer}. The {@link PrinterController} class also implements {@link Printer}. However neither provide the
|
||||
* functionality of {@link Printer} by printing to the screen, they actually call upon the instance of {@link Printer}
|
||||
* that they were instantiated with. Therefore delegating the behaviour to another class.
|
||||
* <p>In this example the delegates are {@link EpsonPrinter}, {@link HpPrinter} and {@link
|
||||
* CanonPrinter} they all implement {@link Printer}. The {@link PrinterController} class also
|
||||
* implements {@link Printer}. However neither provide the functionality of {@link Printer} by
|
||||
* printing to the screen, they actually call upon the instance of {@link Printer} that they were
|
||||
* instantiated with. Therefore delegating the behaviour to another class.
|
||||
*/
|
||||
public class App {
|
||||
|
||||
private static final String MESSAGE_TO_PRINT = "hello world";
|
||||
|
||||
/**
|
||||
* Program entry point
|
||||
* Program entry point.
|
||||
*
|
||||
* @param args command line args
|
||||
*/
|
||||
|
@ -38,7 +38,8 @@ public interface Printer {
|
||||
|
||||
/**
|
||||
* Method that takes a String to print to the screen. This will be implemented on both the
|
||||
* controller and the delegate allowing the controller to call the same method on the delegate class.
|
||||
* controller and the delegate allowing the controller to call the same method on the delegate
|
||||
* class.
|
||||
*
|
||||
* @param message to be printed to the screen
|
||||
*/
|
||||
|
@ -24,10 +24,10 @@
|
||||
package com.iluwatar.delegation.simple;
|
||||
|
||||
/**
|
||||
* Delegator Class to delegate the implementation of the Printer.
|
||||
* This ensures two things:
|
||||
* - when the actual implementation of the Printer class changes the delegation will still be operational
|
||||
* - the actual benefit is observed when there are more than one implementors and they share a delegation control
|
||||
* Delegator Class to delegate the implementation of the Printer. This ensures two things: - when
|
||||
* the actual implementation of the Printer class changes the delegation will still be operational -
|
||||
* the actual benefit is observed when there are more than one implementors and they share a
|
||||
* delegation control
|
||||
*/
|
||||
public class PrinterController implements Printer {
|
||||
|
||||
@ -38,10 +38,10 @@ public class PrinterController implements Printer {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is implemented from {@link Printer} however instead on providing an
|
||||
* implementation, it instead calls upon the class passed through the constructor. This is the delegate,
|
||||
* hence the pattern. Therefore meaning that the caller does not care of the implementing class only the owning
|
||||
* controller.
|
||||
* This method is implemented from {@link Printer} however instead on providing an implementation,
|
||||
* it instead calls upon the class passed through the constructor. This is the delegate, hence the
|
||||
* pattern. Therefore meaning that the caller does not care of the implementing class only the
|
||||
* owning controller.
|
||||
*
|
||||
* @param message to be printed to the screen
|
||||
*/
|
||||
|
@ -28,8 +28,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Specialised Implementation of {@link Printer} for a Canon Printer, in
|
||||
* this case the message to be printed is appended to "Canon Printer : "
|
||||
* Specialised Implementation of {@link Printer} for a Canon Printer, in this case the message to be
|
||||
* printed is appended to "Canon Printer : ".
|
||||
*
|
||||
* @see Printer
|
||||
*/
|
||||
|
@ -28,8 +28,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Specialised Implementation of {@link Printer} for a Epson Printer, in
|
||||
* this case the message to be printed is appended to "Epson Printer : "
|
||||
* Specialised Implementation of {@link Printer} for a Epson Printer, in this case the message to be
|
||||
* printed is appended to "Epson Printer : ".
|
||||
*
|
||||
* @see Printer
|
||||
*/
|
||||
|
@ -28,8 +28,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Specialised Implementation of {@link Printer} for a HP Printer, in
|
||||
* this case the message to be printed is appended to "HP Printer : "
|
||||
* Specialised Implementation of {@link Printer} for a HP Printer, in this case the message to be
|
||||
* printed is appended to "HP Printer : ".
|
||||
*
|
||||
* @see Printer
|
||||
*/
|
||||
|
Reference in New Issue
Block a user