List of usage examples for java.lang Character valueOf
@HotSpotIntrinsicCandidate public static Character valueOf(char c)
From source file:ca.oson.json.Oson.java
private <E> String character2Json(FieldData objectDTO) { if (objectDTO == null || objectDTO.json2Java) { return null; }//w ww . j a v a 2s . c om Object value = objectDTO.valueToProcess; Class<E> returnType = objectDTO.returnType; if (returnType != null && value != null && (returnType == char.class || returnType == Character.class)) { Character valueToProcess = (Character) value; String valueToReturn = null; // convert from char to Character if (returnType == char.class) { valueToProcess = Character.valueOf((char) value); // new Character(value) } else { valueToProcess = (Character) value; } if (valueToProcess != null) { try { Function function = objectDTO.getSerializer(); if (function != null) { try { if (function instanceof DataMapper2JsonFunction) { DataMapper classData = new DataMapper(returnType, value, objectDTO.classMapper, objectDTO.level, getPrettyIndentation()); return ((DataMapper2JsonFunction) function).apply(classData); } else if (function instanceof Character2JsonFunction) { return ((Character2JsonFunction) function).apply(valueToProcess); } else { Object returnedValue = null; if (function instanceof FieldData2JsonFunction) { FieldData2JsonFunction f = (FieldData2JsonFunction) function; FieldData fieldData = objectDTO.clone(); returnedValue = f.apply(fieldData); } else { returnedValue = function.apply(value); } if (returnedValue instanceof Optional) { returnedValue = ObjectUtil.unwrap(returnedValue); } if (returnedValue == null) { return null; } else if (returnedValue instanceof Character || returnedValue.getClass() == char.class) { valueToProcess = (Character) returnedValue; } else { objectDTO.valueToProcess = returnedValue; return object2String(objectDTO); } } } catch (Exception e) { } } if (valueToProcess != null) { return Character.toString(valueToProcess); // String.valueOf(valueToProcess); } } catch (Exception ex) { //ex.printStackTrace(); } } } return character2JsonDefault(objectDTO); }