#1021 Checkstyle changes for Factory Method
This commit is contained in:
parent
7dc47da131
commit
47ae477a56
@ -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 classes—rather 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
|
||||
*/
|
||||
|
@ -24,9 +24,7 @@
|
||||
package com.iluwatar.factory.method;
|
||||
|
||||
/**
|
||||
*
|
||||
* The interface containing method for producing objects.
|
||||
*
|
||||
*/
|
||||
public interface Blacksmith {
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -24,9 +24,7 @@
|
||||
package com.iluwatar.factory.method;
|
||||
|
||||
/**
|
||||
*
|
||||
* WeaponType enumeration
|
||||
*
|
||||
* WeaponType enumeration.
|
||||
*/
|
||||
public enum WeaponType {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user