Use type parameter for Supplier in AggregateBinder.merge()

Closes gh-13139
This commit is contained in:
Johnny Lim 2018-05-11 14:40:15 +09:00 committed by Stephane Nicoll
parent 243023f2ad
commit d72ba70cba
4 changed files with 7 additions and 9 deletions

View File

@ -60,7 +60,7 @@ abstract class AggregateBinder<T> {
if (result == null || value == null) {
return result;
}
return merge(value, (T) result);
return merge((Supplier<T>) value, (T) result);
}
/**
@ -79,7 +79,7 @@ abstract class AggregateBinder<T> {
* @param additional the additional elements to merge
* @return the merged result
*/
protected abstract T merge(Supplier<?> existing, T additional);
protected abstract T merge(Supplier<T> existing, T additional);
/**
* Return the context being used by this binder.

View File

@ -56,7 +56,7 @@ class ArrayBinder extends IndexedElementsBinder<Object> {
}
@Override
protected Object merge(Supplier<?> existing, Object additional) {
protected Object merge(Supplier<Object> existing, Object additional) {
return additional;
}

View File

@ -55,10 +55,9 @@ class CollectionBinder extends IndexedElementsBinder<Collection<Object>> {
}
@Override
@SuppressWarnings("unchecked")
protected Collection<Object> merge(Supplier<?> existing,
protected Collection<Object> merge(Supplier<Collection<Object>> existing,
Collection<Object> additional) {
Collection<Object> existingCollection = (Collection<Object>) existing.get();
Collection<Object> existingCollection = existing.get();
if (existingCollection == null) {
return additional;
}

View File

@ -83,10 +83,9 @@ class MapBinder extends AggregateBinder<Map<Object, Object>> {
}
@Override
@SuppressWarnings("unchecked")
protected Map<Object, Object> merge(Supplier<?> existing,
protected Map<Object, Object> merge(Supplier<Map<Object, Object>> existing,
Map<Object, Object> additional) {
Map<Object, Object> existingMap = (Map<Object, Object>) existing.get();
Map<Object, Object> existingMap = existing.get();
if (existingMap == null) {
return additional;
}