Hi everyone,
I guess it's about time to start working out the ideas for QDox 2.0
The first thing I'd like to pick up is interfacing our model so we can hide al
lot of methods for the users, since most of the time only the getters are
interesting for them.
My idea is to give the interfaces the name of the current classes and give the
implementation the Default prefix.
So the current class JavaClass will become an interface JavaClass with the
implementing class DefaultJavaClass
This way we should be able to keep most the junittests as they are, exception
for the constructor-part.
Here I suggest to make the current model junit test classes abstract and give
them abstract methods for getting an instance.
The JavaParameterTest class is pretty small, but with the folling example it
should be clear what I mean:
I've remove all constructor calls.
Also I've made a method addParameter, because this is some sort of setter so
it's nominated to be invisible for the interface.
First step: prepare the junit-tests.
For the next step I'll write some docs, hopefully we can discuss it in order to
get QDox to the next level.
Anybody who's willing to help, just reply and mention what you want to do.
- Robert
public abstract class JavaParameterTest extends TestCase {
public JavaParameterTest(String s) {
super(s);
}
public abstract Type newType(String typeName);
public abstract JavaParameter newJavaParameter(Type type, String name);
public abstract JavaMethod newJavaMethod();
public abstract void addParameter(JavaMethod method, JavaParameter parameter);
public void testParentMethod() throws Exception {
JavaParameter p = newJavaParameter(newType("x"), "x");
assertNull(p.getParentMethod());
JavaMethod m = newJavaMethod();
addParameter(m, p);
assertSame(m, p.getParentMethod());
}
}
public class DefaultJavaParameterTest extends JavaParameterTest
{
public DefaultJavaParameterTest( String s )
{
super( s );
}
public Type newType( String typeName )
{
return new Type(typeName);
}
public JavaParameter newJavaParameter( Type type, String name )
{
return new JavaParameter(type, name);
}
public JavaMethod newJavaMethod()
{
return new JavaMethod();
}
public void addParameter( JavaMethod method, JavaParameter parameter )
{
method.addParameter( parameter );
}
}