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

com.github.bootfastconfig.cache.AnnotationConfigCacheBuilder Maven / Gradle / Ivy

package com.github.bootfastconfig.cache;

import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.function.Function;

public class AnnotationConfigCacheBuilder implements CacheBuilder> {


    private final Set cacheSimpleConfigs;

    private final Function conversionFactory;

    public AnnotationConfigCacheBuilder(Set cacheSimpleConfigs) {
        this.cacheSimpleConfigs = cacheSimpleConfigs;
        this.conversionFactory = null;
    }

    public AnnotationConfigCacheBuilder(Set cacheSimpleConfigs, Function conversionFactory) {
        this.cacheSimpleConfigs = cacheSimpleConfigs;
        this.conversionFactory = conversionFactory;
    }

    public AnnotationConfigCacheBuilder setConversionFactory(Function conversionFactory) {

        return new AnnotationConfigCacheBuilder(this.cacheSimpleConfigs, conversionFactory);
    }

    @Override
    public List get() {
        if (conversionFactory == null) {
            return null;
        }
        List list = new LinkedList<>();
        for (CacheSimpleConfig cacheSimpleConfig : cacheSimpleConfigs) {
            T t = conversionFactory.apply(cacheSimpleConfig);
            if (t != null) {
                list.add(t);
            }
        }
        return list;
    }

    @Override
    public String getName() {
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy