// Path: src/main/java/com/fluentinterface/ReflectionBuilder.java
// public class ReflectionBuilder<B> {
// 
//     private static BuilderDelegate defaultBuilderDelegate = new DefaultBuilderDelegate();
// 
//     private BuilderDelegate<? super B> builderDelegate;
//     private Class<B> builderInterface;
//     private Class<?> builtClass = null;
//     private PropertyAccessStrategy propertyAccessStrategy;
//     private Instantiator instantiator;
// 
//     @SuppressWarnings("unchecked")
//     private ReflectionBuilder(Class<B> builderInterface) {
//         if (!builderInterface.isInterface()) {
//             throw new IllegalArgumentException(String.format(
//                     "Can only create dynamic builder for interfaces. [%s] is not an interface.", builderInterface));
//         }
// 
//         this.builderInterface = builderInterface;
//         this.builderDelegate = defaultBuilderDelegate;
//         this.propertyAccessStrategy = new SetterPropertyAccessStrategy();
//     }
// 
//     public static void setDefaultBuilderDelegate(BuilderDelegate delegate) {
//         defaultBuilderDelegate = delegate;
//     }
// 
//     public static <T> ReflectionBuilder<T> implementationFor(Class<T> builderInterface) {
//         return new ReflectionBuilder<>(builderInterface);
//     }
// 
//     public ReflectionBuilder<B> builds(Class<?> objectsOfType) {
//         this.builtClass = objectsOfType;
//         return this;
//     }
// 
//     public ReflectionBuilder<B> withDelegate(BuilderDelegate<? super B> builderDelegate) {
//         this.builderDelegate = builderDelegate;
//         return this;
//     }
// 
//     public ReflectionBuilder<B> usingAttributeAccessStrategy(PropertyAccessStrategy strategy) {
//         this.propertyAccessStrategy = strategy;
//         return this;
//     }
// 
//     public ReflectionBuilder<B> usingFieldsDirectly() {
//         this.propertyAccessStrategy = new FieldPropertyAccessStrategy();
//         return this;
//     }
// 
//     public ReflectionBuilder<B> usingInstantiator(Instantiator instantiator) {
//         this.instantiator = instantiator;
//         return this;
//     }
// 
//     public Class<?> getBuiltClass() {
//         if (builtClass != null) {
//             return builtClass;
//         }
// 
//         builtClass = builderDelegate.getClassBuiltBy(builderInterface);
// 
//         if (builtClass == null) {
//             throw new IllegalStateException(String.format(
//                     "Could not imply class being built by builder [%s]. " +
//                             "If the interface does not extend [%s], you must explicitly set the type of object being built using the 'builds(class)' method.",
//                     builderInterface, Builder.class
//             ));
//         }
// 
//         return builtClass;
//     }
// 
//     @SuppressWarnings("unchecked")
//     public B create() {
//         InvocationHandler handler = new BuilderProxy(builderInterface, getBuiltClass(),
//                                                      builderDelegate, propertyAccessStrategy, instantiator);
// 
//         return (B) Proxy.newProxyInstance(
//                 builderInterface.getClassLoader(),
//                 new Class[]{builderInterface},
//                 handler);
//     }
// 
// }
// 
// Path: src/main/java/com/fluentinterface/builder/Builder.java
// public interface Builder<T> {
//     /**
//      * Creates an object instance of the target class being built from the state that was set using the builder's methods.
//      *
//      * @param constructorArgs (optional) when specified, a matching constructor will be looked up on the target class and
//      *                        this constructor (if found) will be used to instantiate your object.
//      * @return an object instance initialized as the builder was used.
//      */
//     T build(Object... constructorArgs);
// }
// 
// Path: src/main/java/com/fluentinterface/utils/MapBuilder.java
// public static <K, V> MapBuilder<K, V> mappingOf(K key, V value) {
//     return new MapBuilder<>(key, value);
// }
// 
// Path: src/main/java/com/fluentinterface/utils/MapBuilder.java
// public static MapBuilder<Object, Object> map() {
//     return new MapBuilder<>();
// }


import com.fluentinterface.ReflectionBuilder;
import com.fluentinterface.builder.Builder;
import org.junit.Test;
import java.util.Map;
import static com.fluentinterface.utils.MapBuilder.mappingOf;
import static com.fluentinterface.utils.MapBuilder.map;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.*;
package com.fluentinterface.utils;




public class MapBuilderTest {
    
    @Test
    public void testBuildTypedMap() throws Exception {

        Map<String, Integer> built =
                mappingOf("key1", 2)
                        .and("key2", 5)
                        .build();

        assertThat("map size", built.size(), is(2));
        assertThat(built.get("key1"), is(2));
        assertThat(built.get("key2"), is(5));
    }
    
    @Test
    public void testBuildUntypedMap() throws Exception {

        Map<Object, Object> built =
                map()
                        .with("key1", 5)
                        .with("key2", "value")
                        .build();

        assertThat("map size", built.size(), is(2));
        assertThat(built.get("key1"), is(5));
        assertThat(built.get("key2"), is("value"));
    }

