Class AutoFilterRule


  • public class AutoFilterRule
    extends java.lang.Object
    An auto filter rule determines how auto filter can be built from visible map data. Several rules can be registered, but only one rule is active at the same time. Rules are identified by the OSM key on which they apply. The dynamic values discovering operates only below a certain zoom level, for performance reasons.
    Since:
    12400
    • Constructor Detail

      • AutoFilterRule

        public AutoFilterRule​(java.lang.String key,
                              int minZoomLevel)
        Constructs a new AutoFilterRule.
        Parameters:
        key - the OSM key on which the rule applies
        minZoomLevel - the minimum zoom level at which the rule applies
    • Method Detail

      • getKey

        public java.lang.String getKey()
        Returns the OSM key on which the rule applies.
        Returns:
        the OSM key on which the rule applies
      • getMinZoomLevel

        public int getMinZoomLevel()
        Returns the minimum zoom level at which the rule applies.
        Returns:
        the minimum zoom level at which the rule applies
      • formatValue

        public java.lang.String formatValue​(int value)
        Formats the numeric value
        Parameters:
        value - the numeric value to format
        Returns:
        the formatted value
      • setValueFormatter

        public AutoFilterRule setValueFormatter​(java.util.function.IntFunction<java.lang.String> valueFormatter)
        Sets a OSM value formatter that defines the associated button label.
        Parameters:
        valueFormatter - OSM value formatter. Cannot be null
        Returns:
        this
        Throws:
        java.lang.NullPointerException - if valueFormatter is null
      • setDefaultValueSupplier

        public AutoFilterRule setDefaultValueSupplier​(java.util.function.Function<OsmPrimitive,​java.util.stream.IntStream> defaultValueSupplier)
        Sets the function which yields default values for the given OSM primitive. This function is invoked if the primitive does not have this key.
        Parameters:
        defaultValueSupplier - the function which yields default values for the given OSM primitive
        Returns:
        this
        Throws:
        java.lang.NullPointerException - if defaultValueSupplier is null
      • setValueExtractor

        public AutoFilterRule setValueExtractor​(java.util.function.ToIntFunction<java.lang.String> valueExtractor)
        Sets the function which extracts a numeric value from an OSM value
        Parameters:
        valueExtractor - the function which extracts a numeric value from an OSM value
        Returns:
        this
        Throws:
        java.lang.NullPointerException - if valueExtractor is null
      • getTagValuesForPrimitive

        public java.util.stream.IntStream getTagValuesForPrimitive​(OsmPrimitive osm)
        Returns the numeric values for the given OSM primitive
        Parameters:
        osm - the primitive
        Returns:
        a stream of numeric values
      • defaultRules

        public static AutoFilterRule[] defaultRules()
        Returns the default list of auto filter rules. Plugins can extend the list by registering additional rules.
        Returns:
        the default list of auto filter rules
      • getDefaultRule

        static java.util.Optional<AutoFilterRulegetDefaultRule​(java.lang.String key)
        Returns the default auto filter rule for the given key
        Parameters:
        key - the OSM key
        Returns:
        default auto filter rule for the given key
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object