Package net.sf.gridarta.model.filter
Class NamedFilter
- java.lang.Object
-
- net.sf.gridarta.model.filter.NamedFilter
-
- All Implemented Interfaces:
Filter<NamedFilter,NamedFilterConfig>
public class NamedFilter extends java.lang.Object implements Filter<NamedFilter,NamedFilterConfig>
AFilterthat aggregates named filters.This filter aggregates a list of named sub-filters. Each sub-filter can be (dis)enabled.
-
-
Constructor Summary
Constructors Constructor Description NamedFilter(@NotNull java.lang.Iterable<NamedGameObjectMatcher> matchers)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFilter(@NotNull java.lang.String name, @NotNull Filter<?,?> filter)Adds a sub-Filter.voidaddFilterListener(@NotNull NamedFilterListener listener)Adds aNamedFilterListenerto be notified about changes.booleancanShow(@NotNull GameObject<?,?,?> gameObject, @NotNull NamedFilterConfig filterOutConfig)Returns whether this filter matches aGameObject.@NotNull NamedFilterConfigcreateConfig()Creates a newFilterConfiginstance for this filter.booleanhasGlobalMatch(@NotNull NamedFilterConfig config)Tells if all the game objects on a square are to be analyzed before a match result.booleanmatch(@NotNull NamedFilterConfig config, @NotNull GameObject<?,?,?> gameObject)Tells whether we got a match on specificGameObject.voidremoveFilter(@NotNull java.lang.String name)Removes a sub-filter.voidremoveFilterListener(@NotNull NamedFilterListener listener)Removes aNamedFilterListenerto be notified about changes.booleanreset(@NotNull NamedFilterConfig config)This tells the filter we have finished with current map square and, perhaps, we are jumping on next one.voidresetConfig(@NotNull NamedFilterConfig config)Disables all sub-filters.
-
-
-
Constructor Detail
-
NamedFilter
public NamedFilter(@NotNull @NotNull java.lang.Iterable<NamedGameObjectMatcher> matchers)Creates a new instance.- Parameters:
matchers- the matchers to create filters from
-
-
Method Detail
-
resetConfig
public void resetConfig(@NotNull @NotNull NamedFilterConfig config)Disables all sub-filters.- Parameters:
config- the filter config to reset
-
match
public boolean match(@NotNull @NotNull NamedFilterConfig config, @NotNull @NotNull GameObject<?,?,?> gameObject)Description copied from interface:FilterTells whether we got a match on specificGameObject. The analysis tool will call this function with every game object on a given map square. The match function is responsible for analyzing inventories if it needs to. UnlessFilter.hasGlobalMatch(FilterConfig)returnstrue, when a match occurred, this function is not called with the remaining game objects on the map square and a reset is issued.- Specified by:
matchin interfaceFilter<NamedFilter,NamedFilterConfig>- Parameters:
config- the filter configuration to usegameObject- the game object being analyzed on the map- Returns:
- whether it matches the criteria; this value is ignored if
hasGlobalMatch()returnstrue
-
reset
public boolean reset(@NotNull @NotNull NamedFilterConfig config)Description copied from interface:FilterThis tells the filter we have finished with current map square and, perhaps, we are jumping on next one. IfFilter.hasGlobalMatch(FilterConfig)returnstrue, the returning value is used to know if we had a match.- Specified by:
resetin interfaceFilter<NamedFilter,NamedFilterConfig>- Parameters:
config- the filter configuration to use- Returns:
- whether we had a global match on map square
-
hasGlobalMatch
public boolean hasGlobalMatch(@NotNull @NotNull NamedFilterConfig config)Description copied from interface:FilterTells if all the game objects on a square are to be analyzed before a match result. If all game objects must be analyzed to decide the result of a match, the return value ofFilter.match(FilterConfig, GameObject)is ignored and the returning value ofFilter.reset(FilterConfig)is used as replacement. This should mainly used by complex analyze filters.- Specified by:
hasGlobalMatchin interfaceFilter<NamedFilter,NamedFilterConfig>- Parameters:
config- the filter configuration to use- Returns:
- whether a match can be decided only when all game objects on a map square are analyzed
-
createConfig
@NotNull public @NotNull NamedFilterConfig createConfig()
Description copied from interface:FilterCreates a newFilterConfiginstance for this filter.- Specified by:
createConfigin interfaceFilter<NamedFilter,NamedFilterConfig>- Returns:
- the new filter config instance
-
addFilter
public void addFilter(@NotNull @NotNull java.lang.String name, @NotNull @NotNull Filter<?,?> filter)Adds a sub-Filter.- Parameters:
name- the name of the sub-filterfilter- the sub-filter
-
removeFilter
public void removeFilter(@NotNull @NotNull java.lang.String name)Removes a sub-filter.- Parameters:
name- the name of the sub-filter
-
addFilterListener
public void addFilterListener(@NotNull @NotNull NamedFilterListener listener)Adds aNamedFilterListenerto be notified about changes.- Parameters:
listener- the listener
-
removeFilterListener
public void removeFilterListener(@NotNull @NotNull NamedFilterListener listener)Removes aNamedFilterListenerto be notified about changes.- Parameters:
listener- the listener
-
canShow
public boolean canShow(@NotNull @NotNull GameObject<?,?,?> gameObject, @NotNull @NotNull NamedFilterConfig filterOutConfig)Returns whether this filter matches aGameObject.- Parameters:
gameObject- the game objectfilterOutConfig- the filter config to use- Returns:
- whether this filter matches the game object
-
-