issue #333 javadocs changes
This commit is contained in:
parent
2fa705ab59
commit
6ab9b36d59
@ -1,7 +1,11 @@
|
||||
package com.iluwatar.factorykit;
|
||||
|
||||
public class App {
|
||||
|
||||
/**
|
||||
* Program entry point.
|
||||
*
|
||||
* @param args @param args command line args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
WeaponFactory factory = WeaponFactory.factory(builder -> {
|
||||
builder.add(WeaponType.SWORD, Sword::new);
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.iluwatar.factorykit;
|
||||
|
||||
/**
|
||||
* Interface representing weapon
|
||||
* Interface representing weapon.
|
||||
*/
|
||||
public interface Weapon {
|
||||
}
|
||||
|
@ -5,14 +5,26 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Functional interface that represents factory kit. Instance created locally gives an opportunity to strictly define
|
||||
* which objects types the instance of a factory would be able to create. Factory is just a placeholder for builders with
|
||||
* create method to initialize new objects.
|
||||
* Functional interface, an example of the factory-kit design pattern.
|
||||
* <br>Instance created locally gives an opportunity to strictly define
|
||||
* which objects types the instance of a factory will be able to create.
|
||||
* <br>Factory is a placeholder for {@link Builder}s
|
||||
* with {@link WeaponFactory#create(WeaponType)} method to initialize new objects.
|
||||
*/
|
||||
public interface WeaponFactory {
|
||||
|
||||
/**
|
||||
* Creates an instance of the given type.
|
||||
* @param name representing enum of an object type to be created.
|
||||
* @return new instance of a requested class implementing {@link Weapon} interface.
|
||||
*/
|
||||
Weapon create(WeaponType name);
|
||||
|
||||
/**
|
||||
* Creates factory - placeholder for specified {@link Builder}s.
|
||||
* @param consumer for the new builder to the factory.
|
||||
* @return factory with specified {@link Builder}s
|
||||
*/
|
||||
static WeaponFactory factory(Consumer<Builder> consumer) {
|
||||
HashMap<WeaponType, Supplier<Weapon>> map = new HashMap<>();
|
||||
consumer.accept(map::put);
|
||||
|
@ -1,5 +1,8 @@
|
||||
package com.iluwatar.factorykit;
|
||||
|
||||
/**
|
||||
* Enumerates {@link Weapon} types
|
||||
*/
|
||||
public enum WeaponType {
|
||||
SWORD, AXE, BOW, SPEAR
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user