static private DataType getDataType(Object value){ if(value != null){ try { return TypeUtil.getDataType(value); } catch(EvaluationException ee){ // Ignored } } return null; }
@Override public DataType getDataType(){ DataType dataType = outputField.getDataType(); if(dataType == null){ if(value instanceof Collection){ Collection<?> values = (Collection<?>)value; dataType = TypeUtil.getDataType(values); } else { dataType = TypeUtil.getDataType(value); } } return dataType; }
static public FieldValue create(Object value){ if(value == null){ return FieldValues.MISSING_VALUE; } DataType dataType; if(value instanceof Collection){ Collection<?> values = (Collection<?>)value; dataType = TypeUtil.getDataType(values); } else { dataType = TypeUtil.getDataType(value); } OpType opType = TypeUtil.getOpType(dataType); return FieldValue.create(dataType, opType, value); }
static public DataType getDataType(Collection<?> values){ DataType result = null; for(Object value : values){ if(value == null){ continue; } DataType dataType = getDataType(value); if(result == null){ result = dataType; } else { if(!(result).equals(dataType)){ throw new TypeCheckException(result, value); } } } if(result == null){ result = DataType.STRING; } return result; }
static public TargetValue getTargetValue(Target target, Object value){ DataType dataType = TypeUtil.getDataType(value); List<TargetValue> targetValues = target.getTargetValues(); for(TargetValue targetValue : targetValues){ String stringValue = targetValue.getValue(); if(stringValue == null){ throw new MissingAttributeException(targetValue, PMMLAttributes.TARGETVALUE_VALUE); } // End if if((value).equals(TypeUtil.parse(dataType, stringValue))){ return targetValue; } } return null; }
@Override public boolean doEquivalent(Object expected, Object actual){ double precision = getPrecision(); double zeroThreshold = getZeroThreshold(); if(actual instanceof Computable){ actual = EvaluatorUtil.decode(actual); } expected = TypeUtil.parseOrCast(TypeUtil.getDataType(actual), expected); return VerificationUtil.acceptable(expected, actual, precision, zeroThreshold); }
private void verify(Object expected, Object actual, double precision, double zeroThreshold){ if(expected == null){ return; } // End if if(!(actual instanceof Collection)){ DataType dataType = TypeUtil.getDataType(actual); expected = TypeUtil.parseOrCast(dataType, expected); } boolean acceptable = VerificationUtil.acceptable(expected, actual, precision, zeroThreshold); if(!acceptable){ throw new EvaluationException("Values " + PMMLException.formatValue(expected) + " and " + PMMLException.formatValue(actual) + " do not match"); } }
@Override public boolean doEquivalent(Object expected, Object actual){ double precision = getPrecision(); double zeroThreshold = getZeroThreshold(); if(actual instanceof Computable){ actual = EvaluatorUtil.decode(actual); } expected = TypeUtil.parseOrCast(TypeUtil.getDataType(actual), expected); return VerificationUtil.acceptable(expected, actual, precision, zeroThreshold); }
TypeUtil.getDataType(FieldValueUtil.getValue(groupValue));
expected = TypeUtil.parseOrCast(TypeUtil.getDataType(actual), expected);
expected = TypeUtil.parseOrCast(TypeUtil.getDataType(actual), expected);