in api/applib/src/main/java/org/apache/causeway/applib/util/schema/CommonDtoUtils.java [443:509]
public Object getValueAsObject (
final @NonNull ValueType valueType,
final @Nullable ValueDto valueDto) {
if(valueDto==null) {
return null;
}
switch(valueType) {
case STRING:
return valueDto.getString();
case BYTE:
return valueDto.getByte();
case SHORT:
return valueDto.getShort();
case INT:
return valueDto.getInt();
case LONG:
return valueDto.getLong();
case FLOAT:
return valueDto.getFloat();
case DOUBLE:
return valueDto.getDouble();
case BOOLEAN:
return valueDto.isBoolean();
case CHAR:
final String aChar = valueDto.getChar();
if(_Strings.isNullOrEmpty(aChar)) { return null; }
return aChar.charAt(0);
case BIG_DECIMAL:
return valueDto.getBigDecimal();
case BIG_INTEGER:
return valueDto.getBigInteger();
case LOCAL_DATE:
return JavaTimeXMLGregorianCalendarMarshalling.toLocalDate(valueDto.getLocalDate());
case LOCAL_TIME:
return JavaTimeXMLGregorianCalendarMarshalling.toLocalTime(valueDto.getLocalTime());
case LOCAL_DATE_TIME:
return JavaTimeXMLGregorianCalendarMarshalling.toLocalDateTime(valueDto.getLocalDateTime());
case OFFSET_DATE_TIME:
return JavaTimeXMLGregorianCalendarMarshalling.toOffsetDateTime(valueDto.getOffsetDateTime());
case OFFSET_TIME:
return JavaTimeXMLGregorianCalendarMarshalling.toOffsetTime(valueDto.getOffsetTime());
case ZONED_DATE_TIME:
return JavaTimeXMLGregorianCalendarMarshalling.toZonedDateTime(valueDto.getZonedDateTime());
case ENUM:
final EnumDto enumDto = valueDto.getEnum();
final String enumType = enumDto.getEnumType();
@SuppressWarnings("rawtypes")
final Class<? extends Enum> enumClass =
_Casts.uncheckedCast(_Context.loadClassAndInitialize(enumType));
return Enum.valueOf(_Casts.uncheckedCast(enumClass), enumDto.getEnumName());
case REFERENCE:
return valueDto.getReference();
case BLOB:
final BlobDto blobDto = valueDto.getBlob();
return new Blob(blobDto.getName(), blobDto.getMimeType(), blobDto.getBytes());
case CLOB:
final ClobDto clobDto = valueDto.getClob();
return new Clob(clobDto.getName(), clobDto.getMimeType(), clobDto.getChars());
case VOID:
return null;
default:
throw _Exceptions.unmatchedCase(valueType);
}
}