// Path: src/main/java/org/laughingpanda/beaninject/impl/Accessor.java
// public class Accessor {
// 
//     public static List<Method> methods(Class<?> clazz) {
//         Method[] declared = clazz.getDeclaredMethods();
//         List<Method> methods = new ArrayList<Method>(Arrays
//                 .asList(declared));
//         if (clazz.getSuperclass() != null) {
//             methods.addAll(methods(clazz.getSuperclass()));
//         }
//         return methods;
//     }
// 
//     public static List<Field> fields(Class<?> clazz) {
//         Field[] declared = clazz.getDeclaredFields();
//         List<Field> fields = new ArrayList<Field>(Arrays
//                 .asList(declared));
//         if (clazz.getSuperclass() != null) {
//             fields.addAll(fields(clazz.getSuperclass()));
//         }
//         return fields;
//     }
// 
//     public static Field field(String name, Class<?> clazz) {
//         for (Field field : fields(clazz)) {
//             if (field.getName().equals(name)) {
//                 return makeAccessible(field);
//             }
//         }
//         return null;
//     }
// 
//     private static Field makeAccessible(Field field) {
//         if (!field.isAccessible()) {
//             field.setAccessible(true);
//         }
//         return field;
//     }
// 
//     public static List<Field> fieldsAssignableFrom(Class<?> type,
//             Class<?> target) {
//         List<Field> fields = new ArrayList<Field>();
//         for (Field field : fields(target)) {
//             if (field.getType().isAssignableFrom(type)) {
//                 fields.add(field);
//             }
//         }
//         return fields;
//     }
// 
//     public static List<Field> fieldsOfType(Class<?> type, Class<?> target) {
//         List<Field> fields = new ArrayList<Field>();
//         for (Field field : fields(target)) {
//             if (field.getType().equals(type)) {
//                 fields.add(field);
//             }
//         }
//         return fields;
//     }
//     
//     public static Field annotatedField(
//             Class<? extends Annotation> annotation,
//             Class<? extends Object> clazz) {
//         for (Field field : fields(clazz)) {
//             if (field.isAnnotationPresent(annotation)) {
//                 return field;
//             }
//         }
//         return null;
//     }
// 
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import junit.framework.JUnit4TestAdapter;
import org.junit.Before;
import org.junit.Test;
import org.laughingpanda.beaninject.impl.Accessor;

    @SuppressWarnings("unused")
    public static class ClassWithMultipleFieldsOfSameType {
        private static Object privateStaticObject;
        private static Object anotherPrivateStaticObject;
        private static PepsiMax privateStaticPepsiMax;
        private static PepsiMax anotherPrivateStaticPepsiMax;
    }

    @SuppressWarnings("unused")
    public static class ClassWithMultipleFieldsOfSameInterface {
        private static Drinkable privateStaticDrinkable;
        private static Drinkable anotherPrivateStaticDrinkable;
    }

    @SuppressWarnings("unused")
    public static class ClassWithOneFieldOfEachNonRelatedType {
        private static int privateStaticInt;
        private static Apple privateStaticApple;
        private static Drinkable privateStaticDrinkable;
    }

    @Before
    public void setUp() throws Exception {
        resetStaticFieldsOf(ClassWithoutFields.class);
        resetStaticFieldsOf(ClassWithMultipleFieldsOfSameType.class);
        resetStaticFieldsOf(ClassWithMultipleFieldsOfSameInterface.class);
        resetStaticFieldsOf(ClassWithOneFieldOfEachNonRelatedType.class);
    }

    private void resetStaticFieldsOf(Class<?> klass) {

// Path: src/main/java/org/laughingpanda/beaninject/impl/Accessor.java
// public class Accessor {
// 
//     public static List<Method> methods(Class<?> clazz) {
//         Method[] declared = clazz.getDeclaredMethods();
//         List<Method> methods = new ArrayList<Method>(Arrays
//                 .asList(declared));
//         if (clazz.getSuperclass() != null) {
//             methods.addAll(methods(clazz.getSuperclass()));
//         }
//         return methods;
//     }
// 
//     public static List<Field> fields(Class<?> clazz) {
//         Field[] declared = clazz.getDeclaredFields();
//         List<Field> fields = new ArrayList<Field>(Arrays
//                 .asList(declared));
//         if (clazz.getSuperclass() != null) {
//             fields.addAll(fields(clazz.getSuperclass()));
//         }
//         return fields;
//     }
// 
//     public static Field field(String name, Class<?> clazz) {
//         for (Field field : fields(clazz)) {
//             if (field.getName().equals(name)) {
//                 return makeAccessible(field);
//             }
//         }
//         return null;
//     }
// 
//     private static Field makeAccessible(Field field) {
//         if (!field.isAccessible()) {
//             field.setAccessible(true);
//         }
//         return field;
//     }
// 
//     public static List<Field> fieldsAssignableFrom(Class<?> type,
//             Class<?> target) {
//         List<Field> fields = new ArrayList<Field>();
//         for (Field field : fields(target)) {
//             if (field.getType().isAssignableFrom(type)) {
//                 fields.add(field);
//             }
//         }
//         return fields;
//     }
// 
//     public static List<Field> fieldsOfType(Class<?> type, Class<?> target) {
//         List<Field> fields = new ArrayList<Field>();
//         for (Field field : fields(target)) {
//             if (field.getType().equals(type)) {
//                 fields.add(field);
//             }
//         }
//         return fields;
//     }
//     
//     public static Field annotatedField(
//             Class<? extends Annotation> annotation,
//             Class<? extends Object> clazz) {
//         for (Field field : fields(clazz)) {
//             if (field.isAnnotationPresent(annotation)) {
//                 return field;
//             }
//         }
//         return null;
//     }
// 
// }


// Path: src/test/java/org/laughingpanda/beaninject/TestStaticFieldInjection.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import junit.framework.JUnit4TestAdapter;
import org.junit.Before;
import org.junit.Test;
import org.laughingpanda.beaninject.impl.Accessor;

    @SuppressWarnings("unused")
    public static class ClassWithMultipleFieldsOfSameType {
        private static Object privateStaticObject;
        private static Object anotherPrivateStaticObject;
        private static PepsiMax privateStaticPepsiMax;
        private static PepsiMax anotherPrivateStaticPepsiMax;
    }

    @SuppressWarnings("unused")
    public static class ClassWithMultipleFieldsOfSameInterface {
        private static Drinkable privateStaticDrinkable;
        private static Drinkable anotherPrivateStaticDrinkable;
    }

    @SuppressWarnings("unused")
    public static class ClassWithOneFieldOfEachNonRelatedType {
        private static int privateStaticInt;
        private static Apple privateStaticApple;
        private static Drinkable privateStaticDrinkable;
    }

    @Before
    public void setUp() throws Exception {
        resetStaticFieldsOf(ClassWithoutFields.class);
        resetStaticFieldsOf(ClassWithMultipleFieldsOfSameType.class);
        resetStaticFieldsOf(ClassWithMultipleFieldsOfSameInterface.class);
        resetStaticFieldsOf(ClassWithOneFieldOfEachNonRelatedType.class);
    }

    private void resetStaticFieldsOf(Class<?> klass) {

        for (Field field : Accessor.fields(klass)) {
