Java Generics, como evitar aviso de atribuição desmarcada ao usar a hierarquia de classe

Eu quero usar um método usando parâmetros genéricos e retornando resultado genérico em uma hierarquia de classe

edit: SupressWarnings ("desmarcado") resposta permitida: -)

Aqui está um código de exemplo que ilustra meu problema:

import java.util.*;

public class GenericQuestion {

    interface Function<F, R> {R apply(F data);}
    static class Fruit {int id; String name; Fruit(int id, String name) {
        this.id = id; this.name = name;}
    }
    static class Apple extends Fruit { 
        Apple(int id, String type) { super(id, type); }
    }
    static class Pear extends Fruit { 
        Pear(int id, String type) { super(id, type); }
    }

    public static void main(String[] args) {

        List<Apple> apples = Arrays.asList(
                new Apple(1,"Green"), new Apple(2,"Red")
        );
        List<Pear> pears = Arrays.asList(
                new Pear(1,"Green"), new Pear(2,"Red")
        );

        Function fruitID = new Function<Fruit, Integer>() {
            public Integer apply(Fruit data) {return data.id;}
        };

        Map<Integer, Apple> appleMap = mapValues(apples, fruitID);
        Map<Integer, Pear> pearMap = mapValues(pears, fruitID);
    }

      public static <K,V> Map<K,V> mapValues(
              List<V> values, Function<V,K> function) {

        Map<K,V> map = new HashMap<K,V>();
        for (V v : values) {
            map.put(function.apply(v), v);
        }
        return map;
    }
}

Como remover a exceção genérica dessas chamadas:

Map<Integer, Apple> appleMap = mapValues(apples, fruitID);
Map<Integer, Pear> pearMap = mapValues(pears, fruitID);

Bônus pergunta: como remover o erro de compilação se eu declarar a função fruitId desta maneira:

Function<Fruit, Integer> fruitID = new Function<Fruit, Integer>() {public Integer apply(Fruit data) {return data.id;}};

Estou muito confuso sobre genéricos quando se trata de hierarquia. Qualquer ponteiro para um bom recurso sobre o uso e será muito apreciad

questionAnswers(1)

yourAnswerToTheQuestion