com.payneteasy.superfly.client.TransformingActionDescriptionCollector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of superfly-client Show documentation
Show all versions of superfly-client Show documentation
Contains classes used to use Superfly facilities by clients
package com.payneteasy.superfly.client;
import java.util.List;
import com.payneteasy.superfly.api.ActionDescription;
import com.payneteasy.superfly.client.exception.CollectionException;
/**
* This implementation decorates another {@link ActionDescriptionCollector}
* implementation and transforms action names using transformers given to it.
*
* @author Roman Puchkovskiy
*/
public class TransformingActionDescriptionCollector implements
ActionDescriptionCollector {
private ActionDescriptionCollector collector;
private StringTransformer[] transformers;
public void setCollector(ActionDescriptionCollector collector) {
this.collector = collector;
}
public void setTransformers(StringTransformer[] transformers) {
this.transformers = transformers;
}
public List collect() throws CollectionException {
List list = collector.collect();
for (ActionDescription actionDescription : list) {
actionDescription.setName(applyTransformers(actionDescription.getName()));
}
return list;
}
protected String applyTransformers(String name) {
for (StringTransformer transformer : transformers) {
name = transformer.transform(name);
}
return name;
}
}