Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.tvd12.reflections.util;
import java.net.URL;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.function.Predicate;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.tvd12.reflections.Configuration;
import com.tvd12.reflections.Reflections;
import com.tvd12.reflections.ReflectionsException;
import com.tvd12.reflections.adapters.JavaReflectionAdapter;
import com.tvd12.reflections.adapters.JavassistAdapter;
import com.tvd12.reflections.adapters.MetadataAdapter;
import com.tvd12.reflections.concurrent.ThreadFactoryBuilder;
import com.tvd12.reflections.scanners.Scanner;
import com.tvd12.reflections.scanners.SubTypesScanner;
import com.tvd12.reflections.scanners.TypeAnnotationsScanner;
import com.tvd12.reflections.serializers.Serializer;
import com.tvd12.reflections.serializers.XmlSerializer;
/**
* a fluent builder for {@link com.tvd12.reflections.Configuration}, to be used for constructing a {@link com.tvd12.reflections.Reflections} instance
*
usage:
*
* new Reflections(
* new ConfigurationBuilder()
* .filterInputsBy(new FilterBuilder().include("your project's common package prefix here..."))
* .setUrls(ClasspathHelper.forClassLoader())
* .setScanners(new SubTypesScanner(), new TypeAnnotationsScanner().filterResultsBy(myClassAnnotationsFilter)));
*
* {@link #executorService} is used optionally used for parallel scanning. if value is null then scanning is done in a simple for loop
*
defaults: accept all for {@link #inputsFilter},
* {@link #executorService} is null,
* {@link #serializer} is {@link com.tvd12.reflections.serializers.XmlSerializer}
*/
/*lazy*/ @SuppressWarnings("rawtypes")
public class ConfigurationBuilder implements Configuration {
@Nonnull private Set scanners;
@Nonnull private Set urls;
protected MetadataAdapter metadataAdapter;
@Nullable private Predicate inputsFilter;
/*lazy*/ private Serializer serializer;
@Nullable private ExecutorService executorService;
@Nullable private ClassLoader[] classLoaders;
private boolean expandSuperTypes = true;
public ConfigurationBuilder() {
scanners = Sets.newHashSet(new TypeAnnotationsScanner(), new SubTypesScanner());
urls = Sets.newHashSet();
}
/** constructs a {@link ConfigurationBuilder} using the given parameters, in a non statically typed way.
* that is, each element in {@code params} is guessed by it's type and populated into the configuration.
*
*
{@link String} - add urls using {@link ClasspathHelper#forPackage(String, ClassLoader...)} ()}
*
{@link Class} - add urls using {@link ClasspathHelper#forClass(Class, ClassLoader...)}
*
{@link ClassLoader} - use these classloaders in order to find urls in ClasspathHelper.forPackage(), ClasspathHelper.forClass() and for resolving types
*
{@link Scanner} - use given scanner, overriding the default scanners
*
{@link URL} - add the given url for scanning
*
{@code Object[]} - flatten and use each element as above
*
*
* an input {@link FilterBuilder} will be set according to given packages.
*
use any parameter type in any order. this constructor uses instanceof on each param and instantiate a {@link ConfigurationBuilder} appropriately.
* */
@SuppressWarnings("unchecked")
public static ConfigurationBuilder build(final @Nullable Object... params) {
ConfigurationBuilder builder = new ConfigurationBuilder();
//flatten
List