@Test @DisplayName("obtain a column type mapping of a supertype") void obtainForSupertype() { Timestamp timestamp = Time.currentTime(); ColumnTypeMapping<?, ? extends String> rule = mapping.of(Timestamp.class); String result = rule.applyTo(timestamp); assertThat(result).isEqualTo(CONVERTED_MESSAGE); }
@SuppressWarnings("unchecked") @Override public <T> ColumnTypeMapping<T, ? extends R> of(Class<T> type) { checkNotNull(type); ColumnTypeMapping<?, ? extends R> result; Optional<ColumnTypeMapping<?, ? extends R>> rule = customMappingFor(type); if (rule.isPresent()) { result = rule.get(); } else { rule = standardMappingFor(type); result = rule.orElseThrow(() -> unsupportedType(type)); } return (ColumnTypeMapping<T, ? extends R>) result; }
AbstractColumnMapping implements ColumnMapping<R> { @SuppressWarnings("unchecked") @Override public <T> ColumnTypeMapping<T, ? extends R> of(Class<T> type) { checkNotNull(type); ColumnTypeMapping<?, ? extends R> result; Optional<ColumnTypeMapping<?, ? extends R>> rule = customMappingFor(type); if (rule.isPresent()) { result = rule.get(); } else { rule = standardMappingFor(type); result = rule.orElseThrow(() -> unsupportedType(type)); } return (ColumnTypeMapping<T, ? extends R>) result; } }
AbstractColumnMapping implements ColumnMapping<R> { @SuppressWarnings("unchecked") @Override public <T> ColumnTypeMapping<T, ? extends R> of(Class<T> type) { checkNotNull(type); ColumnTypeMapping<?, ? extends R> result; Optional<ColumnTypeMapping<?, ? extends R>> rule = customMappingFor(type); if (rule.isPresent()) { result = rule.get(); } else { rule = standardMappingFor(type); result = rule.orElseThrow(() -> unsupportedType(type)); } return (ColumnTypeMapping<T, ? extends R>) result; }  }
AbstractColumnMapping implements ColumnMapping<R> { @SuppressWarnings("unchecked") @Override public <T> ColumnTypeMapping<T, ? extends R> of(Class<T> type) { checkNotNull(type); ColumnTypeMapping<?, ? extends R> result; Optional<ColumnTypeMapping<?, ? extends R>> rule = customMappingFor(type); if (rule.isPresent()) { result = rule.get(); } else { rule = standardMappingFor(type); result = rule.orElseThrow(() -> unsupportedType(type)); } return (ColumnTypeMapping<T, ? extends R>) result; }  @SuppressWarnings("unchecked") // Ensured by mapping declaration. @Override ColumnTypeMapping<T, ? extends R> of(Class<T> type); }
AbstractColumnMapping implements ColumnMapping<R> { @SuppressWarnings("unchecked") @Override public <T> ColumnTypeMapping<T, ? extends R> of(Class<T> type) { checkNotNull(type); ColumnTypeMapping<?, ? extends R> result; Optional<ColumnTypeMapping<?, ? extends R>> rule = customMappingFor(type); if (rule.isPresent()) { result = rule.get(); } else { rule = standardMappingFor(type); result = rule.orElseThrow(() -> unsupportedType(type)); } return (ColumnTypeMapping<T, ? extends R>) result; }  @SuppressWarnings("unchecked") // Ensured by mapping declaration. @Override ColumnTypeMapping<T, ? extends R> of(Class<T> type);  }