All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.graphhopper.reader.osm.conditional.ConditionalValueParser Maven / Gradle / Ivy

Go to download

GraphHopper is a fast and memory efficient Java road routing engine working seamlessly with OpenStreetMap data.

There is a newer version: 10.0
Show newest version
package com.graphhopper.reader.osm.conditional;

import java.text.ParseException;

/**
 * This interface defines how to parse a OSM value from conditional restrictions.
 */
public interface ConditionalValueParser {

    /**
     * This method checks if the condition is satisfied for this parser.
     */
    ConditionState checkCondition(String conditionalValue) throws ParseException;

    enum ConditionState {
        TRUE(true, true),
        FALSE(true, false),
        INVALID(false, false);

        boolean valid;
        boolean checkPassed;

        ConditionState(boolean valid, boolean checkPassed) {
            this.valid = valid;
            this.checkPassed = checkPassed;
        }

        public boolean isValid() {
            return valid;
        }

        public boolean isCheckPassed() {
            if (!isValid())
                throw new IllegalStateException("Cannot call this method for invalid state");

            return checkPassed;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy