return defaultValue; if (is(Instant.class)) { return (Instant) data; if (is(LocalDate.class)) { return ((LocalDate) data).atStartOfDay(ZoneId.systemDefault()).toInstant(); if (is(LocalDateTime.class)) { return ((LocalDateTime) data).atZone(ZoneId.systemDefault()).toInstant(); if (is(LocalTime.class)) { return ((LocalTime) data).atDate(LocalDate.now()).atZone(ZoneId.systemDefault()).toInstant(); if (is(ZonedDateTime.class)) { return ((ZonedDateTime) data).toInstant(); if (is(Date.class)) { return Instant.ofEpochMilli(((Date) data).getTime()); if (is(Calendar.class)) { return Instant.ofEpochMilli(((Calendar) data).getTimeInMillis()); if (is(java.sql.Date.class)) { return Instant.ofEpochMilli(((java.sql.Date) data).getTime()); if (is(Timestamp.class)) { return Instant.ofEpochMilli(((java.sql.Timestamp) data).getTime());
/** * Returns a <tt>Value</tt> containing a translated value using the string representation * of the wrapped value as key. * * @param lang a two-letter language code for which the translation is requested * @return a <tt>Value</tt> containing a translated value by calling {@link NLS#get(String, String)} * if the string representation of the wrapped value starts with {@code $}. * The dollar sign is skipped when passing the key to <tt>NLS</tt>. Otherwise <tt>this</tt> is returned. * @see NLS#get(String, String) */ @Nonnull @CheckReturnValue public Value translate(String lang) { if (isFilled() && is(String.class)) { return Value.of(NLS.smartGet(asString(), lang)); } else { return this; } } }
if (is(Instant.class)) { return LocalDate.from((Instant) data); if (is(LocalDate.class)) { return (LocalDate) data; if (is(LocalDateTime.class)) { return ((LocalDateTime) data).toLocalDate(); if (is(ZonedDateTime.class)) { return ((ZonedDateTime) data).withZoneSameInstant(ZoneId.systemDefault()).toLocalDate(); if (is(Date.class)) { return Instant.ofEpochMilli(((Date) data).getTime()).atZone(ZoneId.systemDefault()).toLocalDate(); if (is(Calendar.class)) { return Instant.ofEpochMilli(((Calendar) data).getTimeInMillis()) .atZone(ZoneId.systemDefault()) .toLocalDate(); if (is(java.sql.Date.class)) { return Instant.ofEpochMilli(((java.sql.Date) data).getTime()).atZone(ZoneId.systemDefault()).toLocalDate(); if (is(Timestamp.class)) { return Instant.ofEpochMilli(((java.sql.Timestamp) data).getTime()) .atZone(ZoneId.systemDefault()) .toLocalDate(); if (is(long.class) || is(Long.class)) {
if (is(Instant.class)) { return LocalDateTime.from((Instant) data); if (is(LocalDateTime.class)) { return (LocalDateTime) data; if (is(LocalTime.class)) { return ((LocalTime) data).atDate(LocalDate.now()); if (is(ZonedDateTime.class)) { return ((ZonedDateTime) data).withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime(); if (is(Date.class)) { return LocalDateTime.ofInstant(Instant.ofEpochMilli(((Date) data).getTime()), ZoneId.systemDefault()); if (is(Calendar.class)) { return LocalDateTime.ofInstant(Instant.ofEpochMilli(((Calendar) data).getTimeInMillis()), ZoneId.systemDefault()); if (is(java.sql.Date.class)) { return LocalDateTime.ofInstant(Instant.ofEpochMilli(((java.sql.Date) data).getTime()), ZoneId.systemDefault()); if (is(Timestamp.class)) { return LocalDateTime.ofInstant(Instant.ofEpochMilli(((java.sql.Timestamp) data).getTime()), ZoneId.systemDefault()); if (is(long.class) || is(Long.class)) { return LocalDateTime.ofInstant(Instant.ofEpochMilli((long) data), ZoneId.systemDefault());
@Override protected Object transformFromDatasource(Class<? extends BaseMapper<?, ?, ?>> mapperType, Value data) { Object object = data.get(); if (object instanceof Boolean) { return object; } if (data.is(String.class) ) { return data.asBoolean(); } if (object == null) { if (field.getType().isPrimitive()) { return false; } else { return null; } } return ((Integer) object) != 0; }
return defaultValue; if (is(Instant.class)) { return ZonedDateTime.from((Instant) data); if (is(LocalDate.class)) { return ((LocalDate) data).atStartOfDay(ZoneId.systemDefault()); if (is(LocalDateTime.class)) { return ((LocalDateTime) data).atZone(ZoneId.systemDefault()); if (is(LocalTime.class)) { return ((LocalTime) data).atDate(LocalDate.now()).atZone(ZoneId.systemDefault()); if (is(ZonedDateTime.class)) { return (ZonedDateTime) data; if (is(Date.class)) { return ZonedDateTime.from(Instant.ofEpochMilli(((Date) data).getTime())); if (is(Calendar.class)) { return ZonedDateTime.from(Instant.ofEpochMilli(((Calendar) data).getTimeInMillis())); if (is(java.sql.Date.class)) { return ZonedDateTime.from(Instant.ofEpochMilli(((java.sql.Date) data).getTime())); if (is(Timestamp.class)) { return ZonedDateTime.from(Instant.ofEpochMilli(((java.sql.Timestamp) data).getTime()));
@SuppressWarnings("unchecked") private <T> T continueCoerceWithDateTypes(Class<T> targetClazz, T defaultValue) { if (LocalDate.class.equals(targetClazz)) { if (is(TemporalAccessor.class, Calendar.class, Date.class, java.sql.Date.class, Timestamp.class)) { return (T) asLocalDate((LocalDate) defaultValue); } } if (LocalDateTime.class.equals(targetClazz)) { if (is(TemporalAccessor.class, Calendar.class, Date.class, java.sql.Date.class, Timestamp.class)) { return (T) asLocalDateTime((LocalDateTime) defaultValue); } } if (ZonedDateTime.class.equals(targetClazz)) { if (is(TemporalAccessor.class, Calendar.class, Date.class, java.sql.Date.class, Timestamp.class)) { return (T) asZonedDateTime((ZonedDateTime) defaultValue); } } if (LocalTime.class.equals(targetClazz) && data instanceof TemporalAccessor) { if (is(TemporalAccessor.class, Calendar.class, Date.class, java.sql.Date.class, Timestamp.class, Time.class)) { return (T) asLocalTime((LocalTime) defaultValue); } } return continueCoerceWithEnumTypes(targetClazz, defaultValue); }
@Override protected Object transformFromDatasource(Class<? extends BaseMapper<?, ?, ?>> mapperType, Value object) { if (object.get() instanceof Long) { return Integer.valueOf(((Long) object.get()).intValue()); } if (object.is(String.class) ) { return object.getInteger(); } return object.get(); }
return defaultValue; if (is(Instant.class)) { return LocalTime.from((Instant) data); if (is(LocalDateTime.class)) { return ((LocalDateTime) data).toLocalTime(); if (is(LocalTime.class)) { return (LocalTime) data; if (is(ZonedDateTime.class)) { return ((ZonedDateTime) data).withZoneSameInstant(ZoneId.systemDefault()).toLocalTime(); if (is(Date.class)) { return LocalDateTime.from(Instant.ofEpochMilli(((Date) data).getTime())).toLocalTime(); if (is(Calendar.class)) { return LocalDateTime.from(Instant.ofEpochMilli(((Calendar) data).getTimeInMillis())).toLocalTime(); if (is(java.sql.Date.class)) { return LocalDateTime.from(Instant.ofEpochMilli(((java.sql.Date) data).getTime())).toLocalTime(); if (is(Timestamp.class)) { return LocalDateTime.from(Instant.ofEpochMilli(((java.sql.Timestamp) data).getTime())).toLocalTime(); if (is(long.class) || is(Long.class)) { return LocalDateTime.from(Instant.ofEpochMilli((long) data)).toLocalTime();
@Override protected Object transformFromDatasource(Class<? extends BaseMapper<?, ?, ?>> mapperType, Value object) { if (object.get() instanceof Integer) { return Long.valueOf((Integer) object.get()); } if (object.is(String.class) ) { return object.getLong(); } return object.get(); }