Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Generics and Inheritance

user5876281Oct 2 2013 — edited Oct 2 2013

Hello,

I am new to generics and trying to change our existing code to use generics.

We have one abstract super class and multiple sub classes. Super class contains a collection that should contain values only of a specific type bases on the sub class. Question I have is, how do I tell super class what type to use for that collection?

Here is the sample code.

Super Class:


import java.util.ArrayList;
import java.util.List;

public class BusinessModelObjectCollection <T>{
    private List <T> bmoColl;
   
    public <T> BusinessModelObjectCollection(){
        bmoColl = new ArrayList<>();
    }
}

Sub Class:

public class AssignableWorkTypeCollection extends BusinessModelObjectCollection {
   
    public AssignableWorkTypeCollection(){
        super<AssignableWorkTypeCollection>();
    }
}

I am getting compile time error in subclass when I try to pass the type when I call the constructor.

I will really appreciate your help on this.

Thanks,

Swetal

This post has been answered by DrClap on Oct 2 2013
Jump to Answer

Comments

Francisco Amores

Are you scheduling the DLR from Data Load Rule page or have you created a batch definition with POV period checked and then schedule it?

Regards

1 - 1
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 30 2013
Added on Oct 2 2013
2 comments
1,913 views