Raw types warning

Brian Goetz brian.goetz at oracle.com
Thu Apr 18 13:45:08 PDT 2013


That's going pretty roundabout...

How about:

   hqIds.stream()
        .map(id -> findDealer(id))
        .flatMap(d -> d.getBranches().stream())
        .collect(toList());

No reason to create intermediate garbage List<Dealer> if you can 
efficiently map from id to Dealer.

On 4/18/2013 4:34 PM, Michael Nascimento wrote:
> Hi guys,
>
> I have this:
>
> public List<Dealer> findBranchesByHeadQuarterIds(Collection<Long>
> headQuarterIds) {
>      return findByIds(headQuarterIds).parallelStream()
>          .map(Dealer::getBranches)
>          .flatMap(Set::stream)
>          .collect(toList());
> }
>
> given that:
>
> List<Dealer> findByIds(Collection<Long>);
> Set<Dealer> getBranches();
>
> produces:
>
>   [rawtypes] found raw type: Set
>    missing type arguments for generic class Set<E>
>    where E is a type-variable:
>      E extends Object declared in interface Set
>
> with all warnings turned on.
>
> Is this expected?
>
> Regards,
> Michael
>


More information about the lambda-dev mailing list