public int compare(Field field1, Field field2) {
      Class<?> field1Type = field1.getType();
      Class<?> field2Type = field2.getType();

      // if same type, compares on field name
      if (field1Type == field2Type) {
        return field1.getName().compareTo(field2.getName());
      }
      if (field1Type.isAssignableFrom(field2Type)) {
        return 1;
      }
      if (field2Type.isAssignableFrom(field1Type)) {
        return -1;
      }
      return 0;
    }
  private List<Field> orderedInstanceFieldsFrom(Class<?> awaitingInjectionClazz) {
    List<Field> declaredFields = Arrays.asList(awaitingInjectionClazz.getDeclaredFields());
    declaredFields = ListUtil.filter(declaredFields, notFinalOrStatic);

    Collections.sort(declaredFields, superTypesLast);

    return declaredFields;
  }
  public boolean processInjection(
      Field injectMocksField, Object injectMocksFieldOwner, Set<Object> mockCandidates) {
    // Set<Object> mocksToBeInjected = new HashSet<Object>(mockCandidates);
    FieldInitializationReport report =
        initializeInjectMocksField(injectMocksField, injectMocksFieldOwner);

    // for each field in the class hierarchy
    boolean injectionOccurred = false;
    Class<?> fieldClass = report.fieldClass();
    Object fieldInstanceNeedingInjection = report.fieldInstance();
    while (fieldClass != Object.class) {
      injectionOccurred |=
          injectMockCandidates(
              fieldClass, newMockSafeHashSet(mockCandidates), fieldInstanceNeedingInjection);
      fieldClass = fieldClass.getSuperclass();
    }
    return injectionOccurred;
  }