Implement method injection priority (higher earlier)

This commit is contained in:
Gabriel Tofvesson 2021-01-28 07:07:55 +01:00
parent c5e9a4270a
commit e4064fa5e0
2 changed files with 8 additions and 2 deletions

View File

@ -128,8 +128,12 @@ public final class GraftSource {
return fieldAnnotations.get(node);
}
public Set<MethodNode> getInjectMethods() {
return methodAnnotations.keySet();
public List<MethodNode> getInjectMethods() {
return methodAnnotations
.keySet()
.stream()
.sorted(Comparator.comparingInt(a -> getInjectAnnotation(a).getEntry("priority")))
.collect(Collectors.toList());
}
public Set<FieldNode> getInjectFields() {

View File

@ -30,4 +30,6 @@ public @interface Inject {
* @return True if the injection method should receive the return value
*/
boolean acceptOriginalReturn() default false;
int priority() default Integer.MIN_VALUE;
}