    @Test
    public void testUsageWithinOtherBuilder() throws Exception {

        BeanBuilder aBean = ReflectionBuilder
                .implementationFor(BeanBuilder.class)
                .usingFieldsDirectly()
                .create();

        Bean built = aBean
// Path: src/main/java/com/fluentinterface/ReflectionBuilder.java
// public class ReflectionBuilder<B> {
// 
//     private static BuilderDelegate defaultBuilderDelegate = new DefaultBuilderDelegate();
// 
//     private BuilderDelegate<? super B> builderDelegate;
//     private Class<B> builderInterface;
//     private Class<?> builtClass = null;
//     private PropertyAccessStrategy propertyAccessStrategy;
//     private Instantiator instantiator;
// 
//     @SuppressWarnings("unchecked")
//     private ReflectionBuilder(Class<B> builderInterface) {
//         if (!builderInterface.isInterface()) {
//             throw new IllegalArgumentException(String.format(
//                     "Can only create dynamic builder for interfaces. [%s] is not an interface.", builderInterface));
//         }
// 
//         this.builderInterface = builderInterface;
//         this.builderDelegate = defaultBuilderDelegate;
//         this.propertyAccessStrategy = new SetterPropertyAccessStrategy();
//     }
// 
//     public static void setDefaultBuilderDelegate(BuilderDelegate delegate) {
//         defaultBuilderDelegate = delegate;
//     }
// 
//     public static <T> ReflectionBuilder<T> implementationFor(Class<T> builderInterface) {
//         return new ReflectionBuilder<>(builderInterface);
//     }
// 
//     public ReflectionBuilder<B> builds(Class<?> objectsOfType) {
//         this.builtClass = objectsOfType;
//         return this;
//     }
// 
//     public ReflectionBuilder<B> withDelegate(BuilderDelegate<? super B> builderDelegate) {
//         this.builderDelegate = builderDelegate;
//         return this;
//     }
// 
//     public ReflectionBuilder<B> usingAttributeAccessStrategy(PropertyAccessStrategy strategy) {
//         this.propertyAccessStrategy = strategy;
//         return this;
//     }
// 
//     public ReflectionBuilder<B> usingFieldsDirectly() {
//         this.propertyAccessStrategy = new FieldPropertyAccessStrategy();
//         return this;
//     }
// 
//     public ReflectionBuilder<B> usingInstantiator(Instantiator instantiator) {
//         this.instantiator = instantiator;
//         return this;
//     }
// 
//     public Class<?> getBuiltClass() {
//         if (builtClass != null) {
//             return builtClass;
//         }
// 
//         builtClass = builderDelegate.getClassBuiltBy(builderInterface);
// 
//         if (builtClass == null) {
//             throw new IllegalStateException(String.format(
//                     "Could not imply class being built by builder [%s]. " +
//                             "If the interface does not extend [%s], you must explicitly set the type of object being built using the 'builds(class)' method.",
//                     builderInterface, Builder.class
//             ));
//         }
// 
//         return builtClass;
//     }
// 
//     @SuppressWarnings("unchecked")
//     public B create() {
//         InvocationHandler handler = new BuilderProxy(builderInterface, getBuiltClass(),
//                                                      builderDelegate, propertyAccessStrategy, instantiator);
// 
//         return (B) Proxy.newProxyInstance(
//                 builderInterface.getClassLoader(),
//                 new Class[]{builderInterface},
//                 handler);
//     }
// 
// }
// 
// Path: src/main/java/com/fluentinterface/builder/Builder.java
// public interface Builder<T> {
//     /**
//      * Creates an object instance of the target class being built from the state that was set using the builder's methods.
//      *
//      * @param constructorArgs (optional) when specified, a matching constructor will be looked up on the target class and
//      *                        this constructor (if found) will be used to instantiate your object.
//      * @return an object instance initialized as the builder was used.
//      */
//     T build(Object... constructorArgs);
// }
// 
// Path: src/main/java/com/fluentinterface/utils/MapBuilder.java
// public static <K, V> MapBuilder<K, V> mappingOf(K key, V value) {
//     return new MapBuilder<>(key, value);
// }
// 
// Path: src/main/java/com/fluentinterface/utils/MapBuilder.java
// public static MapBuilder<Object, Object> map() {
//     return new MapBuilder<>();
// }


// Path: src/test/java/com/fluentinterface/utils/MapBuilderTest.java
import com.fluentinterface.ReflectionBuilder;
import com.fluentinterface.builder.Builder;
import org.junit.Test;
import java.util.Map;
import static com.fluentinterface.utils.MapBuilder.mappingOf;
import static com.fluentinterface.utils.MapBuilder.map;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.*;

package com.fluentinterface.utils;




public class MapBuilderTest {
    
    @Test
    public void testBuildTypedMap() throws Exception {

        Map<String, Integer> built =
                mappingOf("key1", 2)
                        .and("key2", 5)
                        .build();

        assertThat("map size", built.size(), is(2));
        assertThat(built.get("key1"), is(2));
        assertThat(built.get("key2"), is(5));
    }
    
    @Test
    public void testBuildUntypedMap() throws Exception {

        Map<Object, Object> built =
                map()
                        .with("key1", 5)
                        .with("key2", "value")
                        .build();

        assertThat("map size", built.size(), is(2));
        assertThat(built.get("key1"), is(5));
        assertThat(built.get("key2"), is("value"));
    }

    @Test
    public void testUsageWithinOtherBuilder() throws Exception {

        BeanBuilder aBean = ReflectionBuilder
                .implementationFor(BeanBuilder.class)
                .usingFieldsDirectly()
                .create();

        Bean built = aBean
                .withDetails(mappingOf("key1", 2))