pro.verron.officestamper.experimental.PowerpointCollector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of engine Show documentation
Show all versions of engine Show documentation
Office-stamper is a Java template engine for docx documents, forked from org.wickedsource.docx-stamper
The newest version!
package pro.verron.officestamper.experimental;
import java.util.ArrayList;
import java.util.List;
/**
* The PowerpointCollector class is used to collect instances of a specific class in a PowerPoint presentation.
*
* @param the type of instances to collect
*/
public class PowerpointCollector
extends PowerpointVisitor {
private final Class aClass;
private final List list = new ArrayList<>();
/**
* The PowerpointCollector class is used to collect instances of a specific class in a PowerPoint presentation.
*
* @param aClass the type of instances to collect
*/
public PowerpointCollector(Class aClass) {
this.aClass = aClass;
}
/**
* Collects instances of a specific class in a PowerPoint presentation.
*
* @param the type of instances to collect
* @param template the PowerPoint presentation template
* @param aClass the type of instances to collect
*
* @return a list of instances of the specified class
*/
public static List collect(
Object template,
Class aClass
) {
var collector = new PowerpointCollector<>(aClass);
collector.visit(template);
return collector.collect();
}
/**
* Retrieves the collected instances of a specific class.
*
* @return an instance list of the specified class
*/
public List collect() {
return list;
}
@Override
protected void before(Object object) {
if (aClass.isInstance(object))
list.add(aClass.cast(object));
}
}