private JDefinedClass createAcceptingInterface(JDefinedClass valueClass,
ValueVisitorInterfaceModel visitorInterface,
Types types) throws JClassAlreadyExistsException {
JDefinedClass acceptingInterface = valueClass._class(JMod.PUBLIC, valueClass.name() + "Acceptor", EClassType.INTERFACE);
// Hack to overcome bug in codeModel. We want private interface!!! Not public.
acceptingInterface.mods().setPrivate();
for (JTypeVar visitorTypeParameter: visitorInterface.getValueTypeParameters()) {
Types.generifyWithBoundsFrom(acceptingInterface, visitorTypeParameter.name(), visitorTypeParameter);
}
JMethod acceptMethod = acceptingInterface.method(JMod.PUBLIC, types._void, "accept");
JTypeVar visitorResultType = visitorInterface.getResultTypeParameter();
JTypeVar resultType = Types.generifyWithBoundsFrom(acceptMethod, visitorResultType.name(), visitorResultType);
acceptMethod.type(resultType);