Skip to content

Commit

Permalink
Revert to pre-contravariant method signature to avoid generic issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaseder committed Jul 6, 2016
1 parent d98c043 commit 1800024
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions jOOQ/src/main/java/org/jooq/tools/Convert.java
Original file line number Diff line number Diff line change
Expand Up @@ -304,19 +304,15 @@ else if (from[0] != null && from[0].getClass() == toComponentType) {
* @return The target type object
* @throws DataTypeException - When the conversion is not possible
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public static final <U> U convert(Object from, Converter<?, ? extends U> converter) throws DataTypeException {

// Raw type cast necessary because of javac compiler bug in 1.8.0_74 (still used by travis)
return (U) convert0(from, (Converter) converter);
return convert0(from, converter);
}

/**
* Conversion type-safety
*/
@SuppressWarnings("unchecked")
private static final <T, U> U convert0(Object from, Converter<? super T, ? extends U> converter) throws DataTypeException {
ConvertAll<T> all = new ConvertAll<T>((Class<T>) converter.fromType());
private static final <T, U> U convert0(Object from, Converter<T, ? extends U> converter) throws DataTypeException {
ConvertAll<T> all = new ConvertAll<T>(converter.fromType());
return converter.from(all.from(from));
}

Expand Down Expand Up @@ -408,19 +404,15 @@ public static final <T> List<T> convert(Collection<?> collection, Class<? extend
* @throws DataTypeException - When the conversion is not possible
* @see #convert(Object, Converter)
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public static final <U> List<U> convert(Collection<?> collection, Converter<?, ? extends U> converter) throws DataTypeException {

// Raw type cast necessary because of javac compiler bug in 1.8.0_74 (still used by travis)
return convert0(collection, (Converter) converter);
return convert0(collection, converter);
}

/**
* Type safe conversion
*/
@SuppressWarnings("unchecked")
private static final <T, U> List<U> convert0(Collection<?> collection, Converter<? super T, ? extends U> converter) throws DataTypeException {
ConvertAll<T> all = new ConvertAll<T>((Class<T>) converter.fromType());
private static final <T, U> List<U> convert0(Collection<?> collection, Converter<T, ? extends U> converter) throws DataTypeException {
ConvertAll<T> all = new ConvertAll<T>(converter.fromType());
List<U> result = new ArrayList<U>(collection.size());

for (Object o : collection) {
Expand Down

0 comments on commit 1800024

Please sign in to comment.