File tree Expand file tree Collapse file tree
src/main/java/com/iluwatar/factorykit
factory-method/src/test/java/com/iluwatar/factory/method Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111---
1212
1313## Intent
14- Define factory of immutable content with separated builder and factory interfaces.
14+ Define a factory of immutable content with separated builder and factory interfaces.
1515
1616![ alt text] ( ./etc/factory-kit.png " Factory Kit ")
1717
Original file line number Diff line number Diff line change 11package com .iluwatar .factorykit ;
22
3+ /**
4+ * Factory-kit is a creational pattern which defines a factory of immutable content
5+ * with separated builder and factory interfaces to deal with the problem of
6+ * creating one of the objects specified directly in the factory-kit instance.
7+ *
8+ * <p>
9+ * In the given example {@link WeaponFactory} represents the factory-kit, that contains
10+ * four {@link Builder}s for creating new objects of
11+ * the classes implementing {@link Weapon} interface.
12+ * <br>Each of them can be called with {@link WeaponFactory#create(WeaponType)} method, with
13+ * an input representing an instance of {@link WeaponType} that needs to
14+ * be mapped explicitly with desired class type in the factory instance.
15+ */
316public class App {
417 /**
518 * Program entry point.
Original file line number Diff line number Diff line change @@ -93,9 +93,9 @@ public void testElfBlacksmithWithSpear() {
9393 * @param expectedWeaponType expected WeaponType of the weapon
9494 * @param clazz expected class of the weapon
9595 */
96- private void verifyWeapon (Weapon weapon , WeaponType expectedWeaponType , Class clazz ) {
96+ private void verifyWeapon (Weapon weapon , WeaponType expectedWeaponType , Class <?> clazz ) {
9797 assertTrue ("Weapon must be an object of: " + clazz .getName (), clazz .isInstance (weapon ));
9898 assertEquals ("Weapon must be of weaponType: " + clazz .getName (), expectedWeaponType ,
9999 weapon .getWeaponType ());
100100 }
101- }
101+ }
You can’t perform that action at this time.
0 commit comments