Error while Calling parent class method using Lambda

Code_Mode

This is extension to my this question

I want to fetch id from a List below,

List allUserGroups = UserBC.getAllGroupsForUser(userId, deptID);

This List has Objects which I need to typecast to GroupData entity. GroupData extends PartyData which has getId() method defined in it. So I tried using labda as ,

allUserGroups.stream()
.map(GroupData.class::cast)
.map(GroupData::getId)

Issue here is, compiler shows The type GroupData does not define getId(Object) that is applicable here.

The type GroupData does not define getId(Object) that is applicable here

It works fine with normal for loop,

for(Object userGroup: allUserGroups){
    long usergrp = ((GroupData) userGroup ).getId();
}

Can anyone suggest how to achieve this using Labmda

Code_Mode

Used typecast while fetching the list as commented by Jespher and it solved my issue,

List<GroupData> allUserGroups = (List<GroupData>) UserBC.getAllGroupsForUser(userId, deptID);
allUserGroups.stream().map(GroupData::getId)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

stackoverflow while calling method of parent class in subclass

From Dev

Calling parent method from a class

From Dev

Error java.lang.NullPointerException while calling class method

From Dev

Error java.lang.NullPointerException while calling class method

From Dev

Calling method of the base class (not the immediate parent class)

From Dev

error while calling a java Method

From Dev

Getting error while calling the method

From Dev

Getting error while calling the method

From Dev

Python: How to subclass while calling parent class?

From Dev

Calling method that exists in child classes but not in parent class

From Dev

Calling a method of extended class while initialising it as interface

From Dev

Using _this to refer to parent class method

From Dev

Calling super() to parent class using generics

From Dev

determine which child class is calling parent class' method

From Dev

Calling method of child class from object of parent class in C++

From Dev

how to write separate error method while calling calling webservice?

From Dev

Inner method of directive is not calling the parent method (also no error in console)

From Java

What is the purpose of calling super class's method while overriding a method?

From Dev

Using an extension method without calling class name

From Dev

Calling a PHP class method using AJAX

From Dev

Calling method of class in hub using SignalR

From Dev

Calling method in parent class from subclass methods in Ruby

From Dev

Java calling pre-parent method of child class

From Dev

calling a dervied method from a parent class c#

From Dev

calling parent's method with parameter from nested class in python

From Dev

Calling parent method in typescript

From Dev

Calling parent method

From Dev

Calling `super()` in parent class

From Dev

Calling generic static method locally while omitting class name

Related Related

  1. 1

    stackoverflow while calling method of parent class in subclass

  2. 2

    Calling parent method from a class

  3. 3

    Error java.lang.NullPointerException while calling class method

  4. 4

    Error java.lang.NullPointerException while calling class method

  5. 5

    Calling method of the base class (not the immediate parent class)

  6. 6

    error while calling a java Method

  7. 7

    Getting error while calling the method

  8. 8

    Getting error while calling the method

  9. 9

    Python: How to subclass while calling parent class?

  10. 10

    Calling method that exists in child classes but not in parent class

  11. 11

    Calling a method of extended class while initialising it as interface

  12. 12

    Using _this to refer to parent class method

  13. 13

    Calling super() to parent class using generics

  14. 14

    determine which child class is calling parent class' method

  15. 15

    Calling method of child class from object of parent class in C++

  16. 16

    how to write separate error method while calling calling webservice?

  17. 17

    Inner method of directive is not calling the parent method (also no error in console)

  18. 18

    What is the purpose of calling super class's method while overriding a method?

  19. 19

    Using an extension method without calling class name

  20. 20

    Calling a PHP class method using AJAX

  21. 21

    Calling method of class in hub using SignalR

  22. 22

    Calling method in parent class from subclass methods in Ruby

  23. 23

    Java calling pre-parent method of child class

  24. 24

    calling a dervied method from a parent class c#

  25. 25

    calling parent's method with parameter from nested class in python

  26. 26

    Calling parent method in typescript

  27. 27

    Calling parent method

  28. 28

    Calling `super()` in parent class

  29. 29

    Calling generic static method locally while omitting class name

HotTag

Archive