Java源码示例:com.tngtech.archunit.core.importer.ImportOption

示例1
private Modules(ModulithMetadata metadata, Collection<String> packages, DescribedPredicate<JavaClass> ignored,
		boolean useFullyQualifiedModuleNames) {

	this.metadata = metadata;

	List<String> toImport = new ArrayList<>(packages);
	toImport.addAll(FRAMEWORK_PACKAGES);

	this.allClasses = new ClassFileImporter() //
			.withImportOption(new ImportOption.DoNotIncludeTests()) //
			.importPackages(toImport) //
			.that(not(ignored));

	Classes classes = Classes.of(allClasses);

	this.modules = packages.stream() //
			.flatMap(it -> getSubpackages(classes, it)) //
			.map(it -> new Module(it, useFullyQualifiedModuleNames)) //
			.collect(toMap(Module::getName, Function.identity()));

	this.rootPackages = packages.stream() //
			.map(it -> JavaPackage.of(classes, it).toSingle()) //
			.collect(Collectors.toList());

	this.sharedModules = Collections.emptySet();
}
 
示例2
@Test
void servicesAndRepositoriesShouldNotDependOnWebLayer() {

    JavaClasses importedClasses = new ClassFileImporter()
        .withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS)
        .importPackages("io.github.jhipster.online");

    noClasses()
        .that()
            .resideInAnyPackage("io.github.jhipster.online.service..")
        .or()
            .resideInAnyPackage("io.github.jhipster.online.repository..")
        .should().dependOnClassesThat()
            .resideInAnyPackage("..io.github.jhipster.online.web..")
    .because("Services and repositories should not depend on web layer")
    .check(importedClasses);
}
 
示例3
@Test
void servicesAndRepositoriesShouldNotDependOnWebLayer() {

    JavaClasses importedClasses = new ClassFileImporter()
        .withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS)
        .importPackages("io.github.jhipster.registry");

    noClasses()
        .that()
            .resideInAnyPackage("io.github.jhipster.registry.service..")
        .or()
            .resideInAnyPackage("io.github.jhipster.registry.repository..")
        .should().dependOnClassesThat()
            .resideInAnyPackage("..io.github.jhipster.registry.web..")
    .because("Services and repositories should not depend on web layer")
    .check(importedClasses);
}
 
示例4
@BeforeClass
public static void setUp() {
  classes = new ClassFileImporter()
    .withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS)
    .withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_ARCHIVES)
    .importPackages("com.company.app");
}
 
示例5
private ImportOptions onlyAppAndRuntime() {
    return new ImportOptions().with(new ImportOption() {
        @Override
        public boolean includes(Location location) {
            return location.contains("archunit")
                    || location.contains("/rt.jar")
                    || location.contains("java.base");
        }
    });
}
 
示例6
private synchronized void initialize() {
    if (javaClasses == null) {
        ImportOptions importOptions = new ImportOptions();
        for (Class<? extends ImportOption> optionClass : importOptionTypes) {
            importOptions = importOptions.with(newInstanceOf(optionClass));
        }
        javaClasses = cacheClassFileImporter.importClasses(importOptions, locations);
    }
}
 
示例7
private ImportOptions onlyAppAndRuntime() {
    return new ImportOptions().with(new ImportOption() {
        @Override
        public boolean includes(Location location) {
            return location.contains("archunit")
                    || location.contains("/rt.jar")
                    || location.contains("java.base");
        }
    });
}
 
示例8
@BeforeAll
static void init() {
    classes = new ClassFileImporter()
            .withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS)
            .importPackages("study.huhao.demo");
}
 
示例9
@Override
public Class<? extends ImportOption>[] getImportOptions() {
    return analyzeClasses.importOptions();
}
 
示例10
@Override
public Class<? extends ImportOption>[] getImportOptions() {
    return analyzeClasses.importOptions();
}
 
示例11
private LazyJavaClasses(Set<Location> locations, Set<Class<? extends ImportOption>> importOptionTypes) {
    this.locations = locations;
    this.importOptionTypes = importOptionTypes;
}
 
示例12
private LocationsKey(Class<? extends ImportOption>[] importOptionTypes, Set<Location> locations) {
    this.importOptionTypes = ImmutableSet.copyOf(importOptionTypes);
    this.locations = locations;
}
 
示例13
private All(Class<? extends ImportOption>[] importOptions) {
    this.importOptions = importOptions;
}
 
示例14
@Override
public Class<? extends ImportOption>[] getImportOptions() {
    return importOptions;
}
 
示例15
@SafeVarargs
final TestAnalysisRequest withImportOptions(Class<? extends ImportOption>... importOptions) {
    this.importOptions = importOptions;
    return this;
}
 
示例16
Class<? extends ImportOption>[] getImportOptions();