diff --git a/archunit/src/main/java/com/tngtech/archunit/core/domain/ReverseDependencies.java b/archunit/src/main/java/com/tngtech/archunit/core/domain/ReverseDependencies.java index 007bce5dbd..fbcc7c7190 100644 --- a/archunit/src/main/java/com/tngtech/archunit/core/domain/ReverseDependencies.java +++ b/archunit/src/main/java/com/tngtech/archunit/core/domain/ReverseDependencies.java @@ -46,34 +46,20 @@ final class ReverseDependencies { private final SetMultimap instanceofCheckDependencies; private final Supplier> directDependenciesToClass; - private ReverseDependencies( - ImmutableSetMultimap fieldAccessDependencies, - ImmutableSetMultimap methodCallDependencies, - ImmutableSetMultimap constructorCallDependencies, - SetMultimap fieldTypeDependencies, - SetMultimap methodParameterTypeDependencies, - SetMultimap methodReturnTypeDependencies, - SetMultimap> methodsThrowsDeclarationDependencies, - SetMultimap constructorParameterTypeDependencies, - SetMultimap> constructorThrowsDeclarationDependencies, - SetMultimap> annotationTypeDependencies, - SetMultimap> annotationParameterTypeDependencies, - SetMultimap instanceofCheckDependencies, - List allDependencies) { - - accessToFieldCache = CacheBuilder.newBuilder().build(new ResolvingAccessLoader<>(fieldAccessDependencies)); - callToMethodCache = CacheBuilder.newBuilder().build(new ResolvingAccessLoader<>(methodCallDependencies)); - callToConstructorCache = CacheBuilder.newBuilder().build(new ConstructorCallLoader(constructorCallDependencies)); - this.fieldTypeDependencies = fieldTypeDependencies; - this.methodParameterTypeDependencies = methodParameterTypeDependencies; - this.methodReturnTypeDependencies = methodReturnTypeDependencies; - this.methodsThrowsDeclarationDependencies = methodsThrowsDeclarationDependencies; - this.constructorParameterTypeDependencies = constructorParameterTypeDependencies; - this.constructorThrowsDeclarationDependencies = constructorThrowsDeclarationDependencies; - this.annotationTypeDependencies = annotationTypeDependencies; - this.annotationParameterTypeDependencies = annotationParameterTypeDependencies; - this.instanceofCheckDependencies = instanceofCheckDependencies; - this.directDependenciesToClass = createDirectDependenciesToClassSupplier(allDependencies); + private ReverseDependencies(ReverseDependencies.Creation creation) { + accessToFieldCache = CacheBuilder.newBuilder().build(new ResolvingAccessLoader<>(creation.fieldAccessDependencies.build())); + callToMethodCache = CacheBuilder.newBuilder().build(new ResolvingAccessLoader<>(creation.methodCallDependencies.build())); + callToConstructorCache = CacheBuilder.newBuilder().build(new ConstructorCallLoader(creation.constructorCallDependencies.build())); + this.fieldTypeDependencies = creation.fieldTypeDependencies.build(); + this.methodParameterTypeDependencies = creation.methodParameterTypeDependencies.build(); + this.methodReturnTypeDependencies = creation.methodReturnTypeDependencies.build(); + this.methodsThrowsDeclarationDependencies = creation.methodsThrowsDeclarationDependencies.build(); + this.constructorParameterTypeDependencies = creation.constructorParameterTypeDependencies.build(); + this.constructorThrowsDeclarationDependencies = creation.constructorThrowsDeclarationDependencies.build(); + this.annotationTypeDependencies = creation.annotationTypeDependencies.build(); + this.annotationParameterTypeDependencies = creation.annotationParameterTypeDependencies.build(); + this.instanceofCheckDependencies = creation.instanceofCheckDependencies.build(); + this.directDependenciesToClass = createDirectDependenciesToClassSupplier(creation.allDependencies); } private static Supplier> createDirectDependenciesToClassSupplier(final List allDependencies) {