All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.payneteasy.superfly.client.TransformingActionDescriptionCollector Maven / Gradle / Ivy

There is a newer version: 1.7-32
Show newest version
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;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy