@Test(expected = IllegalArgumentException.class) public void evaluationStringIsNotMissing() { Object value = "43"; KiePMMLSimplePredicate kiePMMLSimplePredicate = getKiePMMLSimplePredicate(OPERATOR.IS_NOT_MISSING, value); kiePMMLSimplePredicate.evaluation(value); }
protected boolean evaluation(Object inputValue) { switch (operator) { case EQUAL: return value.equals(inputValue); case NOT_EQUAL: return !value.equals(inputValue); case LESS_THAN: if (inputValue instanceof Number && value instanceof Number) { return ((Number) inputValue).doubleValue() < ((Number) value).doubleValue(); } else { return false; } case LESS_OR_EQUAL: if (inputValue instanceof Number && value instanceof Number) { return ((Number) inputValue).doubleValue() <= ((Number) value).doubleValue(); } else { return false; } case GREATER_THAN: if (inputValue instanceof Number && value instanceof Number) { return ((Number) inputValue).doubleValue() > ((Number) value).doubleValue(); } else { return false; } case GREATER_OR_EQUAL: if (inputValue instanceof Number && value instanceof Number) { return ((Number) inputValue).doubleValue() >= ((Number) value).doubleValue(); } else { return false; } case IS_MISSING: case IS_NOT_MISSING: throw new IllegalArgumentException(SURROGATE + " not supported, yet"); default: throw new KiePMMLException("Unknown OPERATOR " + operator); } }
KiePMMLSimplePredicate extends KiePMMLPredicate { protected boolean evaluation(Object inputValue) { switch (operator) { case EQUAL: return value.equals(inputValue); case NOT_EQUAL: return !value.equals(inputValue); case LESS_THAN: if (inputValue instanceof Number && value instanceof Number) { return ((Number) inputValue).doubleValue() < ((Number) value).doubleValue(); } else { return false; } case LESS_OR_EQUAL: if (inputValue instanceof Number && value instanceof Number) { return ((Number) inputValue).doubleValue() <= ((Number) value).doubleValue(); } else { return false; } case GREATER_THAN: if (inputValue instanceof Number && value instanceof Number) { return ((Number) inputValue).doubleValue() > ((Number) value).doubleValue(); } else { return false; } case GREATER_OR_EQUAL: if (inputValue instanceof Number && value instanceof Number) { return ((Number) inputValue).doubleValue() >= ((Number) value).doubleValue(); } else { return false; } case IS_MISSING: case IS_NOT_MISSING: throw new IllegalArgumentException(SURROGATE + " not supported, yet"); default: throw new KiePMMLException("Unknown OPERATOR " + operator); } } }
KiePMMLSimplePredicate extends KiePMMLPredicate { protected boolean evaluation(Object inputValue) { switch (operator) { case EQUAL: return value.equals(inputValue); case NOT_EQUAL: return !value.equals(inputValue); case LESS_THAN: if (inputValue instanceof Number && value instanceof Number) { return ((Number) inputValue).doubleValue() < ((Number) value).doubleValue(); } else { return false; } case LESS_OR_EQUAL: if (inputValue instanceof Number && value instanceof Number) { return ((Number) inputValue).doubleValue() <= ((Number) value).doubleValue(); } else { return false; } case GREATER_THAN: if (inputValue instanceof Number && value instanceof Number) { return ((Number) inputValue).doubleValue() > ((Number) value).doubleValue(); } else { return false; } case GREATER_OR_EQUAL: if (inputValue instanceof Number && value instanceof Number) { return ((Number) inputValue).doubleValue() >= ((Number) value).doubleValue(); } else { return false; } case IS_MISSING: case IS_NOT_MISSING: throw new IllegalArgumentException(SURROGATE + " not supported, yet"); default: throw new KiePMMLException("Unknown OPERATOR " + operator); } } protected  KiePMMLSimplePredicate(final String name, final List<KiePMMLExtension> extensions, final OPERATOR operator); }
KiePMMLSimplePredicate extends KiePMMLPredicate { protected boolean evaluation(Object inputValue) { switch (operator) { case EQUAL: return value.equals(inputValue); case NOT_EQUAL: return !value.equals(inputValue); case LESS_THAN: if (inputValue instanceof Number && value instanceof Number) { return ((Number) inputValue).doubleValue() < ((Number) value).doubleValue(); } else { return false; } case LESS_OR_EQUAL: if (inputValue instanceof Number && value instanceof Number) { return ((Number) inputValue).doubleValue() <= ((Number) value).doubleValue(); } else { return false; } case GREATER_THAN: if (inputValue instanceof Number && value instanceof Number) { return ((Number) inputValue).doubleValue() > ((Number) value).doubleValue(); } else { return false; } case GREATER_OR_EQUAL: if (inputValue instanceof Number && value instanceof Number) { return ((Number) inputValue).doubleValue() >= ((Number) value).doubleValue(); } else { return false; } case IS_MISSING: case IS_NOT_MISSING: throw new IllegalArgumentException(SURROGATE + " not supported, yet"); default: throw new KiePMMLException("Unknown OPERATOR " + operator); } } protected  KiePMMLSimplePredicate(final String name, final List<KiePMMLExtension> extensions, final OPERATOR operator); static Builder builder(String name, List<KiePMMLExtension> extensions, OPERATOR operator); @Override boolean evaluate(Map<String, Object> values); @Override String getName(); OPERATOR getOperator(); Object getValue(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
KiePMMLSimplePredicate extends KiePMMLPredicate { protected boolean evaluation(Object inputValue) { switch (operator) { case EQUAL: return value.equals(inputValue); case NOT_EQUAL: return !value.equals(inputValue); case LESS_THAN: if (inputValue instanceof Number && value instanceof Number) { return ((Number) inputValue).doubleValue() < ((Number) value).doubleValue(); } else { return false; } case LESS_OR_EQUAL: if (inputValue instanceof Number && value instanceof Number) { return ((Number) inputValue).doubleValue() <= ((Number) value).doubleValue(); } else { return false; } case GREATER_THAN: if (inputValue instanceof Number && value instanceof Number) { return ((Number) inputValue).doubleValue() > ((Number) value).doubleValue(); } else { return false; } case GREATER_OR_EQUAL: if (inputValue instanceof Number && value instanceof Number) { return ((Number) inputValue).doubleValue() >= ((Number) value).doubleValue(); } else { return false; } case IS_MISSING: case IS_NOT_MISSING: throw new IllegalArgumentException(SURROGATE + " not supported, yet"); default: throw new KiePMMLException("Unknown OPERATOR " + operator); } } protected  KiePMMLSimplePredicate(final String name, final List<KiePMMLExtension> extensions, final OPERATOR operator); static Builder builder(String name, List<KiePMMLExtension> extensions, OPERATOR operator); @Override boolean evaluate(Map<String, Object> values); @Override String getName(); OPERATOR getOperator(); Object getValue(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }