Fix check for detecting existing filter being overridden
@@ -43,7 +43,8 @@ public class Method {
private String[] returnName;
private String[] returnDesc;
- private RequestAccessFilter filter = RequireCapabilitiesFilter.unclassified();
+ private static final RequireCapabilitiesFilter defaultFilter = RequireCapabilitiesFilter.unclassified();
+ private RequestAccessFilter filter = defaultFilter;
private static final String undocumented = "???";
@@ -152,14 +153,16 @@ public class Method {
return this;
}
- public Method requestAccessFilter(RequestAccessFilter filter) { this.filter = filter; return this; }
+ public Method requestAccessFilter(RequestAccessFilter filter) { verifyNoFilterAssigned(); this.filter = filter; return this; }
public Method requireCapabilities(Capability... capabilities) { return requireCapabilities(CapabilitySet.from(capabilities)); }
public Method requireCapabilities(CapabilitySet capabilities) {
- if (filter != null) throw new IllegalStateException();
+ verifyNoFilterAssigned();
filter = new RequireCapabilitiesFilter(capabilities);
return this;
}
+ private void verifyNoFilterAssigned() { if (filter != null && filter != defaultFilter) throw new IllegalStateException(); }
+
public RequestAccessFilter requestAccessFilter() { return filter; }
/**
