@Test public void testQueryStateWilderness() throws Exception { MockApplicableRegionSet mock = new MockApplicableRegionSet(); StateFlag flag1 = new StateFlag("test1", false); StateFlag flag2 = new StateFlag("test2", true); FlagValueCalculator result = mock.getFlagCalculator(); assertThat(result.queryState(null, flag1), is((State) null)); assertThat(result.queryState(null, flag2), is(State.ALLOW)); }
@Nullable public State queryState(@Nullable RegionAssociable subject, StateFlag... flags) { State value = null; for (StateFlag flag : flags) { value = StateFlag.combine(value, queryValue(subject, flag)); if (value == State.DENY) { break; } } return value; }
FlagValueCalculator { @Nullable public State queryState(@Nullable RegionAssociable subject, StateFlag... flags) { State value = null; for (StateFlag flag : flags) { value = StateFlag.combine(value, queryValue(subject, flag)); if (value == State.DENY) { break; } } return value; } }
FlagValueCalculator { @Nullable public State queryState(@Nullable RegionAssociable subject, StateFlag... flags) { State value = null; for (StateFlag flag : flags) { value = StateFlag.combine(value, queryValue(subject, flag)); if (value == State.DENY) { break; } } return value; } FlagValueCalculator(List<ProtectedRegion> regions, @Nullable ProtectedRegion globalRegion); }
FlagValueCalculator { @Nullable public State queryState(@Nullable RegionAssociable subject, StateFlag... flags) { State value = null; for (StateFlag flag : flags) { value = StateFlag.combine(value, queryValue(subject, flag)); if (value == State.DENY) { break; } } return value; } FlagValueCalculator(List<ProtectedRegion> regions, @Nullable ProtectedRegion globalRegion); Result getMembership(RegionAssociable subject); @Nullable State queryState(@Nullable RegionAssociable subject, StateFlag... flags); @Nullable State queryState(@Nullable RegionAssociable subject, StateFlag flag); @Nullable V queryValue(@Nullable RegionAssociable subject, Flag<V> flag); Collection<V> queryAllValues(@Nullable RegionAssociable subject, Flag<V> flag); int getPriority(final ProtectedRegion region); @SuppressWarnings("unchecked") V getEffectiveFlag(final ProtectedRegion region, Flag<V> flag, @Nullable RegionAssociable subject); }
FlagValueCalculator { @Nullable public State queryState(@Nullable RegionAssociable subject, StateFlag... flags) { State value = null; for (StateFlag flag : flags) { value = StateFlag.combine(value, queryValue(subject, flag)); if (value == State.DENY) { break; } } return value; } FlagValueCalculator(List<ProtectedRegion> regions, @Nullable ProtectedRegion globalRegion); Result getMembership(RegionAssociable subject); @Nullable State queryState(@Nullable RegionAssociable subject, StateFlag... flags); @Nullable State queryState(@Nullable RegionAssociable subject, StateFlag flag); @Nullable V queryValue(@Nullable RegionAssociable subject, Flag<V> flag); Collection<V> queryAllValues(@Nullable RegionAssociable subject, Flag<V> flag); int getPriority(final ProtectedRegion region); @SuppressWarnings("unchecked") V getEffectiveFlag(final ProtectedRegion region, Flag<V> flag, @Nullable RegionAssociable subject);  }