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

mml-commons.8.44.0.Final.source-code.KiePMMLSimplePredicateEvaluateMethodTemplate.tmpl Maven / Gradle / Ivy

There is a newer version: 10.0.0
Show newest version
package org.kie.pmml.commons.model.predicates;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;


public class KiePMMLSimplePredicateEvaluateMethodTemplate {

    private boolean evaluateEQUAL(Map stringObjectMap) {
        Object value = null;
        if (stringObjectMap.containsKey("avalue")) {
                return value.equals(stringObjectMap.get("avalue"));
        } else {
                return false;
        }
    }

    private boolean evaluateNOT_EQUAL(Map stringObjectMap) {
        Object value = null;
        if (stringObjectMap.containsKey("avalue")) {
                return !value.equals(stringObjectMap.get("avalue"));
        } else {
                return false;
        }
    }

    private boolean evaluateLESS_THAN(Map stringObjectMap) {
        Object inputValue = null;
        Object value = null;
        if (stringObjectMap.containsKey("avalue")) {
             inputValue = stringObjectMap.get("avalue");
        } else {
            return false;
        }
        if (inputValue instanceof Number && value instanceof Number) {
            return ((Number) inputValue).doubleValue() < ((Number) value).doubleValue();
        } else {
            return false;
        }
    }

    private boolean evaluateLESS_OR_EQUAL(Map stringObjectMap) {
        Object inputValue = null;
         Object value = null;
        if (stringObjectMap.containsKey("avalue")) {
            inputValue = stringObjectMap.get("avalue");
        } else {
            return false;
        }
        if (inputValue instanceof Number && value instanceof Number) {
            return ((Number) inputValue).doubleValue() <= ((Number) value).doubleValue();
        } else {
            return false;
        }
    }

    private boolean evaluateGREATER_THAN(Map stringObjectMap) {
        Object inputValue = null;
        Object value = null;
        if (stringObjectMap.containsKey("avalue")) {
            inputValue = stringObjectMap.get("avalue");
        } else {
            return false;
        }
        if (inputValue instanceof Number && value instanceof Number) {
            return ((Number) inputValue).doubleValue() > ((Number) value).doubleValue();
        } else {
            return false;
        }
    }

    private boolean evaluateGREATER_OR_EQUAL(Map stringObjectMap) {
        Object inputValue = null;
        Object value = null;
        if (stringObjectMap.containsKey("avalue")) {
            inputValue = stringObjectMap.get("avalue");
        } else {
            return false;
        }
        if (inputValue instanceof Number && value instanceof Number) {
            return ((Number) inputValue).doubleValue() >= ((Number) value).doubleValue();
        } else {
            return false;
        }
    }

    private boolean evaluateIS_MISSING(Map stringObjectMap) {
         return !stringObjectMap.containsKey("avalue");
    }

    private boolean evaluateIS_NOT_MISSING(Map stringObjectMap) {
         return stringObjectMap.containsKey("avalue");
    }

     private boolean evaluateFALSE(Map stringObjectMap) {
         return false;
     }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy