private JsonElement parsePrimitiveType ( JsonSchema schema , JsonElement value ) throws DataConversionException { if ( ( schema . isType ( NULL ) || schema . isNullable ( ) ) && value . isJsonNull ( ) ) { return JsonNull . INSTANCE ; } if ( ( schema . isType ( NULL ) && ! value . isJsonNull ( ) ) || ( ! schema . isType ( NULL ) && value . isJsonNull ( ) ) ) { throw new DataConversionException ( "Type mismatch for " + value . toString ( ) + " of type " + schema . getDataTypes ( ) . toString ( ) ) ; } if ( schema . isType ( FIXED ) ) { int expectedSize = schema . getSizeOfFixedData ( ) ; if ( value . getAsString ( ) . length ( ) == expectedSize ) { return value ; } else { throw new DataConversionException ( "Fixed type value is not same as defined value expected fieldsCount: " + expectedSize ) ; } } else { return value ; } }
Parses primitive types