eu.solven.cleanthat.engine.ASourceCodeFormatterFactory Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2023 Benoit Lacelle - SOLVEN
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package eu.solven.cleanthat.engine;
import java.util.Set;
import java.util.stream.Collectors;
import eu.solven.cleanthat.config.ConfigHelpers;
import eu.solven.cleanthat.config.pojo.CleanthatStepProperties;
import eu.solven.cleanthat.config.pojo.ICleanthatStepParametersProperties;
/**
* Abstract class for language formatters
*
* @author Benoit Lacelle
*/
public abstract class ASourceCodeFormatterFactory implements IEngineLintFixerFactory {
final ConfigHelpers configHelpers;
public ASourceCodeFormatterFactory(ConfigHelpers configHelpers) {
this.configHelpers = configHelpers;
}
public T convertValue(Object input, Class clazz) {
return configHelpers.getObjectMapper().convertValue(input, clazz);
}
public ConfigHelpers getConfigHelpers() {
return configHelpers;
}
protected ICleanthatStepParametersProperties getParameters(CleanthatStepProperties rawProcessor) {
return rawProcessor.getParameters();
}
@Override
public Set getDefaultIncludes() {
return getMainSteps().stream().flatMap(s -> s.getDefaultIncludes().stream()).collect(Collectors.toSet());
}
}