I'm trying to do an abstract class which has two methods, aggregate
and writeHeader
. Both methods calls a static method that have a Class<?>
parameter. It looks like this :
public abstract class AbstractExtractLineMapper<T extends BaseObject> implements LineAggregator<T>, FlatFileHeaderCallback {
@Override
public void writeHeader(Writer writer) throws IOException {
TreeSet<CSVdata> csvElements = CSVDataGenerator.loadCSVstructureFromAnnotations(CLASS<?> NEEDED);
[...]
writer.write(sb.toString());
}
@Override
public String aggregate(T object) {
TreeSet<CSVdata> csvElements = CSVDataGenerator.loadCSVstructureFromAnnotations(object.getClass());
[...]
return sb.toString();
}
}
For aggregate
, I have an instance of T, on which I can call getClass()
. But I cannot find a compiling code to replace Class<?> NEEDED
of my writeHeader
method. Please note that writeHeader
is called before aggregate
as it writes the header of the CSV file. In some cases, aggregate
will not be called at all (if CSV file to write has no lines, only header).
As some of you may have noticed, these interfaces are from the Spring framework (batch module), but I do not think this information is needed to answer.