List iteration - Generic logic

Ankit

I have a list of beans (List<AClass>), from which I am creating two sub list based some logic which involves checking a field from the bean class, say action. if

bean.getAction.equals("true") - add to new sublist - List<AClass> listA
else - add to new sublist - List<AClass> listB

I have created a method for it and it works fine.

Now I have similar task for other Bean class as well where i have List<BClass> which also has action field and getAction method. I want to create a generic method which would cater to both these beans (and other similar beans as well).

How can I create such method?

luboskrnac

Use List<? extends ParentClass> where ParentClass is parent of AClass and BClass

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Generic comparison logic for objects

From Dev

For Loop Logic Iteration Why not behaving Same ?

From Dev

For Loop Logic Iteration Why not behaving Same ?

From Dev

Generic list of generic objects

From Dev

multiple iteration of the same list

From Dev

Updating list of lists at iteration

From Dev

Python List Iteration/Addition

From Dev

Pythonic List Iteration

From Dev

issues with xrange and list iteration

From Dev

Another loop iteration of list

From Dev

Iteration over a list

From Dev

thymeleaf iteration on a list

From Dev

Drools list iteration issue

From Dev

Python list, iteration

From Dev

Python Iteration in list

From Dev

struts 2 list iteration

From Dev

Iteration/double iteration over a nested list in Python

From Dev

nested generic container iteration C++

From Dev

nested generic container iteration C++

From Dev

How should I remove elements from a generic list based on the list s object's inclusion of elementfrom another list in C# using predicate logic?

From Dev

How should I remove elements from a generic list based on the list s object's inclusion of elementfrom another list in C# using predicate logic?

From Dev

Doubly Linked List logic

From Dev

"Ends with" logic referencing a list

From Dev

Apply Generic logic for different types in Java

From Dev

JSON Data Iteration with a List of Results

From Dev

Java Stream multi list iteration

From Dev

for iteration in self: what's in the list?

From Dev

Iteration on nested list and generators and yield

From Dev

Python iteration of list of objects "not iterable"