Lambda 示例
源码来源: Github java-design-patterns/factory-kit
基础类
1 | public interface Weapon { |
1 | public enum WeaponType { |
1 | public class Sword implements Weapon { |
1 | import java.util.function.Supplier; |
1 | import java.util.HashMap; |
非 Lambda 方式实现 WeaponFactory
1 | static WeaponFactory factory2(Consumer<Builder> consumer) { |
Lambda 方式初始化 WeaponFactory
1 | private static WeaponFactory getWeaponFactory_lam() { |
非 Lambda 方式初始化 WeaponFactory
1 | private static WeaponFactory getWeaponFactory() { |