Class BaseCheck<T>

    • Constructor Summary

      Constructors 
      Constructor Description
      BaseCheck​(org.openstreetmap.atlas.utilities.configuration.Configuration configuration)
      Default constructor
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected boolean acceptPier()
      If the check wants to accept piers as part of it's evaluation then it will need to override this function and return true.
      java.util.Optional<CheckFlag> check​(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object)
      The check for the atlas object
      java.util.function.Predicate<org.openstreetmap.atlas.geography.atlas.items.AtlasObject> checkObjectFilter()  
      void clear()
      Clears all flagged feature identifiers for this check.
      protected void clearFlaggedIdentifiers()  
      protected java.lang.String configurationKey​(java.lang.Class<?> type, java.lang.String key)  
      protected java.lang.String configurationKey​(java.lang.String key)
      Configuration Keys in the Integrity Framework are based on the check simple classname.
      protected <U> U configurationValue​(org.openstreetmap.atlas.utilities.configuration.Configuration configuration, java.lang.String key, U defaultValue)  
      protected <U,​V>
      V
      configurationValue​(org.openstreetmap.atlas.utilities.configuration.Configuration configuration, java.lang.String key, U defaultValue, java.util.function.Function<U,​V> transform)  
      protected CheckFlag createFlag​(java.util.Set<? extends org.openstreetmap.atlas.geography.atlas.items.AtlasObject> objects, java.lang.String instruction)  
      protected CheckFlag createFlag​(java.util.Set<? extends org.openstreetmap.atlas.geography.atlas.items.AtlasObject> objects, java.lang.String instruction, java.util.List<org.openstreetmap.atlas.geography.Location> points)  
      protected CheckFlag createFlag​(java.util.Set<? extends org.openstreetmap.atlas.geography.atlas.items.AtlasObject> objects, java.util.List<java.lang.String> instructions)  
      protected CheckFlag createFlag​(java.util.Set<? extends org.openstreetmap.atlas.geography.atlas.items.AtlasObject> objects, java.util.List<java.lang.String> instructions, java.util.List<org.openstreetmap.atlas.geography.Location> points)  
      protected CheckFlag createFlag​(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object, java.lang.String instruction)  
      protected CheckFlag createFlag​(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object, java.lang.String instruction, java.util.List<org.openstreetmap.atlas.geography.Location> points)  
      protected CheckFlag createFlag​(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object, java.util.List<java.lang.String> instructions)  
      protected CheckFlag createFlag​(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object, java.util.List<java.lang.String> instructions, java.util.List<org.openstreetmap.atlas.geography.Location> points)  
      protected abstract java.util.Optional<CheckFlag> flag​(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object)  
      java.lang.Iterable<CheckFlag> flags​(org.openstreetmap.atlas.geography.atlas.Atlas atlas)
      Compute and return all the CheckFlags from this check, given AtlasEntitys and Relations.
      Challenge getChallenge()
      Gets a challenge object for the specific check
      java.lang.String getCheckName()
      Gets the name of this check
      org.openstreetmap.atlas.utilities.filters.AtlasEntityPolygonsFilter getCheckPolygonFilter()  
      java.util.List<java.lang.String> getCountries()
      Gets the permitlisted countries for this check.
      java.util.List<java.lang.String> getDenylistCountries()  
      protected java.util.List<java.lang.String> getFallbackInstructions()
      Method to implement for inheriting checks to return the default set of instruction formats that will be the last resort in getLocalizedInstruction(int, Object[])
      protected java.util.Set<T> getFlaggedIdentifiers()  
      org.openstreetmap.atlas.utilities.filters.AtlasEntityPolygonsFilter getGlobalPolygonFilter()  
      java.util.Locale getLocale()  
      java.lang.String getLocalizedInstruction​(int index, java.lang.Object... objects)
      Uses the default of configured locale to grab the localized instruction format from the configuration.
      protected java.lang.String getTaskIdentifier​(java.util.Set<? extends org.openstreetmap.atlas.geography.atlas.items.AtlasObject> objects)
      The task identifier is ordered to maintain identifier uniqueness.
      protected java.lang.String getTaskIdentifier​(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object)  
      protected java.lang.String getUniqueObjectIdentifier​(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object)
      Similar to getUniqueOSMIdentifier(AtlasObject) except instead of using the OSM identifier we use the Atlas identifier
      protected java.lang.String getUniqueOSMIdentifier​(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object)
      Generates a unique identifier given an AtlasObject.
      protected boolean isFlagged​(T identifier)  
      void logStatus()
      Helper for debugging.
      protected void markAsFlagged​(T identifier)  
      boolean validCheckForCountry​(java.lang.String country)
      The country check will first check the country permitlist and if the country is contained in the permitlist it is allowed, after that the country is checked it against denylist and if contained in the denylist will not be allowed.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PARAMETER_ACCEPT_PIERS

        public static final java.lang.String PARAMETER_ACCEPT_PIERS
        See Also:
        Constant Field Values
      • PARAMETER_DENYLIST_COUNTRIES

        public static final java.lang.String PARAMETER_DENYLIST_COUNTRIES
        See Also:
        Constant Field Values
      • PARAMETER_CHALLENGE

        public static final java.lang.String PARAMETER_CHALLENGE
        See Also:
        Constant Field Values
      • PARAMETER_PERMITLIST_COUNTRIES

        public static final java.lang.String PARAMETER_PERMITLIST_COUNTRIES
        See Also:
        Constant Field Values
      • PARAMETER_PERMITLIST_TAGS

        public static final java.lang.String PARAMETER_PERMITLIST_TAGS
        See Also:
        Constant Field Values
    • Constructor Detail

      • BaseCheck

        public BaseCheck​(org.openstreetmap.atlas.utilities.configuration.Configuration configuration)
        Default constructor
        Parameters:
        configuration - Configuration required to construct any Check
    • Method Detail

      • check

        public java.util.Optional<CheckFlag> check​(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object)
        Description copied from interface: Check
        The check for the atlas object
        Specified by:
        check in interface Check
        Parameters:
        object - The AtlasObject to check
        Returns:
        an Optional CheckFlag, Optional.EMPTY if check did not reveal any errors
      • checkObjectFilter

        public final java.util.function.Predicate<org.openstreetmap.atlas.geography.atlas.items.AtlasObject> checkObjectFilter()
      • clear

        public void clear()
        Clears all flagged feature identifiers for this check. Primary purpose is to reset flagged features during testing. Be careful in using this for actual production checks.
        Specified by:
        clear in interface Check
      • flags

        public java.lang.Iterable<CheckFlag> flags​(org.openstreetmap.atlas.geography.atlas.Atlas atlas)
        Description copied from interface: Check
        Compute and return all the CheckFlags from this check, given AtlasEntitys and Relations. ComplexEntitys can be added as well, using the appropriate Finder.
        Specified by:
        flags in interface Check
        Parameters:
        atlas - the Atlas to check
        Returns:
        all the CheckFlags from this check
      • getChallenge

        public Challenge getChallenge()
        Description copied from interface: Check
        Gets a challenge object for the specific check
        Specified by:
        getChallenge in interface Check
        Returns:
        a Challenge
      • getCheckName

        public final java.lang.String getCheckName()
        Description copied from interface: Check
        Gets the name of this check
        Specified by:
        getCheckName in interface Check
        Returns:
        a String name
      • getCheckPolygonFilter

        public org.openstreetmap.atlas.utilities.filters.AtlasEntityPolygonsFilter getCheckPolygonFilter()
      • getCountries

        public java.util.List<java.lang.String> getCountries()
        Gets the permitlisted countries for this check. If an empty list is returned it safe to assume this check applies to all countries.
        Returns:
        a list of country ISO3 codes
      • getDenylistCountries

        public java.util.List<java.lang.String> getDenylistCountries()
      • getGlobalPolygonFilter

        public org.openstreetmap.atlas.utilities.filters.AtlasEntityPolygonsFilter getGlobalPolygonFilter()
      • getLocale

        public java.util.Locale getLocale()
      • getLocalizedInstruction

        public final java.lang.String getLocalizedInstruction​(int index,
                                                              java.lang.Object... objects)
        Uses the default of configured locale to grab the localized instruction format from the configuration. If the localized version does not contain the given index instruction then it will be grabbed from the FallBack Instructions. A IndexOutOfBoundsException will be thrown if the instruction index is out of the Fallback Instructions. The instruction format will then be formatted using the provided objects and returned.
        Parameters:
        index - The index of the desired instruction format.
        objects - The objects to be used in constructing the instruction
        Returns:
        String of the localized instruction, or the DEFAULT_LOCALE language instruction, or the fallback instruction. In that order if the previous isn't present in the configuration.
      • logStatus

        public void logStatus()
        Description copied from interface: Check
        Helper for debugging. Implement in check to log info after check is run.
        Specified by:
        logStatus in interface Check
      • validCheckForCountry

        public boolean validCheckForCountry​(java.lang.String country)
        The country check will first check the country permitlist and if the country is contained in the permitlist it is allowed, after that the country is checked it against denylist and if contained in the denylist will not be allowed.
        Specified by:
        validCheckForCountry in interface Check
        Parameters:
        country - country ISO3 code to check
        Returns:
        true if valid check for country, otherwise false
      • acceptPier

        protected boolean acceptPier()
        If the check wants to accept piers as part of it's evaluation then it will need to override this function and return true. By default piers are skipped.
        Returns:
        true if we want to check pier edges, false if we want to skip them
      • clearFlaggedIdentifiers

        protected void clearFlaggedIdentifiers()
      • configurationKey

        protected final java.lang.String configurationKey​(java.lang.Class<?> type,
                                                          java.lang.String key)
      • configurationKey

        protected final java.lang.String configurationKey​(java.lang.String key)
        Configuration Keys in the Integrity Framework are based on the check simple classname.
        Parameters:
        key - key part for a specific configuration item defined for this class
        Returns:
        complete key for lookup
      • configurationValue

        protected <U> U configurationValue​(org.openstreetmap.atlas.utilities.configuration.Configuration configuration,
                                           java.lang.String key,
                                           U defaultValue)
      • configurationValue

        protected <U,​V> V configurationValue​(org.openstreetmap.atlas.utilities.configuration.Configuration configuration,
                                                   java.lang.String key,
                                                   U defaultValue,
                                                   java.util.function.Function<U,​V> transform)
      • createFlag

        protected CheckFlag createFlag​(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object,
                                       java.lang.String instruction)
      • createFlag

        protected CheckFlag createFlag​(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object,
                                       java.lang.String instruction,
                                       java.util.List<org.openstreetmap.atlas.geography.Location> points)
      • createFlag

        protected CheckFlag createFlag​(java.util.Set<? extends org.openstreetmap.atlas.geography.atlas.items.AtlasObject> objects,
                                       java.lang.String instruction)
      • createFlag

        protected CheckFlag createFlag​(java.util.Set<? extends org.openstreetmap.atlas.geography.atlas.items.AtlasObject> objects,
                                       java.lang.String instruction,
                                       java.util.List<org.openstreetmap.atlas.geography.Location> points)
      • createFlag

        protected CheckFlag createFlag​(java.util.Set<? extends org.openstreetmap.atlas.geography.atlas.items.AtlasObject> objects,
                                       java.util.List<java.lang.String> instructions,
                                       java.util.List<org.openstreetmap.atlas.geography.Location> points)
      • createFlag

        protected CheckFlag createFlag​(java.util.Set<? extends org.openstreetmap.atlas.geography.atlas.items.AtlasObject> objects,
                                       java.util.List<java.lang.String> instructions)
      • createFlag

        protected CheckFlag createFlag​(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object,
                                       java.util.List<java.lang.String> instructions)
      • createFlag

        protected CheckFlag createFlag​(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object,
                                       java.util.List<java.lang.String> instructions,
                                       java.util.List<org.openstreetmap.atlas.geography.Location> points)
      • flag

        protected abstract java.util.Optional<CheckFlag> flag​(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object)
      • getFallbackInstructions

        protected java.util.List<java.lang.String> getFallbackInstructions()
        Method to implement for inheriting checks to return the default set of instruction formats that will be the last resort in getLocalizedInstruction(int, Object[])
        Returns:
        The set of instructions to fall back to if configuration results in none.
      • getFlaggedIdentifiers

        protected java.util.Set<T> getFlaggedIdentifiers()
      • getTaskIdentifier

        protected java.lang.String getTaskIdentifier​(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object)
      • getTaskIdentifier

        protected java.lang.String getTaskIdentifier​(java.util.Set<? extends org.openstreetmap.atlas.geography.atlas.items.AtlasObject> objects)
        The task identifier is ordered to maintain identifier uniqueness.
        Parameters:
        objects - set of AtlasObjects comprising this task
        Returns:
        a unique string identifier for this task, made from the sorted object identifiers
      • getUniqueOSMIdentifier

        protected java.lang.String getUniqueOSMIdentifier​(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object)
        Generates a unique identifier given an AtlasObject. OSM/Atlas objects with different types can share the identifier (way 12345 - node 12345). This method makes sure we generate a truly unique identifier, based on the OSM identifier, among different types for an AtlasObject. If the AtlasObject is an instanceof AtlasEntity then it will simply use the type for the first part of the identifier, otherwise it will use the simple class name.
        Parameters:
        object - AtlasObject to generate unique identifier for
        Returns:
        unique object identifier among different types
      • getUniqueObjectIdentifier

        protected java.lang.String getUniqueObjectIdentifier​(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object)
        Similar to getUniqueOSMIdentifier(AtlasObject) except instead of using the OSM identifier we use the Atlas identifier
        Parameters:
        object - AtlasObject to generate unique identifier for
        Returns:
        unique object identifier among different types
      • isFlagged

        protected final boolean isFlagged​(T identifier)
      • markAsFlagged

        protected final void markAsFlagged​(T identifier)