I'm having an issue regarding the simulation of public interfaces in java 8. I have this interface with this methods right now:
public interface A<T> {
void method1(T t) throws someException;
void method2(T t) throws someException;
default method3() {
return Collections.emptyMap();
}
}
The interface A is implemented by class B
, which is an abstract class:
public abstract class B<T> implements A<T> {
@Override
public void method1(T type) throws someException {
// (.... some code snipets ....)
}
}
The method1
contains all the logic and should be the one that the developer can see/use.
Now, bellow is represented the concrete representation of class B
:
public final class ConcreteB extends B<someObject> {
private static ConcreteB concreteBInstance = null;
private ConcreteB() {
}
public static ConcreteB getInstance() {
if (concreteBInstance == null) {
concreteBInstance = new ConcreteB();
}
return concreteBInstance;
}
@Override
public void method2(someObject someObject) throws someException {
// (... code ...)
}
}
So, to summarize, the concrete implementation of B implements the method2
(and the method3, if the user wants to). The class B implements the method1
, which contains all the logic.
My problem here is that when I do ConcreteB.getInstance()
, the methods that are available for the developer to use are the method1
, method2
, and method3
, and I want to make only the method1 visible to the developer. But because java 8 don't enable me to make private methods on interfaces, I don't know how to do it.
Any tips to how to solve this problem?
Thanks!