private AttributeType getEnrichedType ( AttributeType guess , Object value ) { if ( guess == null || value == null ) { return guess ; } if ( guess . equals ( STRING ) ) { String stringValue = value . toString ( ) ; if ( stringValue . length ( ) > MAX_STRING_LENGTH ) { return TEXT ; } if ( canValueBeUsedAsDate ( value ) ) { return DATE ; } } else if ( guess . equals ( DECIMAL ) ) { if ( value instanceof Integer ) { return INT ; } else if ( value instanceof Long ) { Long longValue = ( Long ) value ; return longValue > Integer . MIN_VALUE && longValue < Integer . MAX_VALUE ? INT : LONG ; } else if ( value instanceof Double ) { Double doubleValue = ( Double ) value ; if ( doubleValue != Math . rint ( doubleValue ) ) { return DECIMAL ; } if ( doubleValue > Integer . MIN_VALUE && doubleValue < Integer . MAX_VALUE ) { return INT ; } if ( doubleValue > Long . MIN_VALUE && doubleValue < Long . MAX_VALUE ) { return LONG ; } } } return guess ; }
Returns an enriched AttributeType for when the value meets certain criteria i . e . if a string value is longer dan 255 characters the type should be TEXT