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

com.arextest.schedule.comparer.converter.CompareItemConvertFactory Maven / Gradle / Ivy

There is a newer version: 2.0.4
Show newest version
package com.arextest.schedule.comparer.converter;

import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class CompareItemConvertFactory {
  private final Map categoryConverters;
  @Resource
  private CompareItemConverter defaultCompareItemConverterImpl;

  public CompareItemConvertFactory(@Autowired List converters) {
    this.categoryConverters = converters.stream().filter(c -> StringUtils.isNotBlank(c.getCategoryName()))
        .collect(Collectors.toMap(CompareItemConverter::getCategoryName, Function.identity()));
  }

  public CompareItemConverter getConvert(String categoryName) {
    return categoryConverters.getOrDefault(categoryName, defaultCompareItemConverterImpl);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy