I'm trying to modify a class AuthenticatedUser to store a list of AdminRole's. AuthenticatedUser is a class used by all my applications; it gets put into a session when the user logs in successfully. Now I want to add a list of authorization roles to the user session. However each application defines the an AdminRole class a little differently. For example, my DataCenter application stores in the database:
employee_id
role_name
site_name
receive_email
Not all of my applications will need the receive_email field or may want to extend their own methods. I figured this called for an abstract class. But Eclipse is complaining about the wrong Type on the Authorized_role_list setter here in this snippet.
DataCenterAdminRoleDAO dcAdminDao = new DataCenterAdminRoleDAO();
try {
List<DataCenterAdminRole> authorized_roles = dcAdminDao.getAuthorizedRoleListByBadge(authenticatedUser.getBadge());
authenticatedUser.setAuthorized_role_list(authorized_roles);
=== Classes
public class AuthenticatedUser extends Employee implements Serializable {
private static final long serialVersionUID = 1L;
private List<AdminRole> authorized_role_list;
...
}
public abstract class AdminRole implements Serializable {
private static final long serialVersionUID = 1L;
private String role_name; //regular, admin, editor, etc..
private String site_id; //company branches
...
}
public class DataCenterAdminRole extends AdminRole implements Serializable {
Obviously a fix is to return a list of AdminRole in my Datacenter implemetation but I thought by extending the abstract class I could pass the subclass. What am I missing?