class AspectJPrecedenceComparator
extends java.lang.Object
implements java.util.Comparator
Given two pieces of advice, a
and b
:
a
and b
are defined in different
aspects, then the advice in the aspect with the lowest order
value has the highest precedencea
and b
are defined in the same
aspect, then if one of a
or b
is a form of
after advice, then the advice declared last in the aspect has the
highest precedence. If neither a
nor b
is a
form of after advice, then the advice declared first in the aspect has
the highest precedence.Important: Note that unlike a normal comparator a return of 0 means we don't care about the ordering, not that the two elements must be sorted identically. Used with AspectJ PartialOrder class.
Modifier and Type | Field and Description |
---|---|
private java.util.Comparator<? super Advisor> |
advisorComparator |
private static int |
HIGHER_PRECEDENCE |
private static int |
LOWER_PRECEDENCE |
private static int |
NOT_COMPARABLE |
private static int |
SAME_PRECEDENCE |
Constructor and Description |
---|
AspectJPrecedenceComparator()
Create a default AspectJPrecedenceComparator.
|
AspectJPrecedenceComparator(java.util.Comparator<? super Advisor> advisorComparator)
Create a AspectJPrecedenceComparator, using the given Comparator
for comparing
Advisor instances. |
Modifier and Type | Method and Description |
---|---|
int |
compare(java.lang.Object o1,
java.lang.Object o2) |
private int |
comparePrecedenceWithinAspect(Advisor advisor1,
Advisor advisor2) |
private boolean |
declaredInSameAspect(Advisor advisor1,
Advisor advisor2) |
private int |
getAspectDeclarationOrder(Advisor anAdvisor) |
private java.lang.String |
getAspectName(Advisor anAdvisor) |
private boolean |
hasAspectName(Advisor anAdvisor) |
private static final int HIGHER_PRECEDENCE
private static final int SAME_PRECEDENCE
private static final int LOWER_PRECEDENCE
private static final int NOT_COMPARABLE
private final java.util.Comparator<? super Advisor> advisorComparator
public AspectJPrecedenceComparator()
public int compare(java.lang.Object o1, java.lang.Object o2)
compare
in interface java.util.Comparator
private int comparePrecedenceWithinAspect(Advisor advisor1, Advisor advisor2)
private boolean hasAspectName(Advisor anAdvisor)
private java.lang.String getAspectName(Advisor anAdvisor)
private int getAspectDeclarationOrder(Advisor anAdvisor)