#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;
/**
*
* 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.
* 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
* 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 (
* {@link OrcBlacksmith}, {@link ElfBlacksmith}) then override the method to produce objects of
* their liking.
@ -59,7 +58,7 @@ public class App {
}
/**
* Program entry point
* Program entry point.
*
* @param args command line args
*/

View File

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

View File

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

View File

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

View File

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