Only apply config-wide require value to un-grouped injectors

This commit is contained in:
Mumfrey committed 2016-01-13 01:53:36 +00:00
1 parent c6859f713f
commit 0543aab770
2 files changed
+18 -3

No files matched your search

@@ -48,7 +48,7 @@ public class InjectorGroupInfo {
private static final long serialVersionUID = 1L;
private static final InjectorGroupInfo NO_GROUP = new InjectorGroupInfo("NONE");
private static final InjectorGroupInfo NO_GROUP = new InjectorGroupInfo("NONE", true);
@Override
public InjectorGroupInfo get(Object key) {
@@ -138,6 +138,11 @@ public class InjectorGroupInfo {
*/
private final List<InjectionInfo> members = new ArrayList<InjectionInfo>();
/**
* True if this is the default group
*/
private final boolean isDefault;
/**
* Number of callbacks we require injected across this group
*/
@@ -147,9 +152,14 @@ public class InjectorGroupInfo {
* Maximum number of callbacks allowed across this group
*/
private int maxCallbackCount = Integer.MAX_VALUE;
public InjectorGroupInfo(String name) {
this(name, false);
}
InjectorGroupInfo(String name, boolean flag) {
this.name = name;
this.isDefault = flag;
}
@Override
@@ -157,6 +167,10 @@ public class InjectorGroupInfo {
return String.format("@Group(name=%s, min=%d, max=%d)", this.getName(), this.getMinRequired(), this.getMaxAllowed());
}
public boolean isDefault() {
return this.isDefault;
}
public String getName() {
return this.name;
}
@@ -134,7 +134,6 @@ public abstract class InjectionInfo {
this.annotationType = annotation.desc.substring(annotation.desc.lastIndexOf('/') + 1).replace(";", "");
this.classNode = mixin.getTargetClass();
this.isStatic = ASMHelper.methodIsStatic(method);
this.requiredCallbackCount = mixin.getDefaultRequiredInjections();
this.readAnnotation();
}
@@ -195,6 +194,8 @@ public abstract class InjectionInfo {
Integer require = ASMHelper.<Integer>getAnnotationValue(this.annotation, "require");
if (require != null) {
this.requiredCallbackCount = require.intValue();
} else if (this.group.isDefault()) {
this.requiredCallbackCount = this.mixin.getDefaultRequiredInjections();
}
this.injector = this.initInjector(this.annotation);