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

edu.stanford.protege.webprotege.criteria.NumericPredicate Maven / Gradle / Ivy

There is a newer version: 0.9.2
Show newest version
package edu.stanford.protege.webprotege.criteria;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import javax.annotation.Nonnull;

/**
 * Matthew Horridge
 * Stanford Center for Biomedical Informatics Research
 * 10 Jun 2018
 */
public enum NumericPredicate {

    GREATER_THAN(">") {
        @Override
        public  R visit(@Nonnull NumericPredicateVisitor visitor, A arg) {
            return visitor.isGreaterThan(arg);
        }

        @Override
        public boolean eval(double left, double right) {
            return left > right;
        }

        @Override
        public boolean eval(int left, int right) {
            return left > right;
        }
    },

    GREATER_THAN_OR_EQUAL_TO(">=") {
        @Override
        public  R visit(@Nonnull NumericPredicateVisitor visitor, A arg) {
            return visitor.isGreaterThanOrEqualTo(arg);
        }

        @Override
        public boolean eval(double left, double right) {
            return left >= right;
        }

        @Override
        public boolean eval(int left, int right) {
            return left >= right;
        }
    },

    LESS_THAN("<") {
        @Override
        public  R visit(@Nonnull NumericPredicateVisitor visitor, A arg) {
            return visitor.isLessThan(arg);
        }

        @Override
        public boolean eval(double left, double right) {
            return left < right;
        }

        @Override
        public boolean eval(int left, int right) {
            return left < right;
        }
    },

    LESS_THAN_OR_EQUAL_TO("<=") {
        @Override
        public  R visit(@Nonnull NumericPredicateVisitor visitor, A arg) {
            return visitor.isLessThanOrEqualTo(arg);
        }

        @Override
        public boolean eval(double left, double right) {
            return left <= right;
        }

        @Override
        public boolean eval(int left, int right) {
            return left <= right;
        }
    },

    IS_EQUAL_TO("=") {
        @Override
        public  R visit(@Nonnull NumericPredicateVisitor visitor, A arg) {
            return visitor.isEqualTo(arg);
        }

        @Override
        public boolean eval(double left, double right) {
            return left == right;
        }

        @Override
        public boolean eval(int left, int right) {
            return left == right;
        }
    };

    private String symbol;

    @JsonCreator
    NumericPredicate(String symbol) {
        this.symbol = symbol;
    }

    NumericPredicate() {
    }

    @JsonValue
    public String getSymbol() {
        return symbol;
    }

    public abstract  R visit(@Nonnull NumericPredicateVisitor visitor, A arg);

    public abstract boolean eval(double left, double right);

    public abstract boolean eval(int left, int right);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy