Reputation: 43
I want to define an interface with same name as other one, but different parameters. How can I do it? Please help.
public interface IFactory<T> {
IFactory<T> Select(List<String> fields);
IFactory<T> GroupBy(Expression<?> fields);
IFactory<T> Where(Object column, ConditionalMethods conditionalMethod, Object... value);
IFactory<T> And(Object column, ConditionalMethods conditionalMethod, Object... value);
IFactory<T> Or(Object column, ConditionalMethods conditionalMethod, Object... value);
T Take();
T TakeNewObject();
T TakeAndLock();
}
public interface IFactory<T, Z> {
IFactory<T, Z> Select(List<String> fields);
IFactory<T, Z> GroupBy(Expression<?> fields);
IFactory<T, Z> Where(Object column, ConditionalMethods conditionalMethod, Object... value);
IFactory<T, Z> And(Object column, ConditionalMethods conditionalMethod, Object... value);
IFactory<T, Z> Or(Object column, ConditionalMethods conditionalMethod, Object... value);
T Take();
T TakeNewObject();
T TakeAndLock();
}
I get following error:
java duplicate class: com.xxx.IFactory
Upvotes: 4
Views: 91
Reputation: 393936
You can't. You must use different names. That's how it is done in JDK interfaces.
For example, consider java.util.function.Function<T, R>
vs. java.util.function.BiFunction<T, U, R>
. Both are functional interfaces that represent a function, but the first represents a function with one argument (and a result) and the second represents a function with two arguments (and a result).
Upvotes: 4