com.botronsoft.cmj.spitools.impl.transformation.SingleValueArgumentProcessor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of configuration-manager-spi-tools Show documentation
Show all versions of configuration-manager-spi-tools Show documentation
Configuration Manager Service Provider Interface Tools
package com.botronsoft.cmj.spitools.impl.transformation;
import java.util.Optional;
import org.apache.log4j.Logger;
import com.botronsoft.cmj.spi.configuration.ExportContext;
import com.botronsoft.cmj.spi.configuration.ImportContext;
import com.botronsoft.cmj.spitools.impl.transformation.configuration.Configuration;
import com.botronsoft.cmj.spitools.impl.transformation.parsers.SingleValueArgumentParser;
import com.botronsoft.cmj.spitools.impl.transformation.transformers.ArgumentTransformer;
class SingleValueArgumentProcessor implements ArgumentProcessor {
private static final Logger log = Logger.getLogger(SingleValueArgumentProcessor.class);
private final Configuration configuration;
private final SingleValueArgumentParser singleValueParser;
private final ArgumentTransformer transformer;
SingleValueArgumentProcessor(Configuration configuration, SingleValueArgumentParser singleValueParser,
ArgumentTransformer transformer) {
this.configuration = configuration;
this.singleValueParser = singleValueParser;
this.transformer = transformer;
}
@Override
public String processArgumentForExport(String value, ExportContext exportContext) {
Optional valueOptional = singleValueParser.parse(value, configuration);
if (!valueOptional.isPresent()) {
log.debug(String.format("Ignoring value for argument '%s': '%s'", configuration.getArgumentName(), value));
return value;
}
return transformer.transformArgumentForExport(value, configuration, exportContext.getReferenceCollector());
}
@Override
public String processArgumentForImport(String value, ImportContext importContext) {
Optional valueOptional = singleValueParser.parse(value, configuration);
if (!valueOptional.isPresent()) {
log.debug(String.format("Ignoring value for argument '%s': '%s'", configuration.getArgumentName(), value));
return value;
}
return transformer.transformArgumentForImport(value, configuration, importContext.getReferenceLookup());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy