# whenCompared method

1. @override

int whenCompared(

1. Object? o1,
2. Object? o2

)
override

Compares two objects using annotation-aware ordering rules.

This method extends the base comparison logic to first attempt order resolution through the findOrder method, which handles annotation-based ordering. If both objects have explicit order values, they are compared directly. Otherwise, falls back to the standard OrderComparator logic.

### Comparison Strategy:

1. Resolve order values for both objects using findOrder
2. If both have explicit orders, compare numerically
3. Otherwise, delegate to parent OrderComparator for standard rules
4. Maintains PriorityOrdered precedence over regular Ordered

### Parameters:

- `o1`: The first object to compare
- `o2`: The second object to compare

### Returns:

- Negative integer if `o1` should come before `o2`
- Positive integer if `o2` should come before `o1`
- Zero if objects have equal ordering precedence

### Example:

    final comparator = AnnotationAwareOrderComparator();

    @Order(1)
    class ServiceA {}

    class ServiceB implements Ordered {
      @override int get order => 2;
    }

    final result = comparator.whenCompared(Class<ServiceA>(), Class<ServiceB>());
    print(result); // -1 (ServiceA comes before ServiceB)

## Implementation

    @override
    int whenCompared(Object? o1, Object? o2) {
      final order1 = findOrder(o1);
      final order2 = findOrder(o2);

      if (order1 != null && order2 != null) {
        return order1.compareTo(order2);
      }

      return OrderComparator().whenCompared(o1, o2);
    }