extended CodeWriter signature

This commit is contained in:
Timo Westkämper 2010-05-24 21:03:08 +00:00
parent a180a6b878
commit 8f8b2fcd98
2 changed files with 31 additions and 169 deletions

View File

@ -19,226 +19,68 @@ import org.apache.commons.collections15.Transformer;
*/
public interface CodeWriter extends Appendable{
/**
* @param annotation
* @return
* @throws IOException
*/
CodeWriter annotation(Annotation annotation) throws IOException;
/**
* @param annotation
* @return
* @throws IOException
*/
CodeWriter annotation(Class<? extends Annotation> annotation) throws IOException;
/**
* @param simpleName
* @return
* @throws IOException
*/
CodeWriter beginClass(String simpleName) throws IOException;
/**
* @param simpleName
* @param superClass
* @param interfaces
* @return
* @throws IOException
*/
CodeWriter beginClass(String simpleName, String superClass, String... interfaces) throws IOException;
/**
* @param <T>
* @param params
* @param transformer
* @return
* @throws IOException
*/
<T> CodeWriter beginConstructor(Collection<T> params, Transformer<T, String> transformer) throws IOException;
/**
* @param params
* @return
* @throws IOException
*/
CodeWriter beginConstructor(String... params) throws IOException;
/**
* @param simpleName
* @param interfaces
* @return
* @throws IOException
*/
CodeWriter beginInterface(String simpleName, String... interfaces) throws IOException;
/**
* @param <T>
* @param returnType
* @param methodName
* @param parameters
* @param transformer
* @return
* @throws IOException
*/
<T> CodeWriter beginPublicMethod(String returnType, String methodName, Collection<T> parameters, Transformer<T, String> transformer) throws IOException;
/**
* @param returnType
* @param methodName
* @param args
* @return
* @throws IOException
*/
CodeWriter beginPublicMethod(String returnType, String methodName, String... args) throws IOException;
/**
* @param <T>
* @param type
* @param name
* @param params
* @param transformer
* @return
* @throws IOException
*/
<T> CodeWriter beginStaticMethod(String type, String name, Collection<T> params, Transformer<T, String> transformer) throws IOException;
/**
* @param returnType
* @param methodName
* @param args
* @return
* @throws IOException
*/
CodeWriter beginStaticMethod(String returnType, String methodName, String... args) throws IOException;
/**
* @return
* @throws IOException
*/
CodeWriter end() throws IOException;
/**
* @param type
* @param name
* @return
* @throws IOException
*/
CodeWriter field(String type, String name) throws IOException;
/**
* @param imports
* @return
* @throws IOException
*/
CodeWriter imports(Class<?>... imports) throws IOException;
/**
* @param imports
* @return
* @throws IOException
*/
CodeWriter imports(Package... imports) throws IOException;
/**
* @param lines
* @return
* @throws IOException
*/
CodeWriter javadoc(String... lines) throws IOException;
/**
* @param segments
* @return
* @throws IOException
*/
CodeWriter line(String... segments) throws IOException;
/**
* @return
* @throws IOException
*/
CodeWriter nl() throws IOException;
/**
* @param packageName
* @return
* @throws IOException
*/
CodeWriter packageDecl(String packageName) throws IOException;
/**
* @param type
* @param name
* @return
* @throws IOException
*/
CodeWriter privateField(String type, String name) throws IOException;
/**
* @param type
* @param name
* @param value
* @return
* @throws IOException
*/
CodeWriter privateFinal(String type, String name) throws IOException;
CodeWriter privateFinal(String type, String name, String value) throws IOException;
CodeWriter privateStaticFinal(String type, String name, String value) throws IOException;
/**
* @param type
* @param name
* @return
* @throws IOException
*/
CodeWriter protectedField(String type, String name) throws IOException;
/**
* @param type
* @param name
* @return
* @throws IOException
*/
CodeWriter publicField(String type, String name) throws IOException;
CodeWriter protectedFinal(String type, String name) throws IOException;
/**
* @param type
* @param name
* @return
* @throws IOException
*/
CodeWriter protectedFinal(String type, String name, String value) throws IOException;
CodeWriter publicField(String type, String name) throws IOException;
CodeWriter publicFinal(String type, String name) throws IOException;
/**
* @param type
* @param name
* @param value
* @return
* @throws IOException
*/
CodeWriter publicFinal(String type, String name, String value) throws IOException;
/**
* @param type
* @param name
* @param value
* @return
* @throws IOException
*/
CodeWriter publicStaticFinal(String type, String name, String value) throws IOException;
/**
* @param imports
* @return
* @throws IOException
*/
CodeWriter staticimports(Class<?>... imports) throws IOException;
/**
* @param type
* @return
* @throws IOException
*/
CodeWriter suppressWarnings(String type) throws IOException;
}

View File

@ -334,6 +334,16 @@ public final class JavaWriter implements Appendable, CodeWriter{
return field(PRIVATE, type, name);
}
@Override
public JavaWriter privateFinal(String type, String name) throws IOException {
return field(PRIVATE, type, name);
}
@Override
public JavaWriter privateFinal(String type, String name, String value) throws IOException {
return field(PRIVATE, type, name, value);
}
@Override
public JavaWriter privateStaticFinal(String type, String name, String value) throws IOException {
return field(PRIVATE_STATIC_FINAL, type, name, value);
@ -343,6 +353,16 @@ public final class JavaWriter implements Appendable, CodeWriter{
public JavaWriter protectedField(String type, String name) throws IOException {
return field(PROTECTED, type, name);
}
@Override
public JavaWriter protectedFinal(String type, String name) throws IOException {
return field(PROTECTED, type, name);
}
@Override
public JavaWriter protectedFinal(String type, String name, String value) throws IOException {
return field(PROTECTED, type, name, value);
}
@Override
public JavaWriter publicField(String type, String name) throws IOException {