public static Object parsePrimitiveValue(String value,PrimitiveType primitiveType) throws ODataException {
switch (primitiveType) {
case BOOLEAN:
    return Boolean.valueOf(value);
case BYTE:
  try {
    final Integer v=Integer.valueOf(value);
    if (v < 0 || v > PARSE_INDEX) {
      throwParseException(value,primitiveType,null);
    }
    return v.byteValue();
  }
 catch (  NumberFormatException e) {
    throwParseException(value,primitiveType,e);
  }
break;
case DATE:
try {
return LocalDate.parse(value);
}
 catch (IllegalArgumentException e) {
throwParseException(value,primitiveType,e);
}
break;
case DATE_TIME_OFFSET:
try {
return ZonedDateTime.parse(value);
}
 catch (IllegalArgumentException e) {
throwParseException(value,primitiveType,e);
}
break;
case DURATION:
try {
return Period.parse(value);
}
 catch (IllegalArgumentException e) {
throwParseException(value,primitiveType,e);
}
break;
case TIME_OF_DAY:
try {
return LocalTime.parse(value);
}
 catch (IllegalArgumentException e) {
throwParseException(value,primitiveType,e);
}
break;
case DECIMAL:
try {
return new BigDecimal(value);
}
 catch (NumberFormatException e) {
throwParseException(value,primitiveType,e);
}
break;
case DOUBLE:
try {
return Double.parseDouble(value);
}
 catch (NumberFormatException e) {
throwParseException(value,primitiveType,e);
}
break;
case SINGLE:
try {
return Float.parseFloat(value);
}
 catch (NumberFormatException e) {
throwParseException(value,primitiveType,e);
}
break;
case GUID:
try {
return UUID.fromString(value);
}
 catch (IllegalArgumentException e) {
throwParseException(value,primitiveType,e);
}
break;
case INT16:
try {
return Short.valueOf(value);
}
 catch (NumberFormatException e) {
throwParseException(value,primitiveType,e);
}
break;
case INT32:
try {
return Integer.valueOf(value);
}
 catch (NumberFormatException e) {
throwParseException(value,primitiveType,e);
}
break;
case INT64:
try {
return Long.valueOf(value);
}
 catch (NumberFormatException e) {
throwParseException(value,primitiveType,e);
}
break;
case STRING:
return value;
case SBYTE:
try {
return Byte.valueOf(value);
}
 catch (NumberFormatException e) {
throwParseException(value,primitiveType,e);
}
break;
default :
throw new ODataNotImplementedException("Unsupported primitive type: " + primitiveType + " for value: "+ value);
}
return null;
}

public static Object parsePrimitiveValue ( String value , PrimitiveType primitiveType ) throws ODataException { switch ( primitiveType ) { case BOOLEAN : return Boolean . valueOf ( value ) ; case BYTE : try { final Integer v = Integer . valueOf ( value ) ; if ( v < 0 || v > PARSE_INDEX ) { throwParseException ( value , primitiveType , null ) ; } return v . byteValue ( ) ; } catch ( NumberFormatException e ) { throwParseException ( value , primitiveType , e ) ; } break ; case DATE : try { return LocalDate . parse ( value ) ; } catch ( IllegalArgumentException e ) { throwParseException ( value , primitiveType , e ) ; } break ; case DATE_TIME_OFFSET : try { return ZonedDateTime . parse ( value ) ; } catch ( IllegalArgumentException e ) { throwParseException ( value , primitiveType , e ) ; } break ; case DURATION : try { return Period . parse ( value ) ; } catch ( IllegalArgumentException e ) { throwParseException ( value , primitiveType , e ) ; } break ; case TIME_OF_DAY : try { return LocalTime . parse ( value ) ; } catch ( IllegalArgumentException e ) { throwParseException ( value , primitiveType , e ) ; } break ; case DECIMAL : try { return new BigDecimal ( value ) ; } catch ( NumberFormatException e ) { throwParseException ( value , primitiveType , e ) ; } break ; case DOUBLE : try { return Double . parseDouble ( value ) ; } catch ( NumberFormatException e ) { throwParseException ( value , primitiveType , e ) ; } break ; case SINGLE : try { return Float . parseFloat ( value ) ; } catch ( NumberFormatException e ) { throwParseException ( value , primitiveType , e ) ; } break ; case GUID : try { return UUID . fromString ( value ) ; } catch ( IllegalArgumentException e ) { throwParseException ( value , primitiveType , e ) ; } break ; case INT16 : try { return Short . valueOf ( value ) ; } catch ( NumberFormatException e ) { throwParseException ( value , primitiveType , e ) ; } break ; case INT32 : try { return Integer . valueOf ( value ) ; } catch ( NumberFormatException e ) { throwParseException ( value , primitiveType , e ) ; } break ; case INT64 : try { return Long . valueOf ( value ) ; } catch ( NumberFormatException e ) { throwParseException ( value , primitiveType , e ) ; } break ; case STRING : return value ; case SBYTE : try { return Byte . valueOf ( value ) ; } catch ( NumberFormatException e ) { throwParseException ( value , primitiveType , e ) ; } break ; default : throw new ODataNotImplementedException ( "Unsupported primitive type: " + primitiveType + " for value: " + value ) ; } return null ; }
parses a primitive value into an instance of the specified primitive type .
