An object that says where it goes when several objects of its kind are run or listed in turn; lower numbers come first.
When the framework holds many beans of one type, the order can matter:
which listener sees an event first, which runner starts first, the
order of an injected List<Handler>. Post-processors, event listeners,
runners, lifecycle beans and injected lists (not sets or maps) are
sorted this way.
Usually the @Order(n) annotation says it; implement this interface
instead when the order is computed at run time or the object is not a
bean declared with annotations. An object with no order goes last
(lowestPrecedence).
// Audits before the other listeners, but leaves room for ones that
// must be even earlier.
class AuditListener implements Ordered {
@override
int get order => Ordered.highestPrecedence + 10;
}
Spring (Java):
class AuditListener implements Ordered {
@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE + 10;
}
}
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- order → int
-
Where this object goes: lower values come first. Values are usually
small numbers, or offsets from highestPrecedence and
lowestPrecedence.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- highestPrecedence → const int
- The smallest order value, for objects that must come first.
- lowestPrecedence → const int
- The largest order value, for objects that must come last; also the order of objects that declare none.