#1021 Checkstyle changes for Factory Method

This commit is contained in:
Ilkka Seppälä 2019-11-05 17:28:08 +02:00
parent 7dc47da131
commit 47ae477a56
5 changed files with 14 additions and 21 deletions

View File

@ -27,14 +27,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
*
* The Factory Method is a creational design pattern which uses factory methods to deal with the * The Factory Method is a creational design pattern which uses factory methods to deal with the
* problem of creating objects without specifying the exact class of object that will be created. * problem of creating objects without specifying the exact class of object that will be created.
* This is done by creating objects via calling a factory method either specified in an interface * This is done by creating objects via calling a factory method either specified in an interface
* and implemented by child classes, or implemented in a base class and optionally overridden by * and implemented by child classes, or implemented in a base class and optionally overridden by
* derived classesrather than by calling a constructor. * derived classesrather than by calling a constructor.
* <p> *
* In this Factory Method example we have an interface ({@link Blacksmith}) with a method for * <p>In this Factory Method example we have an interface ({@link Blacksmith}) with a method for
* creating objects ({@link Blacksmith#manufactureWeapon}). The concrete subclasses ( * creating objects ({@link Blacksmith#manufactureWeapon}). The concrete subclasses (
* {@link OrcBlacksmith}, {@link ElfBlacksmith}) then override the method to produce objects of * {@link OrcBlacksmith}, {@link ElfBlacksmith}) then override the method to produce objects of
* their liking. * their liking.
@ -59,7 +58,7 @@ public class App {
} }
/** /**
* Program entry point * Program entry point.
* *
* @param args command line args * @param args command line args
*/ */

View File

@ -24,9 +24,7 @@
package com.iluwatar.factory.method; package com.iluwatar.factory.method;
/** /**
*
* The interface containing method for producing objects. * The interface containing method for producing objects.
*
*/ */
public interface Blacksmith { public interface Blacksmith {

View File

@ -27,13 +27,12 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
*
* Concrete subclass for creating new objects. * Concrete subclass for creating new objects.
*
*/ */
public class ElfBlacksmith implements Blacksmith { public class ElfBlacksmith implements Blacksmith {
private static Map<WeaponType, ElfWeapon> ELFARSENAL; private static Map<WeaponType, ElfWeapon> ELFARSENAL;
static { static {
ELFARSENAL = new HashMap<>(WeaponType.values().length); ELFARSENAL = new HashMap<>(WeaponType.values().length);
for (WeaponType type : WeaponType.values()) { for (WeaponType type : WeaponType.values()) {

View File

@ -27,13 +27,12 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
*
* Concrete subclass for creating new objects. * Concrete subclass for creating new objects.
*
*/ */
public class OrcBlacksmith implements Blacksmith { public class OrcBlacksmith implements Blacksmith {
private static Map<WeaponType, OrcWeapon> ORCARSENAL; private static Map<WeaponType, OrcWeapon> ORCARSENAL;
static { static {
ORCARSENAL = new HashMap<>(WeaponType.values().length); ORCARSENAL = new HashMap<>(WeaponType.values().length);
for (WeaponType type : WeaponType.values()) { for (WeaponType type : WeaponType.values()) {

View File

@ -24,9 +24,7 @@
package com.iluwatar.factory.method; package com.iluwatar.factory.method;
/** /**
* * WeaponType enumeration.
* WeaponType enumeration
*
*/ */
public enum WeaponType { public enum WeaponType {