package org.hamcrest.generator;
import java.io.IOException;
import java.io.PrintStream;
public class QuickReferenceWriter implements FactoryWriter {
private final PrintStream out;
private int columnPosition = 14;
public QuickReferenceWriter(PrintStream out) {
this.out = out;
}
public QuickReferenceWriter() {
this(System.out);
}
public void setColumnPosition(int columnPosition) {
this.columnPosition = columnPosition;
}
@Override
public void () throws IOException {
}
@Override
public void writeMethod(String generatedMethodName, FactoryMethod factoryMethod) throws IOException {
String actsOn = removePackageNames(factoryMethod.getGenerifiedType());
for (int i = actsOn.length(); i < columnPosition; i++) {
out.append(' ');
}
out.append('[').append(actsOn).append("] ");
out.append(generatedMethodName);
out.append('(');
boolean seenFirst = false;
for (FactoryMethod.Parameter parameter : factoryMethod.getParameters()) {
if (seenFirst) {
out.append(", ");
} else {
seenFirst = true;
}
out.append(removePackageNames(parameter.getType()));
out.append(' ');
out.append(parameter.getName());
}
out.append(')');
out.println();
}
private static String removePackageNames(String in) {
return in == null ? "" : in.replaceAll("[^<>]*\\.([^\\.])", "$1");
}
@Override
public void () throws IOException {
}
@Override
public void close() throws IOException {
}
@Override
public void flush() throws IOException {
}
}