How to make a generic parameter optional in interface in java?

Viewed 6967

I have an interface which has 2 generic parameters.But abstract method inside sometimes is needed to accept only 1 generic parameter.How can i make that happen ? The way i see it i can't make the generics optional and also if i write an overloaded method inside the interface it will be unnecessarily implemented in some java classes(which will be implementing that interface) where it's not needed. Now i am passing the parameterized which is needed twice both in the class header while implementing the interface and also inside a function,since i compulsorily have to pass 2 arguments.I am stuck.Any direction ?

public interface ITaskPermissionHandler<T, V> {

    String getType();

    boolean hasPermission(T clazz, UserRef user, String type, V clazz1);
}

public class CreateTaskPermission implements ITaskPermissionHandler<Task,Task> {

    @Override
    public String getType() {
        return TaskConstants.CREATE_TASK;
    }

    @Override
    public boolean hasPermission(Task task, UserRef user, String type, Task      task1) {
        return type.equalsIgnoreCase(TaskConstants.CREATE_TASK);
    }
}
1 Answers
Related