Skip to content

Commit f2c91eb

Browse files
altaiezioriluwatar
authored andcommitted
Resolves checkstyle errors for delegation dependency-injection dirty-flag double-buffer double-checked-locking double-dispatch (iluwatar#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
1 parent 01e489c commit f2c91eb

35 files changed

Lines changed: 154 additions & 215 deletions

File tree

delegation/src/main/java/com/iluwatar/delegation/simple/App.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,25 @@
2828
import com.iluwatar.delegation.simple.printers.HpPrinter;
2929

3030
/**
31-
* The delegate pattern provides a mechanism to abstract away the implementation and control of the desired action.
32-
* The class being called in this case {@link PrinterController} is not responsible for the actual desired action,
33-
* but is actually delegated to a helper class either {@link CanonPrinter}, {@link EpsonPrinter} or {@link HpPrinter}.
34-
* The consumer does not have or require knowledge of the actual class carrying out the action, only the
35-
* container on which they are calling.
31+
* The delegate pattern provides a mechanism to abstract away the implementation and control of the
32+
* desired action. The class being called in this case {@link PrinterController} is not responsible
33+
* for the actual desired action, but is actually delegated to a helper class either {@link
34+
* CanonPrinter}, {@link EpsonPrinter} or {@link HpPrinter}. The consumer does not have or require
35+
* knowledge of the actual class carrying out the action, only the container on which they are
36+
* calling.
3637
*
37-
* In this example the delegates are {@link EpsonPrinter}, {@link HpPrinter} and {@link CanonPrinter} they all implement
38-
* {@link Printer}. The {@link PrinterController} class also implements {@link Printer}. However neither provide the
39-
* functionality of {@link Printer} by printing to the screen, they actually call upon the instance of {@link Printer}
40-
* that they were instantiated with. Therefore delegating the behaviour to another class.
38+
* <p>In this example the delegates are {@link EpsonPrinter}, {@link HpPrinter} and {@link
39+
* CanonPrinter} they all implement {@link Printer}. The {@link PrinterController} class also
40+
* implements {@link Printer}. However neither provide the functionality of {@link Printer} by
41+
* printing to the screen, they actually call upon the instance of {@link Printer} that they were
42+
* instantiated with. Therefore delegating the behaviour to another class.
4143
*/
4244
public class App {
4345

4446
private static final String MESSAGE_TO_PRINT = "hello world";
4547

4648
/**
47-
* Program entry point
49+
* Program entry point.
4850
*
4951
* @param args command line args
5052
*/

delegation/src/main/java/com/iluwatar/delegation/simple/Printer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public interface Printer {
3838

3939
/**
4040
* Method that takes a String to print to the screen. This will be implemented on both the
41-
* controller and the delegate allowing the controller to call the same method on the delegate class.
41+
* controller and the delegate allowing the controller to call the same method on the delegate
42+
* class.
4243
*
4344
* @param message to be printed to the screen
4445
*/

delegation/src/main/java/com/iluwatar/delegation/simple/PrinterController.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
package com.iluwatar.delegation.simple;
2525

2626
/**
27-
* Delegator Class to delegate the implementation of the Printer.
28-
* This ensures two things:
29-
* - when the actual implementation of the Printer class changes the delegation will still be operational
30-
* - the actual benefit is observed when there are more than one implementors and they share a delegation control
27+
* Delegator Class to delegate the implementation of the Printer. This ensures two things: - when
28+
* the actual implementation of the Printer class changes the delegation will still be operational -
29+
* the actual benefit is observed when there are more than one implementors and they share a
30+
* delegation control
3131
*/
3232
public class PrinterController implements Printer {
3333

@@ -38,10 +38,10 @@ public PrinterController(Printer printer) {
3838
}
3939

4040
/**
41-
* This method is implemented from {@link Printer} however instead on providing an
42-
* implementation, it instead calls upon the class passed through the constructor. This is the delegate,
43-
* hence the pattern. Therefore meaning that the caller does not care of the implementing class only the owning
44-
* controller.
41+
* This method is implemented from {@link Printer} however instead on providing an implementation,
42+
* it instead calls upon the class passed through the constructor. This is the delegate, hence the
43+
* pattern. Therefore meaning that the caller does not care of the implementing class only the
44+
* owning controller.
4545
*
4646
* @param message to be printed to the screen
4747
*/

delegation/src/main/java/com/iluwatar/delegation/simple/printers/CanonPrinter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
import org.slf4j.LoggerFactory;
2929

3030
/**
31-
* Specialised Implementation of {@link Printer} for a Canon Printer, in
32-
* this case the message to be printed is appended to "Canon Printer : "
31+
* Specialised Implementation of {@link Printer} for a Canon Printer, in this case the message to be
32+
* printed is appended to "Canon Printer : ".
3333
*
3434
* @see Printer
3535
*/

delegation/src/main/java/com/iluwatar/delegation/simple/printers/EpsonPrinter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
import org.slf4j.LoggerFactory;
2929

3030
/**
31-
* Specialised Implementation of {@link Printer} for a Epson Printer, in
32-
* this case the message to be printed is appended to "Epson Printer : "
31+
* Specialised Implementation of {@link Printer} for a Epson Printer, in this case the message to be
32+
* printed is appended to "Epson Printer : ".
3333
*
3434
* @see Printer
3535
*/

delegation/src/main/java/com/iluwatar/delegation/simple/printers/HpPrinter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
import org.slf4j.LoggerFactory;
2929

3030
/**
31-
* Specialised Implementation of {@link Printer} for a HP Printer, in
32-
* this case the message to be printed is appended to "HP Printer : "
31+
* Specialised Implementation of {@link Printer} for a HP Printer, in this case the message to be
32+
* printed is appended to "HP Printer : ".
3333
*
3434
* @see Printer
3535
*/

dependency-injection/src/main/java/com/iluwatar/dependency/injection/AdvancedSorceress.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,6 @@
2323

2424
package com.iluwatar.dependency.injection;
2525

26-
/**
27-
* The MIT License
28-
* Copyright (c) 2014-2017 Ilkka Seppälä
29-
* <p>
30-
* Permission is hereby granted, free of charge, to any person obtaining a copy
31-
* of this software and associated documentation files (the "Software"), to deal
32-
* in the Software without restriction, including without limitation the rights
33-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
34-
* copies of the Software, and to permit persons to whom the Software is
35-
* furnished to do so, subject to the following conditions:
36-
* <p>
37-
* The above copyright notice and this permission notice shall be included in
38-
* all copies or substantial portions of the Software.
39-
* <p>
40-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
41-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
42-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
43-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
44-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
45-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
46-
* THE SOFTWARE.
47-
*/
48-
49-
5026
/**
5127
* AdvancedSorceress implements inversion of control. It depends on abstraction that can be injected
5228
* through its setter.

dependency-injection/src/main/java/com/iluwatar/dependency/injection/AdvancedWizard.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@
2424
package com.iluwatar.dependency.injection;
2525

2626
/**
27-
*
2827
* AdvancedWizard implements inversion of control. It depends on abstraction that can be injected
2928
* through its constructor.
30-
*
3129
*/
3230
public class AdvancedWizard implements Wizard {
3331

dependency-injection/src/main/java/com/iluwatar/dependency/injection/App.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,26 @@
3131
* implements so called inversion of control principle. Inversion of control has two specific rules:
3232
* - High-level modules should not depend on low-level modules. Both should depend on abstractions.
3333
* - Abstractions should not depend on details. Details should depend on abstractions.
34-
* <p>
35-
* In this example we show you three different wizards. The first one ({@link SimpleWizard}) is a
36-
* naive implementation violating the inversion of control principle. It depends directly on a
34+
*
35+
* <p>In this example we show you three different wizards. The first one ({@link SimpleWizard}) is
36+
* a naive implementation violating the inversion of control principle. It depends directly on a
3737
* concrete implementation which cannot be changed.
38-
* <p>
39-
* The second and third wizards({@link AdvancedWizard} and {@link AdvancedSorceress}) are more flexible.
40-
* They do not depend on any concrete implementation but abstraction. They utilizes Dependency Injection
41-
* pattern allowing their {@link Tobacco} dependency to be injected through constructor ({@link AdvancedWizard})
42-
* or setter ({@link AdvancedSorceress}). This way, handling the dependency is no longer the wizard's
43-
* responsibility. It is resolved outside the wizard class.
44-
* <p>
45-
* The fourth example takes the pattern a step further. It uses Guice framework for Dependency
38+
*
39+
* <p>The second and third wizards({@link AdvancedWizard} and {@link AdvancedSorceress}) are more
40+
* flexible. They do not depend on any concrete implementation but abstraction. They utilizes
41+
* Dependency Injection pattern allowing their {@link Tobacco} dependency to be injected through
42+
* constructor ({@link AdvancedWizard}) or setter ({@link AdvancedSorceress}). This way, handling
43+
* the dependency is no longer the wizard's responsibility. It is resolved outside the wizard
44+
* class.
45+
*
46+
* <p>The fourth example takes the pattern a step further. It uses Guice framework for Dependency
4647
* Injection. {@link TobaccoModule} binds a concrete implementation to abstraction. Injector is then
4748
* used to create {@link GuiceWizard} object with correct dependencies.
4849
*/
4950
public class App {
5051

5152
/**
52-
* Program entry point
53+
* Program entry point.
5354
*
5455
* @param args command line args
5556
*/

dependency-injection/src/main/java/com/iluwatar/dependency/injection/GuiceWizard.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@
2626
import javax.inject.Inject;
2727

2828
/**
29-
*
3029
* GuiceWizard implements inversion of control. Its dependencies are injected through its
3130
* constructor by Guice framework.
32-
*
3331
*/
3432
public class GuiceWizard implements Wizard {
3533

0 commit comments

Comments
 (0)