//package com.fs.core.config;
//
//import org.springframework.boot.context.config.ConfigData;
//import org.springframework.boot.context.config.ConfigDataLoader;
//import org.springframework.boot.context.config.ConfigDataLoaderContext;
//import org.springframework.boot.context.config.ConfigDataResource;
//import org.springframework.boot.context.config.ConfigDataResourceNotFoundException;
//import org.springframework.core.io.Resource;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//import org.springframework.core.io.support.ResourcePatternResolver;
//import org.springframework.util.StringUtils;
//
//import java.io.IOException;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.List;
//
//public class WildcardClasspathConfigDataLoader implements ConfigDataLoader<WildcardClasspathConfigDataLoader.WildcardResource> {
//
//    private static final ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
//
//    @Override
//    public ConfigData load(ConfigDataLoaderContext context, WildcardResource resource) {
//        try {
//            List<Resource> resources = resolveResources(resource.getPattern());
//            if (resources.isEmpty()) {
//                throw new ConfigDataResourceNotFoundException(resource);
//            }
//
//            ConfigData.Builder builder = new ConfigData.Builde();
//            for (Resource res : resources) {
//                builder = builder.with(res, new DefaultConfigDataResource(res));
//            }
//            return builder.build();
//        } catch (IOException e) {
//            throw new IllegalStateException("Failed to load config resources: " + resource, e);
//        }
//    }
//
//    private List<Resource> resolveResources(String pattern) throws IOException {
//        Resource[] resources = resolver.getResources(pattern);
//        return Arrays.asList(resources);
//    }
//
//    public static class WildcardResource extends ConfigDataResource {
//        private final String pattern;
//
//        public WildcardResource(String pattern) {
//            this.pattern = pattern;
//        }
//
//        public String getPattern() {
//            return pattern;
//        }
//
//        @Override
//        public boolean equals(Object obj) {
//            return obj instanceof WildcardResource
//                    && this.pattern.equals(((WildcardResource) obj).pattern);
//        }
//
//        @Override
//        public int hashCode() {
//            return pattern.hashCode();
//        }
//
//        @Override
//        public String toString() {
//            return "WildcardClasspathResource [pattern='" + pattern + "']";
//        }
//    }
//
//    public static class DefaultConfigDataResource extends ConfigDataResource {
//        private final Resource resource;
//
//        public DefaultConfigDataResource(Resource resource) {
//            this.resource = resource;
//        }
//
//        public Resource getResource() {
//            return resource;
//        }
//    }
//}