Showing preview only (647K chars total). Download the full file or copy to clipboard to get everything.
Repository: beworker/magnet
Branch: master
Commit: f60e84a1f7b4
Files: 378
Total size: 18.0 MB
Directory structure:
gitextract_enrgbkx0/
├── .editorconfig
├── .github/
│ ├── stale.yml
│ └── workflows/
│ └── android.yml
├── .gitignore
├── .project
├── .settings/
│ └── org.eclipse.buildship.core.prefs
├── CHANGELOG.md
├── LICENSE
├── README.md
├── build.gradle
├── documentation/
│ └── diagrams/
│ └── design.graphml
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── magnet/
│ ├── build.gradle
│ ├── gradle.properties
│ └── src/
│ ├── main/
│ │ └── java/
│ │ └── magnet/
│ │ ├── Classifier.java
│ │ ├── Factory.java
│ │ ├── Instance.java
│ │ ├── Magnet.java
│ │ ├── Registry.java
│ │ ├── Scope.java
│ │ ├── Scoping.java
│ │ ├── SelectorFilter.java
│ │ ├── Visitor.java
│ │ └── internal/
│ │ ├── FactoryFilter.java
│ │ ├── Generated.java
│ │ ├── ImmutableArrayList.java
│ │ ├── Index.java
│ │ ├── InstanceBucket.java
│ │ ├── InstanceFactory.java
│ │ ├── InstanceManager.java
│ │ ├── InternalFactory.java
│ │ ├── MagnetInstanceManager.java
│ │ ├── MagnetScope.java
│ │ └── Range.java
│ └── test/
│ ├── java/
│ │ └── magnet/
│ │ └── internal/
│ │ ├── FactoryFilter_MagnetInstanceManagerTest.java
│ │ ├── FactoryFilter_MagnetScopeTest.java
│ │ ├── InstanceBucketTest.java
│ │ ├── InstrumentedScope.java
│ │ ├── MagnetInstanceManagerTest.java
│ │ ├── MagnetScope_CircularDependencyTest.java
│ │ ├── MagnetScope_DisposeTest.java
│ │ ├── MagnetScope_FindDeepForSiblingTypesTest.java
│ │ ├── MagnetScope_GetManyTest.java
│ │ ├── MagnetScope_ManyInstancesInMultipleScopesTest.java
│ │ ├── MagnetScope_RegisterAndGetTest.java
│ │ ├── MagnetScope_SiblingTypesTest.java
│ │ ├── MagnetScopingDirectTest.java
│ │ ├── MagnetScopingNoneTest.java
│ │ ├── MagnetScopingTopmostDependsOnDirectTest.java
│ │ ├── MagnetScopingTopmostDependsOnTopmostTest.java
│ │ ├── MagnetScopingTopmostDependsOnUnscopedTest.java
│ │ ├── Scope_GetManyAnySiblingTypesTest_Issue95.java
│ │ ├── Scope_LimitDirectScoping_DependencyInNonReachableChildScopeTest.java
│ │ ├── Scope_LimitDirectScoping_InstanceWithDependencyTest.java
│ │ ├── Scope_LimitDirectScoping_SingleInstanceTest.java
│ │ ├── Scope_LimitTest.java
│ │ ├── Scope_LimitWithDependencyTest.java
│ │ ├── VisitInstancesTest.java
│ │ ├── VisitScopesTest.java
│ │ ├── events/
│ │ │ ├── ObservableScopeVisitor.java
│ │ │ ├── OnEnterScope.java
│ │ │ ├── OnExitScope.java
│ │ │ └── OnInstance.java
│ │ └── observer/
│ │ ├── ScopeObserver.java
│ │ └── ScopeValidator.java
│ └── resources/
│ └── mockito-extensions/
│ └── org.mockito.plugins.MockMaker
├── magnet-kotlin/
│ ├── build.gradle
│ ├── gradle.properties
│ └── src/
│ ├── main/
│ │ └── java/
│ │ └── magnet/
│ │ ├── MagnetExt.kt
│ │ ├── ScopeExt.kt
│ │ └── internal/
│ │ ├── ManyLazy.kt
│ │ ├── OptionalLazy.kt
│ │ └── SingleLazy.kt
│ └── test/
│ └── java/
│ └── magnet/
│ └── kotlin/
│ ├── ScopeExtTest.kt
│ └── internal/
│ ├── ManyLazyTest.kt
│ ├── OptionalLazyTest.kt
│ └── SingleLazyTest.kt
├── magnet-processor/
│ ├── build.gradle
│ ├── gradle.properties
│ ├── libs/
│ │ └── tools.jar
│ └── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── magnet/
│ │ │ └── processor/
│ │ │ ├── MagnetProcessor.kt
│ │ │ ├── common/
│ │ │ │ ├── AptUtils.kt
│ │ │ │ └── KotlinMethodMetadata.kt
│ │ │ ├── instances/
│ │ │ │ ├── FactoryTypeModel.kt
│ │ │ │ ├── InstanceProcessor.kt
│ │ │ │ ├── aspects/
│ │ │ │ │ ├── classifier/
│ │ │ │ │ │ └── ClassifierAttributeParser.kt
│ │ │ │ │ ├── disabled/
│ │ │ │ │ │ └── DisabledAttributeParser.kt
│ │ │ │ │ ├── disposer/
│ │ │ │ │ │ ├── DisposeMethodGenerator.kt
│ │ │ │ │ │ ├── DisposerAttributeParser.kt
│ │ │ │ │ │ ├── DisposerValidator.kt
│ │ │ │ │ │ └── IsDisposableMethodGenerator.kt
│ │ │ │ │ ├── factory/
│ │ │ │ │ │ ├── CreateMethodGenerator.kt
│ │ │ │ │ │ ├── CustomFactoryCreateMethodGenerator.kt
│ │ │ │ │ │ ├── FactoryAttributeParser.kt
│ │ │ │ │ │ └── StandardFactoryCreateMethodGenerator.kt
│ │ │ │ │ ├── index/
│ │ │ │ │ │ └── FactoryIndexCodeGenerator.kt
│ │ │ │ │ ├── limitedto/
│ │ │ │ │ │ ├── GetLimitMethodGenerator.kt
│ │ │ │ │ │ ├── LimitedToAttributeParser.kt
│ │ │ │ │ │ └── LimitedToValidator.kt
│ │ │ │ │ ├── scoping/
│ │ │ │ │ │ ├── GetScopingMethodGenerator.kt
│ │ │ │ │ │ └── ScopingAttributeParser.kt
│ │ │ │ │ ├── selector/
│ │ │ │ │ │ ├── GetSelectorMethodGenerator.kt
│ │ │ │ │ │ └── SelectorAttributeParser.kt
│ │ │ │ │ ├── siblings/
│ │ │ │ │ │ └── GetSiblingTypesMethodGenerator.kt
│ │ │ │ │ └── type/
│ │ │ │ │ ├── TypeAndTypesValidator.kt
│ │ │ │ │ ├── TypeAttributeParser.kt
│ │ │ │ │ └── TypesAttributeParser.kt
│ │ │ │ ├── generator/
│ │ │ │ │ ├── CodeGenerator.kt
│ │ │ │ │ ├── CodeWriter.kt
│ │ │ │ │ └── FactoryTypeCodeGenerator.kt
│ │ │ │ └── parser/
│ │ │ │ ├── AspectValidator.kt
│ │ │ │ ├── AttributeParser.kt
│ │ │ │ ├── InstanceParser.kt
│ │ │ │ ├── InstanceParserForClass.kt
│ │ │ │ ├── InstanceParserForMethod.kt
│ │ │ │ └── ParserInstance.kt
│ │ │ └── registry/
│ │ │ ├── Model.kt
│ │ │ ├── RegistryGenerator.kt
│ │ │ ├── RegistryParser.kt
│ │ │ ├── RegistryProcessor.kt
│ │ │ └── instances/
│ │ │ ├── IndexGeneratorVisitor.kt
│ │ │ ├── Indexer.kt
│ │ │ ├── InstanceIndexGenerator.kt
│ │ │ ├── Model.kt
│ │ │ └── SectionsCreatorVisitor.kt
│ │ └── resources/
│ │ └── META-INF/
│ │ ├── gradle/
│ │ │ └── incremental.annotation.processors
│ │ └── services/
│ │ └── javax.annotation.processing.Processor
│ └── test/
│ ├── java/
│ │ └── magnet/
│ │ └── processor/
│ │ ├── GenerateRegistryForInstanceFactoriesTest.kt
│ │ ├── IndexerTest.kt
│ │ ├── InstanceCustomFactoryProcessorTest.kt
│ │ ├── InstanceDisposerTest.kt
│ │ ├── InstanceIndexProcessorTest.kt
│ │ ├── MagnetProcessorFactoryNamesTest.kt
│ │ ├── MagnetProcessorTest.kt
│ │ ├── SelectorInFactoryClassTest.kt
│ │ └── SiblingTypesTest.kt
│ └── resources/
│ ├── GenerateRegistryForInstanceFactoriesTest/
│ │ ├── App.java
│ │ ├── Implementation1.java
│ │ ├── Implementation3_1.java
│ │ ├── Implementation3_2.java
│ │ ├── Implementation4_1.java
│ │ ├── Implementation4_2.java
│ │ ├── Implementation5_1.java
│ │ ├── Implementation5_2.java
│ │ ├── Implementation6_1.java
│ │ ├── Implementation6_2.java
│ │ ├── Interface1.java
│ │ ├── Interface3.java
│ │ ├── Interface4.java
│ │ ├── Interface5.java
│ │ ├── Interface6_1.java
│ │ ├── Interface6_2.java
│ │ ├── Interface7.java
│ │ └── expected/
│ │ ├── MagnetIndexer1.java
│ │ ├── MagnetIndexer2.java
│ │ ├── MagnetIndexer3.java
│ │ ├── MagnetIndexer4.java
│ │ ├── MagnetIndexer5.java
│ │ ├── MagnetIndexer6.java
│ │ └── MagnetIndexer7.java
│ ├── InstanceCustomFactoryProcessorTest/
│ │ ├── CustomFactory1.java
│ │ ├── CustomFactory2.java
│ │ ├── CustomFactory3.java
│ │ ├── Implementation1.java
│ │ ├── Implementation2.java
│ │ ├── Implementation3.java
│ │ ├── Interface1.java
│ │ ├── Interface2.java
│ │ ├── Interface3.java
│ │ └── expected/
│ │ ├── Implementation1MagnetFactory.java
│ │ ├── Implementation2MagnetFactory.java
│ │ └── Implementation3MagnetFactory.java
│ ├── InstanceDisposerTest/
│ │ ├── Implementation1.java
│ │ ├── Implementation2.java
│ │ ├── Implementation3.java
│ │ ├── Implementation4.java
│ │ ├── Implementation5.java
│ │ ├── Interface.java
│ │ └── expected/
│ │ └── Implementation1MagnetFactory.java
│ ├── InstanceIndexProcessorTest/
│ │ ├── Implementation1.java
│ │ ├── Implementation2.java
│ │ ├── Interface1.java
│ │ ├── Interface2.java
│ │ └── generated/
│ │ ├── app_test_Implementation1MagnetFactory.java
│ │ └── app_test_Implementation2MagnetFactory.java
│ ├── MagnetProcessorFactoryNamesTest/
│ │ ├── Delegate1.java
│ │ ├── Interface1.java
│ │ └── generated/
│ │ ├── Delegate1MagnetFactory.java
│ │ └── Interface1DelegateMagnetFactory.java
│ ├── MagnetProcessorTest/
│ │ ├── AppExtensionRegistry.java
│ │ ├── Constructor_PackagePrivate_PackagePrivate/
│ │ │ └── UnderTest.java
│ │ ├── Constructor_PackagePrivate_Private/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── Constructor_Private/
│ │ │ └── UnderTest.java
│ │ ├── Constructor_Protected/
│ │ │ └── UnderTest.java
│ │ ├── Constructor_Public_PackagePrivate/
│ │ │ └── UnderTest.java
│ │ ├── Constructor_Public_Private/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── Constructor_Public_Protected/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── Constructor_Public_Public/
│ │ │ └── UnderTest.java
│ │ ├── Constructor_Public_Public_Kotlin/
│ │ │ └── UnderTest.java
│ │ ├── Covariance_Constructor_ManyParameter/
│ │ │ ├── Foo.java
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── Covariance_Constructor_SingleParameter/
│ │ │ ├── Foo.java
│ │ │ └── UnderTest.java
│ │ ├── DefaultArguments_JvmOverloads_AtTheEnd/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── DefaultArguments_JvmOverloads_InTheMiddle/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── DefaultArguments_JvmOverloads_Mixed/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── DisabledTab.java
│ │ ├── Executor.java
│ │ ├── ExecutorImpl.java
│ │ ├── ExecutorMaster.java
│ │ ├── Generics_GetOptional_Unchecked/
│ │ │ ├── Dependency.java
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── Generics_GetSingle_Unchecked/
│ │ │ ├── Dependency.java
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── Generics_ProvideTypeWithParameter/
│ │ │ ├── Parameter.java
│ │ │ ├── Type.java
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestProvideTypeMagnetFactory.java
│ │ ├── Generics_ProvideTypeWithParameter_NoClassifier/
│ │ │ ├── Parameter.java
│ │ │ ├── Type.java
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestProvideTypeMagnetFactory.java
│ │ ├── HomePage.java
│ │ ├── HomePageMenuItem.java
│ │ ├── HomePageNoParams.java
│ │ ├── HomePageWithClassifierParams.java
│ │ ├── HomePageWithGenericParam.java
│ │ ├── HomePageWithManyParameterizedParams.java
│ │ ├── HomePageWithManyParameterizedWildcardInParams.java
│ │ ├── HomePageWithManyParameterizedWildcardKnownParams.java
│ │ ├── HomePageWithManyParameterizedWildcardOutParams.java
│ │ ├── HomePageWithManyParams.java
│ │ ├── HomePageWithManyWildcardParams.java
│ │ ├── HomePageWithParams.java
│ │ ├── HomePageWithScope.java
│ │ ├── HomePageWithStaticConstructor.java
│ │ ├── HomePageWithStaticConstructorDisabled.java
│ │ ├── HomePageWithStaticConstructorSingle.java
│ │ ├── HomeRepository.java
│ │ ├── Lazy_Constructor_ManyParameter/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── Lazy_Constructor_ManyParameter_NullableGenericType/
│ │ │ └── UnderTest.java
│ │ ├── Lazy_Constructor_ManyParameter_NullableListType/
│ │ │ └── UnderTest.java
│ │ ├── Lazy_Constructor_ManyParameter_Wildcard/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── Lazy_Constructor_NoKotlinMetadata/
│ │ │ └── UnderTest.java
│ │ ├── Lazy_Constructor_OptionalParameter/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── Lazy_Constructor_OptionalParameter_Wildcard/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── Lazy_Constructor_SingleParameter/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── Lazy_Constructor_SingleParameter_ParameterizedType/
│ │ │ ├── Foo.java
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── Lazy_Constructor_SingleParameter_Wildcard/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── Lazy_Method_NoKotlinMetadata/
│ │ │ └── UnderTest.java
│ │ ├── Lazy_Method_OptionalParameter/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestProvideUnderTestDepMagnetFactory.java
│ │ ├── Lazy_Method_OptionalParameter_Wildcard/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestProvideUnderTestDepMagnetFactory.java
│ │ ├── Lazy_Method_SingleParameter/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestProvideUnderTestDepMagnetFactory.java
│ │ ├── Lazy_Method_SingleParameter_Wildcard/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestProvideUnderTestDepMagnetFactory.java
│ │ ├── Limit_Empty_NoGetter/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── Limit_NotEmpty_HasGetter/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── Limit_ReservedAsterisks_Fails/
│ │ │ └── UnderTest.java
│ │ ├── Limit_ScopingDirect_GeneratesGetter/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── Limit_ScopingUnscoped_Fails/
│ │ │ └── UnderTest.java
│ │ ├── MenuItem.java
│ │ ├── Page.java
│ │ ├── ScopeParameter_CustomName/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── ScopeParameter_CustomName_KotlinClass/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── ScopeParameter_DefaultName/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── StaticMethodNeedsDependencyWithClassifier/
│ │ │ ├── Constants.java
│ │ │ ├── Input.java
│ │ │ ├── Output.java
│ │ │ ├── StaticFunction.java
│ │ │ └── generated/
│ │ │ └── StaticFunctionProvideInputMagnetFactory.java
│ │ ├── StaticMethodProvidesInnerClass/
│ │ │ ├── PowerManager.java
│ │ │ ├── PowerManagerProvider.java
│ │ │ └── expected/
│ │ │ └── PowerManagerProviderProvideWakeLockMagnetFactory.java
│ │ ├── Tab.java
│ │ ├── TypeAutoDetect_ExtendsObjectNoInterfaces/
│ │ │ ├── UnderTest.java
│ │ │ └── expected/
│ │ │ └── UnderTestMagnetFactory.java
│ │ ├── UnimplementedTab.java
│ │ ├── UserData.java
│ │ ├── UserPage.java
│ │ ├── UserPageMenuItem.java
│ │ ├── WorkProcessor.java
│ │ └── generated/
│ │ ├── ForInterfaceWithGenericType_ExecutorMagnetFactory.java
│ │ ├── HomePageMagnetFactory.java
│ │ ├── HomePageNoParamsMagnetFactory.java
│ │ ├── HomePageWithClassifierParamsMagnetFactory.java
│ │ ├── HomePageWithManyParameterizedParamsMagnetFactory.java
│ │ ├── HomePageWithManyParameterizedWildcardInParamsMagnetFactory.java
│ │ ├── HomePageWithManyParameterizedWildcardKnownParamsMagnetFactory.java
│ │ ├── HomePageWithManyParameterizedWildcardOutParamsMagnetFactory.java
│ │ ├── HomePageWithManyParamsMagnetFactory.java
│ │ ├── HomePageWithManyWildcardParamsMagnetFactory.java
│ │ ├── HomePageWithParamsMagnetFactory.java
│ │ ├── HomePageWithScopeMagnetFactory.java
│ │ └── HomePageWithStaticConstructorSingleCreateRepositoriesMagnetFactory.java
│ ├── SelectorInFactoryClassTest/
│ │ ├── Implementation1.java
│ │ ├── Implementation10.java
│ │ ├── Implementation2.java
│ │ ├── Implementation3.java
│ │ ├── Implementation4.java
│ │ ├── Implementation5.java
│ │ ├── Implementation6.java
│ │ ├── Implementation7.java
│ │ ├── Implementation8.java
│ │ ├── Implementation9.java
│ │ ├── Interface.java
│ │ └── generated/
│ │ ├── Implementation10MagnetFactory.java
│ │ ├── Implementation1MagnetFactory.java
│ │ ├── Implementation7MagnetFactory.java
│ │ ├── Implementation8MagnetFactory.java
│ │ └── Implementation9MagnetFactory.java
│ └── SiblingTypesTest/
│ ├── Implementation1.java
│ ├── Implementation2.java
│ ├── Implementation3.java
│ ├── Implementation4.java
│ ├── Implementation5.java
│ ├── Interface1.java
│ ├── Interface2.java
│ └── generated/
│ ├── Implementation4Interface1MagnetFactory.java
│ └── Implementation4Interface2MagnetFactory.java
├── magnetx-app/
│ ├── build.gradle
│ ├── gradle.properties
│ └── src/
│ └── main/
│ └── kotlin/
│ └── magnetx/
│ └── AppExtension.kt
├── magnetx-app-rx3android/
│ ├── build.gradle
│ ├── gradle.properties
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ └── java/
│ └── magnetx/
│ └── RxAndroidAppExtension.kt
├── magnetx-app-rxandroid/
│ ├── build.gradle
│ ├── gradle.properties
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ └── java/
│ └── magnetx/
│ └── RxAndroidAppExtension.kt
├── magnetx-app-stetho/
│ ├── build.gradle
│ ├── gradle.properties
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ └── java/
│ └── magnetx/
│ └── app/
│ └── stetho/
│ └── StethoAppExtension.kt
├── magnetx-app-stetho-scope/
│ ├── build.gradle
│ ├── gradle.properties
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ └── java/
│ └── magnetx/
│ └── app/
│ └── stetho/
│ └── scope/
│ ├── ScopeDumper.kt
│ ├── StethoScopeDumpPlugin.kt
│ └── StethoScopeInitializer.kt
├── magnetx-selector-android/
│ ├── build.gradle
│ ├── gradle.properties
│ └── src/
│ └── main/
│ └── kotlin/
│ └── magnetx/
│ └── AndroidSelectorFilter.kt
├── magnetx-selector-features/
│ ├── build.gradle
│ ├── gradle.properties
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ └── java/
│ └── magnetx/
│ └── FeaturesSelectorFilter.kt
└── settings.gradle
================================================
FILE CONTENTS
================================================
================================================
FILE: .editorconfig
================================================
[*.{kt,kts}]
disabled_rules=import-ordering
================================================
FILE: .github/stale.yml
================================================
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 30
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- bug
- enhancement
- help wanted
# Label to use when marking an issue as stale
staleLabel: wontfix
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
================================================
FILE: .github/workflows/android.yml
================================================
name: Build Magnet
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
================================================
FILE: .gitignore
================================================
out/
build/
captures/
classes/
reports/
library/.idea/
.idea/
.gradle/
.navigation/
*.iml
.DS_Store
local.properties
================================================
FILE: .project
================================================
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>magnet</name>
<comment>Project magnet created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<filteredResources>
<filter>
<id>1626289350744</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
================================================
FILE: .settings/org.eclipse.buildship.core.prefs
================================================
arguments=
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home
jvm.arguments=
offline.mode=false
override.workspace.settings=true
show.console.view=true
show.executions.view=true
================================================
FILE: CHANGELOG.md
================================================
# Changelog
## 3.8 (release) - 2023.03.27
- Same as 3.8 (snapshot)
## 3.8 (snapshot) - 2023.01.20
- Bump versions:
- Kotlin 1.8.0
- Kotlin Metadata JVM 0.6.0
## 3.7 (release) - 2023.01.20
- Same as 3.7 (snapshot)
## 3.7 (snapshot) - 2022.08.13
- Bump versions:
- Kotlin 1.7.10
- Android Gradle Plugin (AGP) 7.2.0
- Stetho 1.6.0
- Kotlin Metadata JVM 0.5.0
## 3.6 (release) - 2022.08.13
- Migrate to Kotlin 1.6.21, Java 11 and AGP 7.0.4.
- Add `Scope.isDisposed()` method.
- Remove `magnetx-app-leakcannary`. The extension is not needed anymore because the library has a
built-in ability to autostart.
- Fixed stetho extension
## 3.6-rc3 - 2022.05.13
- Fixed stetho extension
Final release version. Same as 3.6-rc3
## 3.6-rc1 (Renierit) - 2022.04.30
- Migrate to Kotlin 1.6.21, Java 11 and AGP 7.0.4.
- Add `Scope.isDisposed()` method.
- Remove `magnetx-app-leakcannary`. The extension is not needed anymore because the library has a
built-in ability to autostart.
## 3.5 (Pyrrhotite) - 2021.07.14
- Migrate to Kotlin 1.5.0
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2018 Sergej Shafarenka, www.halfbit.de
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: README.md
================================================
[](http://kotlinlang.org/)
[](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22de.halfbit%22%20a%3A%22magnet%22)

[](http://www.apache.org/licenses/LICENSE-2.0)
‼️ 27.01.2023: This project is not actively developed anymore ‼️
# 🧲 Magnet
Magnet is a concise, scope tree based Dependency Injection (DI) library designed for highly modular Android applications. It consists of two parts: an annotation processor (Kotlin) and a reflection free runtime library (Java + Kotlin).
# Design
Magnet defines and opetates on two core concepts: `Scopes` and `Instances`.
<img height="400" src="https://github.com/beworker/magnet/blob/master/documentation/images/readme-diagram.png" />
`Scope` is a container for instances. Scopes can be combined into a hierarchical tree by referencing parent scopes. The most top scope of the tree hierarchy, which has no parent scope, is called the root scope.
`Instance` is a concrete occurrence of an injected type. Instances can be allocated in scopes (scoped instances) or outside of scopes (unscoped instances).
# The Dependency Rule
Scopes depend on each other using the strong dependency rule - *scope dependency can only point towards its parent scope*. The dependency direction between two scopes enforces the direction of dependencies between instances allocated in those scopes. Instances allocated in a parent scope can know nothing about instances allocated in its child scopes. This simple design rule helps preventing memory leaks and allows safe disposal of child scopes and garbage collecting instances allocated there.
# Getting Started
In the example below we will compose a very naive `MediaPlayer` which loads media using a `MediaLoader` and then plays the media.
```kotlin
fun main() {
val rootScope = MagnetScope.createRootScope()
val playerScope = rootScope.createSubscope {
bind(Uri.parse("https://my-media-file"))
}
// mark 1
val mediaPlayer = playerScope.getSingle<MediaPlayer>()
mediaPlayer.playWhenReady()
// mark 2
Thread.sleep(5000)
playerScope.dispose()
// mark 3
}
// MediaPlayer.kt
interface MediaPlayer {
fun playWhenReady()
}
@Instance(type = MediaPlayer::class, disposer = "dispose")
internal class DefaultMediaPlayer(
private val assetId: Uri,
private val mediaLoader: MediaLoader
) : MediaPlayer {
override fun playWhenReady() { ... }
fun dispose() { ... }
}
// MediaLoader.kt
interface MediaLoader {
fun load(mediaUri: Uri): Single<Media>
}
@Instance(type = MediaLoader::class)
internal class DefaultMediaLoader() : MediaLoader {
override fun load(mediaUri: Uri): Single<Media> { ... }
}
```
The diagram below shows how Magnet manages the scope hierarchy when different marks of the main function are reached.
At `Mark 1`, two scopes are created and the `Uri` instance gets bound into the `playerScope`.
<img width="450" src="https://github.com/beworker/magnet/blob/master/documentation/images/readme-mark1.png" />
At `Mark 2`, `mediaPlayer` and `mediaLoader` instances get allocated in respective scopes. `mediaPlayer` is allocated in the `playerScope` because one of its dependencies, the `Uri`, is located in `playerScope`. Magnet cannot move `mediaPlayer` up to the `rootScope` because this would break the dependency rule described above. `mediaLoader` has no dependencies, that's why it is allocated in the `rootScope`. This instance allocation logic is specific to Magnet DI and is called auto-scoping. See developer documentation for more detail.
<img width="450" src="https://github.com/beworker/magnet/blob/master/documentation/images/readme-mark2.png" />
At `Mark 3`, the `playerScope` gets disposed and all its instances are garbage collected.
<img width="450" src="https://github.com/beworker/magnet/blob/master/documentation/images/readme-mark3.png" />
For more information refer to Magnet documentation.
# Documentation
1. [Developer Guide](https://www.halfbit.de/magnet/developer-guide/)
2. [Dependency auto-scoping](https://github.com/beworker/magnet/wiki/Dependency-auto-scoping)
3. [Scope Inspection](https://github.com/beworker/magnet/wiki/Scope-Inspection)
4. [How to Inject Android ViewModels](https://github.com/beworker/magnet/issues/69#issuecomment-468033997)
5. [Blog: Magnet - an alternative to Dagger](https://www.thomaskeller.biz/blog/2019/10/09/magnet-an-alternative-to-dagger/)
6. [Co2Monitor sample app](https://github.com/beworker/co2monitor/tree/master/android-client)
7. [Another sample app](https://github.com/beworker/g1)
# Features
- Minimalistic API
- Auto-scoping of instances
- Hierarchical, disposable scopes
- Kotlin friendly annotation
- Injection into Kotlin constructors with default arguments
- Injection from binary libraries
- Dependency inversion
- No direct references to Magnet generated code
- No reflection for injection, apt generated factory classes
- Extensible - some `magnetx` extensions are available
- Customizable - custom factories and instance selectors
# Why Magnet?
Magnet was crafted with simplicity and development speed in mind. It lets developers spend less time on DI configuration and do more other stuff, also more mistakes when used inattentively. Magnet motivates you writing highly modular apps because it makes DI so simple. It can even inject instances from the libraries added in build scripts without necessity to adapt source code. Magnet could be interesting for those, who needs an easy to configure and simple DI with more runtime control.
# Why not Magnet?
If compile time consistency validation is your highest priority, I recommend using awesome [Dagger2](https://github.com/google/dagger) instead. You will spend slightly more time on DI configuration but Dagger2 lets you keep it highly consistent and error prone (in most cases) very early in the development cycle - at compile time.
Peace ✌️ and have fun.
# Gradle
Kotlin
```gradle
repositories {
mavenCentral()
}
dependencies {
api 'de.halfbit:magnet-kotlin:<version>'
kapt 'de.halfbit:magnet-processor:<version>'
}
```
Java
```gradle
repositories {
mavenCentral()
}
dependencies {
api 'de.halfbit:magnet:<version>'
annotationProcessor 'de.halfbit:magnet-processor:<version>'
}
```
# Compatibility
| Kotlin Version | Magnet Version |
|----------------|----------------|
| 1.8.x | 3.8 |
| 1.7.x | 3.7 |
| 1.6.x | 3.6 |
| 1.5.x | 3.5 |
| 1.4.x | 3.4 |
| 1.3.x | 3.4 |
# Proguard & R8
```
-keep class magnet.internal.MagnetIndexer { *; }
```
# Build from Sources
1. Set JAVA_HOME variable to JDK 11.
2. Import project into Android Studio.
3. Set Gradle → Gradle Settings... → Gradle JDK to JDK 11.
4. To build the project run `./gradlew build`
5. To release the project run `./gradlew publish`
# Maven repository configurations
| Repository | Configuration |
|------------|----------------------------------------------------------------------------|
| Central | mavenCentral() |
| Snapshot | maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" } |
| Local | mavenLocal() |
# License
```
Copyright 2018-2023 Sergej Shafarenka, www.halfbit.de
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
================================================
FILE: build.gradle
================================================
buildscript {
ext.kotlin_version = '1.8.0'
repositories {
mavenCentral()
maven { url 'https://maven.google.com' }
}
dependencies {
classpath "com.android.tools.build:gradle:7.2.0"
classpath "com.vanniktech:gradle-maven-publish-plugin:0.19.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
mavenCentral()
}
configurations {
all {
resolutionStrategy {
force deps.kotlinjdk
}
}
}
}
ext {
javaVersion = JavaVersion.VERSION_11
}
ext.deps = [:]
// open source
ext.deps.kotlinjdk = "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
ext.deps.javapoet = 'com.squareup:javapoet:1.13.0'
ext.deps.android = 'com.google.android:android:4.1.1.4'
ext.deps.rxandroid = 'io.reactivex.rxjava2:rxandroid:2.1.1'
ext.deps.rx3android = 'io.reactivex.rxjava3:rxandroid:3.0.0'
ext.deps.stetho = 'com.facebook.stetho:stetho:1.6.0'
ext.deps.kotlinMetadata = 'org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.6.0'
ext.deps.annotations = 'org.jetbrains:annotations:16.0.1'
// testing
ext.deps.junit = 'junit:junit:4.12'
ext.deps.jsr305 = 'com.google.code.findbugs:jsr305:3.0.2'
ext.deps.mockito = 'org.mockito:mockito-core:4.5.1'
ext.deps.mockitoKotlin = 'org.mockito.kotlin:mockito-kotlin:4.0.0'
ext.deps.truth = 'com.google.truth:truth:1.1.3'
ext.deps.compileTesting = 'com.google.testing.compile:compile-testing:0.21.0'
================================================
FILE: documentation/diagrams/design.graphml
================================================
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:java="http://www.yworks.com/xml/yfiles-common/1.0/java" xmlns:sys="http://www.yworks.com/xml/yfiles-common/markup/primitives/2.0" xmlns:x="http://www.yworks.com/xml/yfiles-common/markup/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:y="http://www.yworks.com/xml/graphml" xmlns:yed="http://www.yworks.com/xml/yed/3" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://www.yworks.com/xml/schema/graphml/1.1/ygraphml.xsd">
<!--Created by yEd 3.18.0.2-->
<key attr.name="Description" attr.type="string" for="graph" id="d0"/>
<key for="port" id="d1" yfiles.type="portgraphics"/>
<key for="port" id="d2" yfiles.type="portgeometry"/>
<key for="port" id="d3" yfiles.type="portuserdata"/>
<key attr.name="url" attr.type="string" for="node" id="d4"/>
<key attr.name="description" attr.type="string" for="node" id="d5"/>
<key for="node" id="d6" yfiles.type="nodegraphics"/>
<key for="graphml" id="d7" yfiles.type="resources"/>
<key attr.name="url" attr.type="string" for="edge" id="d8"/>
<key attr.name="description" attr.type="string" for="edge" id="d9"/>
<key for="edge" id="d10" yfiles.type="edgegraphics"/>
<graph edgedefault="directed" id="G">
<data key="d0"/>
<node id="n0">
<data key="d4"/>
<data key="d6">
<y:UMLClassNode>
<y:Geometry height="42.83889883347422" width="121.96157027354172" x="299.8019242940941" y="328.709202259597"/>
<y:Fill color="#FFCC00" transparent="false"/>
<y:BorderStyle hasColor="false" type="line" width="1.0"/>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="13" fontStyle="bold" hasBackgroundColor="false" hasLineColor="false" height="19.310546875" horizontalTextPosition="center" iconTextGap="4" modelName="custom" textColor="#000000" verticalTextPosition="bottom" visible="true" width="42.87939453125" x="39.54108787114586" y="3.0">Scope<y:LabelModel>
<y:SmartNodeLabelModel distance="4.0"/>
</y:LabelModel>
<y:ModelParameter>
<y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
</y:ModelParameter>
</y:NodeLabel>
<y:UML clipContent="true" constraint="" hasDetailsColor="false" omitDetails="false" stereotype="" use3DEffect="false">
<y:AttributeLabel/>
<y:MethodLabel/>
</y:UML>
</y:UMLClassNode>
</data>
</node>
<node id="n1">
<data key="d4"/>
<data key="d6">
<y:UMLClassNode>
<y:Geometry height="42.83889883347422" width="121.96157027354172" x="514.2481436779401" y="328.709202259597"/>
<y:Fill color="#FFCC00" transparent="false"/>
<y:BorderStyle hasColor="false" type="line" width="1.0"/>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="13" fontStyle="bold" hasBackgroundColor="false" hasLineColor="false" height="19.310546875" horizontalTextPosition="center" iconTextGap="4" modelName="custom" textColor="#000000" verticalTextPosition="bottom" visible="true" width="60.18310546875" x="30.889232402395862" y="3.0">Instance<y:LabelModel>
<y:SmartNodeLabelModel distance="4.0"/>
</y:LabelModel>
<y:ModelParameter>
<y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="-0.5" nodeRatioX="4.440892098500626E-16" nodeRatioY="-0.42997018873753573" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
</y:ModelParameter>
</y:NodeLabel>
<y:UML clipContent="true" constraint="" hasDetailsColor="false" omitDetails="false" stereotype="" use3DEffect="false">
<y:AttributeLabel/>
<y:MethodLabel/>
</y:UML>
</y:UMLClassNode>
</data>
</node>
<edge id="e0" source="n0" target="n0">
<data key="d8"/>
<data key="d10">
<y:PolyLineEdge>
<y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0">
<y:Point x="360.78270943086494" y="287.44899181474153"/>
</y:Path>
<y:LineStyle color="#000000" type="line" width="1.0"/>
<y:Arrows source="none" target="plain"/>
<y:EdgeLabel alignment="center" configuration="AutoFlippingLabel" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.1328125" horizontalTextPosition="center" iconTextGap="4" modelName="custom" preferredPlacement="anywhere" ratio="0.5" textColor="#000000" verticalTextPosition="bottom" visible="true" width="60.7890625" x="-60.70566875261699" y="-64.50409416775955"><parent><y:LabelModel>
<y:SmartEdgeLabelModel autoRotationEnabled="false" defaultAngle="0.0" defaultDistance="10.0"/>
</y:LabelModel>
<y:ModelParameter>
<y:SmartEdgeLabelModelParameter angle="6.283185307179586" distance="0.5943657323100519" distanceToCenter="true" position="right" ratio="-14.193472945391704" segment="-1"/>
</y:ModelParameter>
<y:PreferredPlacementDescriptor angle="0.0" angleOffsetOnRightSide="0" angleReference="absolute" angleRotationOnRightSide="co" distance="-1.0" frozen="true" placement="anywhere" side="anywhere" sideReference="relative_to_edge_flow"/>
</y:EdgeLabel>
<y:EdgeLabel alignment="center" configuration="AutoFlippingLabel" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" hasText="false" height="4.0" horizontalTextPosition="center" iconTextGap="4" modelName="custom" preferredPlacement="anywhere" ratio="0.5" textColor="#000000" verticalTextPosition="bottom" visible="true" width="4.0" x="-1.7167717703069343" y="-26.1141097499401">
<y:LabelModel>
<y:SmartEdgeLabelModel autoRotationEnabled="false" defaultAngle="0.0" defaultDistance="10.0"/>
</y:LabelModel>
<y:ModelParameter>
<y:SmartEdgeLabelModelParameter angle="0.0" distance="30.0" distanceToCenter="true" position="right" ratio="0.5" segment="0"/>
</y:ModelParameter>
<y:PreferredPlacementDescriptor angle="0.0" angleOffsetOnRightSide="0" angleReference="absolute" angleRotationOnRightSide="co" distance="-1.0" frozen="true" placement="anywhere" side="anywhere" sideReference="relative_to_edge_flow"/>
</y:EdgeLabel>
<y:BendStyle smoothed="false"/>
</y:PolyLineEdge>
</data>
</edge>
<edge id="e1" source="n0" target="n1">
<data key="d8"/>
<data key="d10">
<y:PolyLineEdge>
<y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>
<y:LineStyle color="#000000" type="line" width="1.0"/>
<y:Arrows source="white_diamond" target="plain"/>
<y:BendStyle smoothed="false"/>
</y:PolyLineEdge>
</data>
</edge>
<edge id="e2" source="n1" target="n1">
<data key="d8"/>
<data key="d10">
<y:PolyLineEdge>
<y:Path sx="0.0" sy="0.0" tx="0.0" ty="12.878338588469717">
<y:Point x="565.7917197218228" y="291.627427387127"/>
</y:Path>
<y:LineStyle color="#000000" type="line" width="1.0"/>
<y:Arrows source="none" target="plain"/>
<y:EdgeLabel alignment="center" configuration="AutoFlippingLabel" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.1328125" horizontalTextPosition="center" iconTextGap="4" modelName="custom" preferredPlacement="anywhere" ratio="0.5" textColor="#000000" verticalTextPosition="bottom" visible="true" width="103.10546875" x="-77.45654384302611" y="-61.57494978959795"><dependencies><y:LabelModel>
<y:SmartEdgeLabelModel autoRotationEnabled="false" defaultAngle="0.0" defaultDistance="10.0"/>
</y:LabelModel>
<y:ModelParameter>
<y:SmartEdgeLabelModelParameter angle="6.283185307179586" distance="9.279785258782196" distanceToCenter="true" position="left" ratio="-14.325195439906148" segment="-1"/>
</y:ModelParameter>
<y:PreferredPlacementDescriptor angle="0.0" angleOffsetOnRightSide="0" angleReference="absolute" angleRotationOnRightSide="co" distance="-1.0" frozen="true" placement="anywhere" side="anywhere" sideReference="relative_to_edge_flow"/>
</y:EdgeLabel>
<y:BendStyle smoothed="false"/>
</y:PolyLineEdge>
</data>
</edge>
</graph>
<data key="d7">
<y:Resources/>
</data>
</graphml>
================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
#Wed Dec 18 22:04:35 CET 2019
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
================================================
FILE: gradle.properties
================================================
org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
GROUP=de.halfbit
VERSION_NAME=3.8
VERSION_CODE=0
POM_DESCRIPTION=Dependency injection library for Android
POM_URL=https://github.com/sergejsha/magnet/
POM_INCEPTION_YEAR=2018
POM_SCM_URL=https://github.com/sergejsha/magnet/
POM_SCM_CONNECTION=scm:git:git://github.com/sergejsha/magnet.git
POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/sergejsha/magnet.git
POM_LICENSE_NAME=The Apache Software License, Version 2.0
POM_LICENSE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENSE_DIST=repo
POM_DEVELOPER_ID=sergejsha
POM_DEVELOPER_NAME=Sergej Shafarenka
POM_DEVELOPER_URL=https://github.com/sergejsha/
================================================
FILE: gradlew
================================================
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"
================================================
FILE: gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: magnet/build.gradle
================================================
plugins {
id 'java-library'
id 'com.vanniktech.maven.publish'
}
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
dependencies {
compileOnly deps.annotations
testImplementation deps.junit
testImplementation deps.mockito
testImplementation deps.truth
testCompileOnly deps.annotations
}
================================================
FILE: magnet/gradle.properties
================================================
POM_NAME=Magnet Runtime Library
POM_ARTIFACT_ID=magnet
POM_PACKAGING=jar
================================================
FILE: magnet/src/main/java/magnet/Classifier.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.RetentionPolicy.CLASS;
/**
* Magnet can bind multiple instances of the same type into a scope. Use classifier
* with a unique value to differentiate between those instances.
*
* <pre>
* // bind instances
* scope.bind(Context.class, application, "app-context");
* scope.bind(Context.class, activity, "activity-context");
*
* // get instances directly
* Context app = scope.getSingle(Context.class, "app-context");
* Context activity = scope.getSingle(Context.class, "activity-context");
*
* // get instances via constructor injection
* @Instance(type = MyImplementation.class)
* public MyImplementation(
* @Classifier("app-context") Context app,
* @Classifier("activity-context") Context activity,
* ) {
* ...
* }
* </pre>
*/
@Retention(CLASS)
@Target({ElementType.PARAMETER, ElementType.METHOD})
public @interface Classifier {
String NONE = "";
String value();
}
================================================
FILE: magnet/src/main/java/magnet/Factory.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet;
import org.jetbrains.annotations.NotNull;
/** Custom factory to be used with {@link Instance#factory()}. */
public interface Factory<T> {
/** Implementation must return instance of give type without delegating the call to the given scope. */
@NotNull
T create(
@NotNull Scope scope,
@NotNull Class<T> type,
@NotNull String classifier,
@NotNull Scoping scoping,
@NotNull Instantiator<T> instantiator
);
/** Instantiator creates new instance of given type using {@code new} operator. */
interface Instantiator<T> {
@NotNull
T instantiate(Scope scope);
}
}
================================================
FILE: magnet/src/main/java/magnet/Instance.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet;
import static java.lang.annotation.RetentionPolicy.CLASS;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* Magnet instantiates classes marked with this annotation automatically. Annotated
* classes must have a single, none private constructor. Constructor is allowed to have
* parameters which are dependencies for this instance. Magnet checks constructor
* parameters and tries to resolve corresponding dependencies by looking into accessible
* scopes. If no suitable instances were found in scopes, Magnet searches for
* {@code Instance}-annotated classes and tried to instantiate them. If constructor's
* dependencies cannot be fulfilled, Magnet will fail at runtime with corresponding
* error message.
*
* <p>
* In the example below we declare two dependent types and instantiate them in scope.
*
* <pre>
* @Instance(type=TypeA.class)
* class TypeA {
* TypeA() {}
* }
*
* @Instance(type=TypeB.class)
* class TypeB {
* final TypeA typeA;
* TypeB(@NonNull TypeA dependency) {
* typeA = dependency;
* }
* }
*
* ...
*
* // get instance of typeB
* TypeB typeB = scope.getSingle(TypeB.class);
*
* // typeA has been provided by Magnet
* typeB.typeA != null
*
* </pre>
*
* <p>
* <b>Nullability.</b> Magnet is capable of detecting whether dependency can or cannot be null.
* If a constructor's parameter is annotated as nullable and Magnet cannot provide instance of
* parameter's type, then <code>null</code> is provided instead.
*
* <p>
* <b>Classification.</b> Same interface can be implemented by many classes. Classifier is used
* to differentiate between those implementations. See {@link Classifier} for more detail.
*
* <p>
* <b>Scoping.</b> Magnet can bind created instances into scope for reuse. Instance can
* specify whether and how its instances should be bound into the scope. See {@link Scoping}
* for more detail.
*/
@Retention(CLASS)
@Target({ElementType.TYPE, ElementType.METHOD})
public @interface Instance {
/**
* Type to use when annotated instance gets registered in scope. Annotated class must
* actually implement this type.
*/
Class<?> type() default void.class;
/**
* Multiple types to use when annotated instance gets registered in scope. Annotated
* class must actually implement all these types. Properties {@link #type()} and
* {@code #types()} are exclusively mutual and cannot be used together.
*/
Class<?>[] types() default void.class;
/**
* Classifier to use when annotated instance gets registered in scope.
*/
String classifier() default Classifier.NONE;
/**
* Scoping rule to be applied when instance of annotated class gets created.
*/
Scoping scoping() default Scoping.TOPMOST;
/**
* Limit tag to be used with {@link Scoping#TOPMOST} algorithm. If a limit tag is
* preset then the instance will be placed at or below the scope having same limit
* tag applied to it. If multiple scopes have the same limit tag, then the closest scope
* to the scope where the instance gets requested is used.
*/
String limitedTo() default "";
/**
* <b>Experimental.</b> Magnet will only create instance of the annotated class if
* this selector expression is true after evaluation. Magnet currently support single
* type of expression:
* <p>
* <code>android.api (comparison operator) (api version)</code>
* <p>
* For instance, the expression <code>android.api >= 28</code> will only create
* annotated instance if Build.VERSION.SDK_INT >= 28. For the other versions
* <code>null</code> is returned. Make sure to use optional injection to handle
* this case.
*/
String selector() default SelectorFilter.DEFAULT_SELECTOR;
/**
* Custom factory to be used for creating instance instead of the generated one.
*/
Class<? extends Factory> factory() default Factory.class;
/**
* Name of optional disposer method to be called, when whole scope gets disposed.
*/
String disposer() default "";
/**
* Magnet ignores this annotation when this flag is set to <code>true</code>.
*/
boolean disabled() default false;
}
================================================
FILE: magnet/src/main/java/magnet/Magnet.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet;
import magnet.internal.InternalFactory;
import org.jetbrains.annotations.NotNull;
public final class Magnet {
private Magnet() { }
public static @NotNull Scope createRootScope() {
return InternalFactory.createRootScope();
}
}
================================================
FILE: magnet/src/main/java/magnet/Registry.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.RetentionPolicy.CLASS;
/**
* This marker annotation instructs Magnet to generate a registry indexing all
* instances available in classpath. Index applies to sources as well as libraries.
* Apply this annotation to any interface or class in your main application module.
*/
@Retention(CLASS)
@Target({ElementType.TYPE})
public @interface Registry {}
================================================
FILE: magnet/src/main/java/magnet/Scope.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* Scope is a container for objects which are stored there at runtime.
*
* <p>
* <b>Binding.</b> Binding is the way of putting objects into the scope.
*
* <pre>
* Scope root = Magnet.createScope()
* .bind(app, Application.class)
* .bind(String.class, "#FF0000", "red-color");
* </pre>
*
* <p>
* <b>Chaining.</b> Scopes can be chained using
* parent-child relation, or rather a child-parent relation because
* a child scope (aka subscope) holds a reference to its parent and not
* the other way around.
*
* <pre>
* Scope subscope = root.createSubscope()
* .bind(activity, Context.class)
* .bind(String.class, "#F30303", "red-color")
* .bind(String.class, "#00FF00", "green-color");
* </pre>
*
* <b>Provisioning.</b> Scope has multiple get-methods for providing
* objects it stores. Magnet will look through the whole scope's chain up
* to the root parent scope to provide an object. First found match gets
* returned.
*
* <pre>
* // object overwriting
* String red = root.getSingle(String.class, "red-color"); // "#FF0000" (from root)
* String red = subscope.getSingle(String.class, "red-color"); // "#F30303" (from subscope)
*
* // scope chaining
* Application app = subscope.getSingle(Application.class); // app (from root)
* Context context = subscope.getSingle(Context.class); // activity (from subscope)
* String green = subscope.getSingle(String.class, "green-color"); // "#00FF00" (from subscope)
*
* // optional provisioning
* String red = root.getOptional(String.class, "red-color"); "#FF0000" (from root)
* String yellow = subscope.getSingle(String.class, "yellow-color"); // throws IllegalStateException
* String yellow = subscope.getOptional(String.class, "yellow-color"); // null, optional was not found
* </pre>
*
* <p>
* <b>Automatic binding (injection).</b>
* Magnet can instantiate {@link Instance}-annotated classes and bind their instances
* into respective scopes automatically. If instantiated classes have dependencies, Magnet
* will resolve those dependencies too. In this respect Magnet works as dependency injection
* library.
*
* <p>In the example below Magnet will create instance of {@code toaster} by taking required
* dependencies from the scopes.
*
* <pre>
* @Instance(type = Toaster.class)
* class Toaster {
* Toaster(
* Application app,
* @Classifier("red-color") String red,
* @Classifier("green-color") String green
* ) { ... }
*
* Toaster toaster = subscope.getSingle(Toaster.class);
* toaster != null
* </pre>
*/
public interface Scope {
/** Returns an object from the scope or {@code null}, if object was not found. */
@Nullable <T> T getOptional(@NotNull Class<T> type);
/** Returns an object from the scope or {@code null}, if object was not found. */
@Nullable <T> T getOptional(@NotNull Class<T> type, @NotNull String classifier);
/** Returns an object from the scope or throws exception, if object was not found. */
@NotNull <T> T getSingle(@NotNull Class<T> type);
/** Returns an object from the scope or throws exception, if object was not found. */
@NotNull <T> T getSingle(@NotNull Class<T> type, @NotNull String classifier);
/** Returns a list of objects or empty list, if no objects were found. */
@NotNull <T> List<T> getMany(@NotNull Class<T> type);
/** Returns a list of objects or empty list, if no objects were found. */
@NotNull <T> List<T> getMany(@NotNull Class<T> type, @NotNull String classifier);
/** Binds given instance into this scope. */
@NotNull <T> Scope bind(@NotNull Class<T> type, @NotNull T instance);
/** Binds given instance into this scope. */
@NotNull <T> Scope bind(@NotNull Class<T> type, @NotNull T instance, @NotNull String classifier);
/** Sets given limits to this scope. */
@NotNull Scope limit(String... limits);
/** Creates a new child scope of this scope. */
@NotNull Scope createSubscope();
/** Disposes this and all children scopes. Notifies instances with {@link magnet.Instance#disposer()}. */
void dispose();
/** Returns `true` is the scope is disposed, or `false` otherwise. */
boolean isDisposed();
/** Visits all instances and child scopes of given depth (use {@code Integer.MAX_VALUE} for visiting all scopes). */
void accept(Visitor visitor, int depth);
}
================================================
FILE: magnet/src/main/java/magnet/Scoping.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet;
/**
* Declares the way Magnet binds instances of @Instance</code>-annotated
* classes into scopes. See each separate setting for more detail.
*/
public enum Scoping {
/**
* Magnet will not bind created instance into any scope. This is equivalent
* to having a factory creating new instances each time when instance is
* requested.
*
* <p>
* In the example below, both instances {@code typeA} and {@code typeB} are
* <b>not</b> bound into the {@code scope}. Each new {@code scope.getSingle(TypeB.class)}
* call will return new instances of {@code typeA} and {@code typeB}.
*
* <pre>
*
* @Instance(type = TypeA.class, scoping = Scoping.UNSCOPED)
* class TypeA {
* TypeA() {}
* }
*
* @Instance(type = TypeB.class, scoping = Scoping.UNSCOPED)
* class TypeB {
* final TypeA typeA;
* TypeB(@NonNull TypeA dependency) {
* typeA = dependency;
* }
* }
*
* ...
*
* Scope scope = Magnet.createScope();
*
* TypeB typeB = scope.getSingle(TypeB.class);
* TypeA typeA = typeB.typeA;
* TypeA typeA2 = scope.getSingle(TypeA.class);
* typeA !== typeA2 // different instances
*
* </pre>
*/
UNSCOPED,
/**
* Magnet will bind created instance into the most top scope in the chain of scopes,
* where all dependencies for the created instance are still fulfilled.
*
* <p>
* Scopes in Magnet can build a chain of parent-child relations (see {@link Scope} for
* more detail). This option allows binding instances of annotated class into a one
* of parent scopes. Magnet goes up the scope chain and checks, whether all dependencies
* for the instance can still be satisfied in that scope. The most top reached scope
* with satisfied dependencies is the scope, into which the instance gets bound.
*
* <p>
* In the example below both instances {@code typeA} and {@code typeB} are bound into
* {@code root}.
*
* <pre>
*
* @Instance(type = TypeA.class, scoping = Scoping.TOPMOST)
* class TypeA {
* TypeA() {}
* }
*
* @Instance(type = TypeB.class)
* class TypeB {
* final TypeA typeA;
* TypeB(@NonNull TypeA dependency) {
* typeA = dependency;
* }
* }
*
* ...
*
* Scope root = Magnet.createScope();
* Scope scope = root.createSubscope();
*
* TypeB typeB = scope.getSingle(TypeB.class);
* TypeA typeA = typeB.typeA;
* TypeA typeA2 = scope.getSingle(TypeA.class);
* typeA === typeA2 // same instance
*
* </pre>
*
* Explanation:
*
* <ul>
* <li>{@code TypeA} has no dependencies and thus it gets bound to {@code root};
* <li>{@code TypeB} depends on {@code TypeA} and because the instance of {@code TypeA}
* is available in {@code root}, and instance of {@code TypeB} can also be created
* in {@code root}.
* </ul>
*
* <p>
* In the example below we bind instance of {@code typeA} into {@code scope} and
* {@code typeB} instance gets bound into the {@code scope} too.
*
* <pre>
*
* @Instance(type = TypeA.class, scoping = Scoping.TOPMOST)
* class TypeA {
* TypeA() {}
* }
*
* @Instance(type = TypeB.class, scoping = Scoping.TOPMOST)
* class TypeB {
* final TypeA typeA;
* TypeB(@NonNull TypeA dependency) {
* typeA = dependency;
* }
* }
*
* ...
*
* Scope root = Magnet.createScope();
* Scope scope = root.createSubscope().bind(TypeA.class, new TypeA());
*
* TypeB typeB = scope.getSingle(TypeB.class);
* TypeA typeA = typeB.typeA;
* TypeA typeA2 = scope.getSingle(TypeA.class);
* typeA === typeA2 // same instance
*
* </pre>
*
* Explanation:
*
* <ul>
* <li>{@code typeB} cannot be bound in a scope above its dependencies;
* <li>{@code typeA} is available in {@code scope}, thus the {@code scope} is the
* top most scope for dependent {@code typeB} too.
* </ul>
*/
TOPMOST,
/**
* Magnet will bind created instance into the same scope, in which this instance
* has been created.
*
* <p>
* In the example below, both instances {@code typeA} and {@code typeB} are bound
* into {@code scope}. Each new {@code scope.getSingle(TypeB.class)} call on the
* same instance of {@code scope} will return same instances of {@code typeA} and
* {@code typeB}.
*
* <pre>
*
* @Instance(type = TypeA.class, scoping = Scoping.DIRECT)
* class TypeA {
* TypeA() {}
* }
*
* @Instance(type = TypeB.class, scoping = Scoping.DIRECT)
* class TypeB {
* final TypeA typeA;
* TypeB(@NonNull TypeA dependency) {
* typeA = dependency;
* }
* }
*
* ...
*
* Scope root = Magnet.createScope();
* Scope scope = root.createSubscope();
*
* TypeB typeB = scope.getSingle(TypeB.class);
* TypeA typeA = typeB.typeA;
* TypeA typeA2 = scope.getSingle(TypeA.class);
* typeA === typeA2 // same instance
*
* </pre>
*/
DIRECT
}
================================================
FILE: magnet/src/main/java/magnet/SelectorFilter.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet;
import org.jetbrains.annotations.NotNull;
/** Selector handler for processing {@link Instance#selector()} value at runtime. */
public abstract class SelectorFilter {
public static final String DEFAULT_SELECTOR = "";
public abstract boolean filter(@NotNull String[] selector);
}
================================================
FILE: magnet/src/main/java/magnet/Visitor.java
================================================
package magnet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Implementation of this interface should be used with {@link magnet.Scope#accept(Visitor, int)}
* for iterating though instances and subscopes of a scope. Scope visiting begins with iterating
* through all instances and then through all subscopes.
*/
public interface Visitor {
/** Provision type. */
enum Provision {BOUND, INJECTED}
/** Visited instance. */
interface Instance {
@NotNull Scoping getScoping();
@NotNull String getClassifier();
@NotNull String getLimit();
@NotNull Class<?> getType();
@NotNull Object getValue();
@NotNull Provision getProvision();
}
/** Visited scope. */
interface Scope {
@Nullable String[] getLimits();
}
/**
* Called when new scope is entered.
*
* @param scope entered scope.
* @param parent parent scope of the entered scope.
* @return <code>true</code> to visit instances of this scope, <code>false</code> to skip instances.
*/
boolean onEnterScope(@NotNull Scope scope, @Nullable Scope parent);
/**
* Called when visiting new instance between {@link #onEnterScope(Scope, Scope)}
* and {@link #onExitScope(Scope)} calls.
*
* @param instance visited instance.
* @return <code>true</code> to visit the next instance in the scope or <code>false</code>
* to skip all other instances in this scope.
*/
boolean onInstance(@NotNull Instance instance);
/**
* Called when previously entered scope is exited.
*
* @param scope exited scope.
*/
void onExitScope(@NotNull Scope scope);
}
================================================
FILE: magnet/src/main/java/magnet/internal/FactoryFilter.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet.internal;
/* Subject to change. For internal use only. */
interface FactoryFilter {
boolean filter(InstanceFactory factory);
}
================================================
FILE: magnet/src/main/java/magnet/internal/Generated.java
================================================
package magnet.internal;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.RetentionPolicy.CLASS;
/** Subject to change. For internal use only. */
@Retention(CLASS)
@Target({ElementType.TYPE})
public @interface Generated {}
================================================
FILE: magnet/src/main/java/magnet/internal/ImmutableArrayList.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet.internal;
import java.util.AbstractList;
/* Subject to change. For internal use only. */
class ImmutableArrayList<E> extends AbstractList<E> {
private final E[] elements;
ImmutableArrayList(E[] elements) {
this.elements = elements;
}
@Override public E get(int i) {
if (i < 0 || i >= elements.length) {
throw new IndexOutOfBoundsException(
String.format(
"Cannot find element with index %s, array length: %s", i, elements.length));
}
return elements[i];
}
@Override public int size() {
return elements.length;
}
}
================================================
FILE: magnet/src/main/java/magnet/internal/Index.java
================================================
package magnet.internal;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.RetentionPolicy.CLASS;
/** Subject to change. For internal use only. */
@Retention(CLASS)
@Target({ElementType.TYPE})
public @interface Index {
Class factoryType();
Class factoryClass();
String instanceType();
String classifier();
}
================================================
FILE: magnet/src/main/java/magnet/internal/InstanceBucket.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet.internal;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import magnet.Scoping;
import magnet.Visitor;
/* Subject to change. For internal use only. */
@SuppressWarnings("unchecked")
final class InstanceBucket<T> {
@NotNull private final OnInstanceListener listener;
@NotNull private InstanceBucket.Instance instance;
@NotNull private MagnetScope scope;
InstanceBucket(
@NotNull MagnetScope scope,
@Nullable InstanceFactory<T> factory,
@NotNull Class<T> objectType,
@NotNull T object,
@NotNull String classifier,
@NotNull OnInstanceListener listener
) {
this.scope = scope;
this.listener = listener;
this.instance = createSingleInstance(factory, objectType, object, classifier);
}
@NotNull MagnetScope getScope() { return scope; }
@NotNull T getSingleInstance() {
if (instance instanceof InjectedInstance) {
return ((InjectedInstance<T>) instance).object;
} else if (instance instanceof BoundInstance) {
return ((BoundInstance<T>) instance).object;
}
MultiObjectInstance multiObjectInstance = (MultiObjectInstance) instance;
throw new IllegalStateException(
String.format(
"Single instance requested, while many instances are stored: %s",
multiObjectInstance.instances
)
);
}
@Nullable T getOptional(@Nullable Class<InstanceFactory<T>> factoryType) {
if (instance instanceof InjectedInstance) {
InjectedInstance<T> single = (InjectedInstance<T>) instance;
if (single.factory.getClass() == factoryType) {
return single.object;
}
return null;
} else if (instance instanceof BoundInstance) {
BoundInstance<T> single = (BoundInstance<T>) instance;
if (factoryType == null) {
return single.object;
}
return null;
}
return (T) ((MultiObjectInstance) instance).getOptional(factoryType);
}
@NotNull List<T> getMany() {
if (instance instanceof InjectedInstance) {
return Collections.singletonList(((InjectedInstance<T>) instance).object);
} else if (instance instanceof BoundInstance) {
return Collections.singletonList(((BoundInstance<T>) instance).object);
}
return ((MultiObjectInstance<T>) instance).getMany();
}
void registerObject(
@Nullable InstanceFactory<T> factory,
@NotNull Class<T> objectType,
@NotNull T object,
@NotNull String classifier
) {
if (this.instance instanceof InstanceBucket.MultiObjectInstance) {
MultiObjectInstance<T> many = (MultiObjectInstance<T>) this.instance;
many.putSingle(createSingleInstance(factory, objectType, object, classifier));
} else {
MultiObjectInstance<T> many = new MultiObjectInstance<>((SingleObjectInstance<T>) this.instance);
many.putSingle(createSingleInstance(factory, objectType, object, classifier));
this.instance = many;
}
}
boolean hasInstanceWithFactory(@Nullable InstanceFactory<T> factory) {
return instance.hasObjectWithFactory(factory);
}
private @NotNull InstanceBucket.SingleObjectInstance<T> createSingleInstance(
@Nullable InstanceFactory<T> factory,
@NotNull Class<T> objectType,
@NotNull T object,
@NotNull String classifier
) {
SingleObjectInstance single;
if (factory == null) {
single = new BoundInstance<>(objectType, object, classifier);
} else {
single = new InjectedInstance<>(factory, objectType, object, classifier);
}
listener.onInstanceCreated(single);
return single;
}
public boolean accept(Visitor visitor) {
if (instance instanceof SingleObjectInstance) {
return ((SingleObjectInstance) instance).accept(visitor);
} else {
return ((MultiObjectInstance) instance).accept(visitor);
}
}
interface Instance<T> {
boolean hasObjectWithFactory(@Nullable InstanceFactory<T> factory);
}
static abstract class SingleObjectInstance<T> implements Instance<T> {
final @NotNull Class<T> objectType;
final @NotNull T object;
final @NotNull String classifier;
SingleObjectInstance(
@NotNull Class<T> objectType,
@NotNull T object,
@NotNull String classifier
) {
this.objectType = objectType;
this.object = object;
this.classifier = classifier;
}
public boolean accept(Visitor visitor) {
if (this instanceof InjectedInstance) {
return visitor.onInstance((InjectedInstance) this);
} else {
return visitor.onInstance((BoundInstance) this);
}
}
}
static class BoundInstance<T> extends SingleObjectInstance<T> implements Visitor.Instance {
BoundInstance(@NotNull Class<T> objectType, @NotNull T object, @NotNull String classifier) {
super(objectType, object, classifier);
}
@Override public boolean hasObjectWithFactory(@Nullable InstanceFactory<T> factory) {
return true;
}
@Override public @NotNull Scoping getScoping() { return Scoping.DIRECT; }
@Override public @NotNull String getClassifier() { return classifier; }
@Override public @NotNull String getLimit() { return ""; }
@Override public @NotNull Class<?> getType() { return objectType; }
@Override public @NotNull Object getValue() { return object; }
@Override public @NotNull Visitor.Provision getProvision() {
return Visitor.Provision.BOUND;
}
}
static class InjectedInstance<T> extends SingleObjectInstance<T> implements Visitor.Instance {
@NotNull final InstanceFactory<T> factory;
InjectedInstance(
@NotNull InstanceFactory<T> factory,
@NotNull Class<T> objectType,
@NotNull T object,
@NotNull String classifier
) {
super(objectType, object, classifier);
this.factory = factory;
}
@Override public boolean hasObjectWithFactory(@Nullable InstanceFactory<T> factory) {
return factory == this.factory;
}
@Override public @NotNull Scoping getScoping() { return factory.getScoping(); }
@Override public @NotNull String getClassifier() { return classifier; }
@Override public @NotNull String getLimit() { return factory.getLimit(); }
@Override public @NotNull Class<?> getType() { return objectType; }
@Override public @NotNull Object getValue() { return object; }
@Override public @NotNull Visitor.Provision getProvision() {
return Visitor.Provision.INJECTED;
}
}
private static class MultiObjectInstance<T> implements Instance<T> {
private final @NotNull HashMap<Class<InstanceFactory<T>>, SingleObjectInstance<T>> instances;
MultiObjectInstance(@NotNull InstanceBucket.SingleObjectInstance<T> single) {
instances = new HashMap<>(8);
putSingle(single);
}
@NotNull List<T> getMany() {
List<T> result = new ArrayList<>(this.instances.size());
for (SingleObjectInstance<T> single : this.instances.values()) {
result.add(single.object);
}
return result;
}
@Nullable T getOptional(@Nullable Class<InstanceFactory<T>> factoryType) {
SingleObjectInstance<T> single = instances.get(factoryType);
if (single == null) return null;
return single.object;
}
void putSingle(@NotNull InstanceBucket.SingleObjectInstance<T> single) {
@Nullable final Class<InstanceFactory<T>> factoryType;
if (single instanceof InjectedInstance) {
factoryType = (Class<InstanceFactory<T>>) ((InjectedInstance) single).factory.getClass();
} else if (single instanceof BoundInstance) {
factoryType = null;
} else {
throw new IllegalStateException("Unsupported SingleObjectInstance type.");
}
instances.put(factoryType, single);
}
@Override public boolean hasObjectWithFactory(@Nullable InstanceFactory<T> factory) {
return instances.containsKey(factory == null ? null : factory.getClass());
}
public boolean accept(Visitor visitor) {
Collection<SingleObjectInstance<T>> singleObjectInstances = instances.values();
boolean takeNext = true;
for (SingleObjectInstance<T> instance : singleObjectInstances) {
takeNext = instance.accept(visitor);
if (!takeNext) break;
}
return takeNext;
}
}
interface OnInstanceListener {
<T> void onInstanceCreated(SingleObjectInstance<T> instance);
}
}
================================================
FILE: magnet/src/main/java/magnet/internal/InstanceFactory.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet.internal;
import magnet.Scope;
import magnet.Scoping;
/* Subject to change. For internal use only. */
public abstract class InstanceFactory<T> {
public abstract T create(Scope scope);
public Scoping getScoping() { return Scoping.TOPMOST; }
public String getLimit() { return ""; }
public Class[] getSiblingTypes() { return null; }
public String[] getSelector() { return null; }
public boolean isDisposable() { return false; }
public void dispose(T instance) {
throw new IllegalStateException(
String.format("Instance %s is not disposable", instance)
);
}
}
================================================
FILE: magnet/src/main/java/magnet/internal/InstanceManager.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet.internal;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/* Subject to change. For internal use only. */
interface InstanceManager {
<T> @Nullable InstanceFactory<T> getInstanceFactory(
Class<T> instanceType, String classifier, Class<InstanceFactory<T>> factoryType);
<T> @Nullable InstanceFactory<T> getFilteredInstanceFactory(
Class<T> type, String classifier, FactoryFilter factoryFilter);
<T> @NotNull List<InstanceFactory<T>> getManyInstanceFactories(
Class<T> type, String classifier, FactoryFilter factoryFilter);
}
================================================
FILE: magnet/src/main/java/magnet/internal/InternalFactory.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet.internal;
import magnet.Scope;
import org.jetbrains.annotations.NotNull;
/* Subject to change. For internal use only. */
public final class InternalFactory {
private static final InstanceManager INSTANCE_MANAGER = new MagnetInstanceManager();
private InternalFactory() {}
static @NotNull Scope createRootScope(@NotNull InstanceManager instanceManager) {
return new MagnetScope(null, instanceManager);
}
public static @NotNull Scope createRootScope() {
return new MagnetScope(null, INSTANCE_MANAGER);
}
}
================================================
FILE: magnet/src/main/java/magnet/internal/MagnetInstanceManager.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet.internal;
import magnet.Registry;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/* Subject to change. For internal use only. */
@SuppressWarnings("unchecked") final class MagnetInstanceManager implements InstanceManager {
private InstanceFactory[] factories;
private Map<Class, Object> index;
MagnetInstanceManager() {
registerInstanceFactories();
}
private void registerInstanceFactories() {
try {
Class<?> magnetClass = Class.forName("magnet.internal.MagnetIndexer");
Method registerFactories = magnetClass.getMethod("register", MagnetInstanceManager.class);
registerFactories.invoke(magnetClass, this);
} catch (Exception e) {
System.err.println(
String.format(
"MagnetIndexer cannot be found. Add a @%s-annotated class to the application module.",
Registry.class
)
);
}
}
// called by generated index class
void register(InstanceFactory[] factories, Map<Class, Object> index) {
this.factories = factories;
this.index = index;
}
@Override
public <T> @Nullable InstanceFactory<T> getInstanceFactory(
Class<T> instanceType, String classifier, Class<InstanceFactory<T>> factoryType
) {
Range range = getOptionalRange(instanceType, classifier);
if (range == null) return null;
if (range.getCount() == 1) return factories[range.getFrom()];
for (int index = range.getFrom(), afterLast = range.getFrom() + range.getCount(); index < afterLast; index++) {
InstanceFactory<T> candidate = factories[index];
if (candidate.getClass() == factoryType) {
return candidate;
}
}
return null;
}
@Override
public <T> @Nullable InstanceFactory<T> getFilteredInstanceFactory(
Class<T> type, String classifier, FactoryFilter factoryFilter
) {
Range range = getOptionalRange(type, classifier);
if (range == null) {
return null;
}
if (range.getCount() == 1) {
InstanceFactory factory = factories[range.getFrom()];
if (factoryFilter.filter(factory)) {
return factory;
}
return null;
}
InstanceFactory<T> factory = null;
for (int index = range.getFrom(), afterLast = range.getFrom() + range.getCount(); index < afterLast; index++) {
InstanceFactory<T> candidate = factories[index];
if (factoryFilter.filter(candidate)) {
if (factory != null) {
throw new IllegalStateException(
String.format(
"Multiple implementations of type %s (classifier: %s) can be injected," +
" while single implementation is expected. Overloaded factories: %s, %s",
type, classifier, factory, candidate
)
);
}
factory = candidate;
}
}
return factory;
}
@Override
public <T> @NotNull List<InstanceFactory<T>> getManyInstanceFactories(
Class<T> type, String classifier, FactoryFilter factoryFilter
) {
Object indexed = index.get(type);
if (indexed instanceof Range) {
Range range = (Range) indexed;
if (range.getClassifier().equals(classifier)) {
return factoriesFromRange(range, factoryFilter);
}
return Collections.emptyList();
}
if (indexed instanceof Map) {
Map<String, Range> ranges = (Map<String, Range>) indexed;
Range range = ranges.get(classifier);
if (range != null) {
return factoriesFromRange(range, factoryFilter);
}
return Collections.emptyList();
}
return Collections.emptyList();
}
private Range getOptionalRange(Class<?> type, String classifier) {
Object indexed = index.get(type);
if (indexed == null) {
return null;
}
if (indexed instanceof Range) {
Range range = (Range) indexed;
if (classifier.equals(range.getClassifier())) {
return (Range) indexed;
}
return null;
}
if (indexed instanceof Map) {
Map<String, Range> ranges = (Map<String, Range>) indexed;
return ranges.get(classifier);
}
throw new IllegalStateException(
String.format("Unsupported index type: %s", indexed.getClass())
);
}
private <T> List<InstanceFactory<T>> factoriesFromRange(Range range, FactoryFilter factoryFilter) {
List<InstanceFactory<T>> filteredFactories = null;
for (int index = range.getFrom(), afterLast = range.getFrom() + range.getCount(); index < afterLast; index++) {
InstanceFactory<T> factory = factories[index];
if (factory.getSelector() != null) {
if (filteredFactories == null) {
filteredFactories = new ArrayList<>(range.getCount());
}
if (factoryFilter.filter(factory)) {
filteredFactories.add(factory);
}
}
}
if (filteredFactories != null) {
return filteredFactories;
}
InstanceFactory<T>[] factories = new InstanceFactory[range.getCount()];
System.arraycopy(this.factories, range.getFrom(), factories, 0, range.getCount());
return new ImmutableArrayList<>(factories);
}
}
================================================
FILE: magnet/src/main/java/magnet/internal/MagnetScope.java
================================================
/*
* Copyright (C) 2018-2019 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet.internal;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.ref.WeakReference;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import magnet.Classifier;
import magnet.Scope;
import magnet.Scoping;
import magnet.SelectorFilter;
import magnet.Visitor;
/* Subject to change. For internal use only. */
final class MagnetScope implements Scope, Visitor.Scope, FactoryFilter, InstanceBucket.OnInstanceListener {
private static final byte CARDINALITY_OPTIONAL = 0;
private static final byte CARDINALITY_SINGLE = 1;
private static final byte CARDINALITY_MANY = 2;
private final @Nullable MagnetScope parent;
private final @NotNull InstanceManager instanceManager;
private final int depth;
private @Nullable WeakScopeReference childrenScopes;
private @Nullable List<InstanceBucket.InjectedInstance> disposables;
private @Nullable String[] limits;
private boolean disposed = false;
final @NotNull Map<String, InstanceBucket> instanceBuckets;
@SuppressWarnings("AnonymousHasLambdaAlternative")
private final @NotNull ThreadLocal<InstantiationContext> instantiationContext =
new ThreadLocal<InstantiationContext>() {
@Override protected InstantiationContext initialValue() {
return new InstantiationContext();
}
};
MagnetScope(@Nullable MagnetScope parent, @NotNull InstanceManager instanceManager) {
this.depth = parent == null ? 0 : parent.depth + 1;
this.parent = parent;
this.instanceManager = instanceManager;
this.instanceBuckets = new HashMap<>(32, 0.75f);
}
@Override
public <T> @Nullable T getOptional(@NotNull Class<T> type) {
checkNotDisposed();
InstanceFactory<T> factory = instanceManager
.getFilteredInstanceFactory(type, Classifier.NONE, this);
return findOrInjectOptional(type, Classifier.NONE, factory, CARDINALITY_OPTIONAL);
}
@Override
public <T> @Nullable T getOptional(@NotNull Class<T> type, @NotNull String classifier) {
checkNotDisposed();
InstanceFactory<T> factory = instanceManager
.getFilteredInstanceFactory(type, classifier, this);
return findOrInjectOptional(type, classifier, factory, CARDINALITY_OPTIONAL);
}
@Override
public <T> @NotNull T getSingle(@NotNull Class<T> type) {
return getSingle(type, Classifier.NONE);
}
@Override
public <T> @NotNull T getSingle(@NotNull Class<T> type, @NotNull String classifier) {
checkNotDisposed();
@Nullable InstanceFactory<T> factory = instanceManager
.getFilteredInstanceFactory(type, classifier, this);
T object = findOrInjectOptional(type, classifier, factory, CARDINALITY_SINGLE);
if (object == null) {
throw new IllegalStateException(
String.format(
"Instance of type '%s' (classifier: '%s') was not found in scopes.",
type.getName(), classifier
)
);
}
return object;
}
@Override
public <T> @NotNull List<T> getMany(@NotNull Class<T> type) {
checkNotDisposed();
return getManyObjects(type, Classifier.NONE);
}
@Override
public <T> @NotNull List<T> getMany(@NotNull Class<T> type, @NotNull String classifier) {
checkNotDisposed();
return getManyObjects(type, classifier);
}
@Override
public <T> @NotNull Scope bind(@NotNull Class<T> type, @NotNull T object) {
bind(type, object, Classifier.NONE);
return this;
}
@Override
public <T> @NotNull Scope bind(
@NotNull Class<T> type, @NotNull T object, @NotNull String classifier
) {
checkNotDisposed();
final String key = key(type, classifier);
Object existing = instanceBuckets.put(
key,
new InstanceBucket<>(
/* scope = */ this,
/* factory = */ null,
/* instanceType = */ type,
/* instance = */ object,
/* classifier = */ classifier,
/* listener = */ this
)
);
if (existing != null) {
throw new IllegalStateException(
String.format(
"Instance of type %s already registered. Existing instance %s, new instance %s",
key, existing, object
)
);
}
return this;
}
@Override
public @NotNull Scope createSubscope() {
checkNotDisposed();
MagnetScope child = new MagnetScope(this, instanceManager);
childrenScopes = new WeakScopeReference(child, childrenScopes);
return child;
}
@Override
public @NotNull Scope limit(String... limits) {
if (this.limits != null) {
throw new IllegalStateException(
String.format(
"Cannot set limits to '%s' because they must only be applied once." +
" Current limits '%s'", Arrays.toString(limits), Arrays.toString(this.limits))
);
}
for (String limit : limits) {
if (limit.length() == 0 || limit.equals("*")) {
throw new IllegalStateException("Limit must not be empty or be a '*'");
}
}
Arrays.sort(limits);
this.limits = limits;
return this;
}
@Override
@SuppressWarnings("unchecked")
public void dispose() {
if (disposed) return;
WeakScopeReference weakScope = childrenScopes;
if (weakScope != null) {
do {
MagnetScope scope = weakScope.get();
if (scope != null) {
scope.dispose();
}
weakScope = weakScope.next;
} while (weakScope != null);
}
if (disposables != null) {
for (int i = disposables.size(); i-- > 0; ) {
InstanceBucket.InjectedInstance single = disposables.get(i);
single.factory.dispose(single.object);
}
}
disposed = true;
if (parent != null) {
parent.onChildScopeDisposed(this);
}
}
@Override
public boolean isDisposed() {
return disposed;
}
private void onChildScopeDisposed(MagnetScope childScope) {
if (childrenScopes == null) return;
WeakScopeReference prevWeakScope = null;
WeakScopeReference weakScope = childrenScopes;
do {
MagnetScope scope = weakScope.get();
if (scope == childScope) {
if (prevWeakScope == null) {
childrenScopes = weakScope.next;
} else {
prevWeakScope.next = weakScope.next;
}
break;
}
prevWeakScope = weakScope;
weakScope = weakScope.next;
} while (weakScope != null);
}
@Override
public <T> void onInstanceCreated(InstanceBucket.SingleObjectInstance<T> instance) {
if (instance instanceof InstanceBucket.InjectedInstance) {
InstanceBucket.InjectedInstance injected = (InstanceBucket.InjectedInstance) instance;
if (injected.factory.isDisposable()) {
if (disposables == null) {
disposables = new ArrayList<>(8);
}
disposables.add(injected);
}
}
}
private void checkNotDisposed() {
if (disposed) throw new IllegalStateException("Scope is already disposed.");
}
@Override
public boolean filter(@NotNull InstanceFactory factory) {
String[] selector = factory.getSelector();
if (selector == null) {
return true;
}
SelectorFilter selectorFilter = getOptional(SelectorFilter.class, selector[0]);
if (selectorFilter == null) {
throw new IllegalStateException(
String.format(
"Factory %s requires selector '%s', which implementation is not available in the scope." +
" Make sure to add corresponding %s implementation to the classpath.",
factory, Arrays.toString(selector), SelectorFilter.class)
);
}
return selectorFilter.filter(selector);
}
private <T> @NotNull List<T> getManyObjects(Class<T> type, String classifier) {
List<InstanceFactory<T>> factories = instanceManager.getManyInstanceFactories(type, classifier, this);
if (factories.size() == 0) return Collections.emptyList();
List<T> objects = new ArrayList<>(factories.size());
for (InstanceFactory<T> factory : factories) {
T object = findOrInjectOptional(type, classifier, factory, CARDINALITY_MANY);
if (object != null) objects.add(object);
}
return objects;
}
@SuppressWarnings("unchecked")
private <T> @Nullable T findOrInjectOptional(
@NotNull Class<T> objectType,
@NotNull String classifier,
@Nullable InstanceFactory<T> factory,
byte cardinality
) {
@NotNull InstantiationContext instantiationContext = this.instantiationContext.get();
@NotNull String key = key(objectType, classifier);
InstanceBucket<T> deepInstanceBucket = findDeepInstanceBucket(key, factory);
if (factory == null) {
if (deepInstanceBucket == null) {
if (cardinality == CARDINALITY_SINGLE) {
throw new IllegalStateException(
String.format(
"Instance of type '%s' (classifier: '%s') was not found in scopes.",
objectType.getName(), classifier));
}
return null;
}
instantiationContext.onDependencyFound(deepInstanceBucket.getScope().depth, key);
return deepInstanceBucket.getSingleInstance();
}
boolean keepInScope = factory.getScoping() != Scoping.UNSCOPED;
if (keepInScope) {
if (deepInstanceBucket != null) {
boolean isSingleOrOptional = cardinality != CARDINALITY_MANY;
if (isSingleOrOptional) {
instantiationContext.onDependencyFound(deepInstanceBucket.getScope().depth, key);
return deepInstanceBucket.getSingleInstance();
}
T object = deepInstanceBucket.getOptional((Class<InstanceFactory<T>>) factory.getClass());
if (object != null) {
instantiationContext.onDependencyFound(deepInstanceBucket.getScope().depth, key);
return object;
}
}
}
instantiationContext.onBeginInstantiation(key);
T object = factory.create(this);
Instantiation instantiation = instantiationContext.onEndInstantiation();
int objectDepth = instantiation.dependencyDepth;
Scoping objectScoping = factory.getScoping();
@NotNull String objectLimit = factory.getLimit();
if (objectLimit.length() > 0) {
if (objectScoping == Scoping.TOPMOST) {
objectDepth = findTopMostLimitedObjectDepth(objectLimit, objectDepth);
} else if (objectScoping == Scoping.DIRECT) {
objectDepth = findDirectLimitedObjectDepth(
objectLimit, objectDepth, object, objectType, classifier, instantiation
);
}
if (objectDepth < 0) throwLimitNotFound(object, objectType, classifier, objectLimit);
} else {
if (objectScoping == Scoping.DIRECT) objectDepth = this.depth;
}
instantiationContext.onDependencyFound(objectDepth, key);
if (keepInScope) {
boolean canRegisterAtDeepInstanceBucket = deepInstanceBucket != null
&& deepInstanceBucket.getScope().depth == objectDepth;
if (canRegisterAtDeepInstanceBucket) {
deepInstanceBucket.registerObject(factory, objectType, object, classifier);
} else {
registerInstanceInScope(
key,
objectDepth,
factory,
objectType,
object,
classifier
);
}
Class[] siblingFactoryTypes = factory.getSiblingTypes();
if (siblingFactoryTypes != null) {
for (int i = 0, size = siblingFactoryTypes.length; i < size; i += 2) {
Class siblingObjectType = siblingFactoryTypes[i];
String siblingKey = key(siblingObjectType, classifier);
InstanceFactory siblingFactory = instanceManager.getInstanceFactory(
siblingObjectType, classifier, siblingFactoryTypes[i + 1]
);
registerInstanceInScope(
siblingKey,
objectDepth,
siblingFactory,
siblingObjectType,
object,
classifier
);
}
}
}
return object;
}
private int findTopMostLimitedObjectDepth(String objectLimit, int objectDepth) {
@Nullable MagnetScope scope = this;
while (scope != null) {
if (objectDepth > scope.depth) {
return objectDepth;
} else if (scope.hasLimit(objectLimit)) {
return scope.depth;
}
scope = scope.parent;
}
return -1;
}
private <T> int findDirectLimitedObjectDepth(
String objectLimit, int objectDepth, T object, Class<T> objectType, String classifier,
Instantiation instantiation
) {
@Nullable MagnetScope scope = this;
int limitingScopeDepth = -1;
while (scope != null) {
if (scope.hasLimit(objectLimit)) {
limitingScopeDepth = scope.depth;
break;
}
scope = scope.parent;
}
if (limitingScopeDepth > -1 && limitingScopeDepth < objectDepth) {
StringBuilder logDetails = new StringBuilder();
buildInstanceDetails(logDetails, object, objectType, classifier, objectLimit);
throw new IllegalStateException(
String.format(
"Cannot register instance in limiting scope [depth: %s] because its" +
" dependency '%s' is located in non-reachable child scope [depth: %s].\n%s",
limitingScopeDepth,
instantiation.dependencyKey,
instantiation.dependencyDepth,
logDetails
)
);
}
return limitingScopeDepth;
}
private boolean hasLimit(@NotNull String limit) {
if (limit.length() == 0 || limits == null) {
return false;
}
return Arrays.binarySearch(limits, limit) > -1;
}
private <T> void registerInstanceInScope(
@NotNull String key,
int depth,
@Nullable InstanceFactory<T> factory,
@NotNull Class<T> objectType,
@NotNull T object,
@NotNull String classifier
) {
if (this.depth == depth) {
@SuppressWarnings("unchecked") final InstanceBucket<T> bucket = instanceBuckets.get(key);
if (bucket == null) {
instanceBuckets.put(
key,
new InstanceBucket<>(this, factory, objectType, object, classifier, this)
);
} else {
bucket.registerObject(factory, objectType, object, classifier);
}
return;
}
if (parent == null) {
throw new IllegalStateException(
String.format(
"Cannot register instance %s, factory: %s, depth: %s",
object, factory, depth
)
);
}
parent.registerInstanceInScope(key, depth, factory, objectType, object, classifier);
}
@Nullable
@SuppressWarnings("unchecked")
private <T> InstanceBucket<T> findDeepInstanceBucket(
@NotNull String key, @Nullable InstanceFactory<T> factory
) {
@Nullable InstanceBucket<T> bucket = (InstanceBucket<T>) instanceBuckets.get(key);
if (bucket != null && bucket.hasInstanceWithFactory(factory)) return bucket;
if (parent == null) return null;
return parent.findDeepInstanceBucket(key, factory);
}
@NotNull
static String key(Class<?> type, String classifier) {
if (classifier == null || classifier.length() == 0) {
return type.getName();
}
return classifier + "@" + type.getName();
}
@Override
public void accept(Visitor visitor, int depth) {
acceptAtLevel(0, visitor, depth);
}
private void acceptAtLevel(int level, Visitor visitor, int depth) {
if (disposed) return;
boolean visitScopes = true;
if (visitor.onEnterScope(this, parent)) {
Collection<InstanceBucket> buckets = this.instanceBuckets.values();
for (InstanceBucket bucket : buckets) {
if (!bucket.accept(visitor)) {
visitScopes = false;
break;
}
}
}
if (visitScopes && level < depth) {
WeakScopeReference scopeRef = this.childrenScopes;
while (scopeRef != null) {
MagnetScope scope = scopeRef.get();
if (scope != null) scope.acceptAtLevel(level + 1, visitor, depth);
scopeRef = scopeRef.next;
}
}
visitor.onExitScope(this);
}
@Override public @Nullable String[] getLimits() {
return limits;
}
private static <T> void buildInstanceDetails(
StringBuilder builder, T object, Class<T> objectType, String classifier, String objectLimit
) {
builder
.append("Instance:")
.append("\n\tobject : ").append(object)
.append("\n\ttype : ").append(objectType.getName());
if (classifier.length() > 0) {
builder
.append("\n\tclassifier: '").append(classifier).append("'");
}
builder
.append("\n\tlimit : '").append(objectLimit).append("'");
}
private <T> void throwLimitNotFound(T object, Class<T> objectType, String classifier, String objectLimit) {
StringBuilder logDetail = new StringBuilder();
buildInstanceDetails(logDetail, object, objectType, classifier, objectLimit);
logDetail.append(" <- required limit");
logDetail.append("\n\nSearched scopes:\n\t-> ");
@Nullable MagnetScope scope = this;
while (scope != null) {
String scopeName = scope.toString();
if (scope.limits != null) {
logDetail.append('(');
for (String limit : scope.limits) {
logDetail.append("'").append(limit).append("', ");
}
logDetail.setLength(logDetail.length() - 2);
logDetail.append(") ").append(scope.toString());
} else logDetail.append(scopeName);
logDetail.append("\n\t-> ");
scope = scope.parent;
}
logDetail.setLength(logDetail.length() - 5);
logDetail.append(" <root scope>");
throw new IllegalStateException(
String.format(
"Cannot register instance because no scope with limit '%s' has been found.\n%s",
objectLimit, logDetail
)
);
}
private final static class InstantiationContext {
private final ArrayDeque<Instantiation> instantiations = new ArrayDeque<>();
private Instantiation currentInstantiation;
void onBeginInstantiation(String key) {
if (currentInstantiation != null) {
instantiations.addFirst(currentInstantiation);
}
currentInstantiation = new Instantiation(key);
if (instantiations.contains(currentInstantiation)) {
throw createCircularDependencyException();
}
}
@NotNull Instantiation onEndInstantiation() {
Instantiation instantiation = currentInstantiation;
currentInstantiation = instantiations.isEmpty() ? null : instantiations.pollFirst();
return instantiation;
}
void onDependencyFound(int dependencyDepth, @NotNull String dependencyKey) {
if (currentInstantiation == null) return;
if (dependencyDepth > currentInstantiation.dependencyDepth) {
currentInstantiation.dependencyDepth = dependencyDepth;
currentInstantiation.dependencyKey = dependencyKey;
}
}
private IllegalStateException createCircularDependencyException() {
Instantiation[] objects = instantiations.toArray(new Instantiation[0]);
StringBuilder builder = new StringBuilder()
.append("Dependency injection failed because of unresolved circular dependency: ");
for (int i = objects.length; i-- > 0; ) {
builder.append(objects[i].key).append(" -> ");
}
builder.append(currentInstantiation.key);
return new IllegalStateException(builder.toString());
}
}
private final static class Instantiation {
final String key;
int dependencyDepth;
@Nullable String dependencyKey;
Instantiation(String key) {
this.key = key;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Instantiation that = (Instantiation) o;
return key.equals(that.key);
}
@Override
public int hashCode() {
return key.hashCode();
}
}
private final static class WeakScopeReference extends WeakReference<MagnetScope> {
private @Nullable WeakScopeReference next;
WeakScopeReference(MagnetScope referent, @Nullable WeakScopeReference next) {
super(referent);
this.next = next;
}
}
}
================================================
FILE: magnet/src/main/java/magnet/internal/Range.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet.internal;
/* Subject to change. For internal use only. */
final class Range {
private final int from;
private final int count;
private final String classifier;
public Range(int from, int count, String classifier) {
this.from = from;
this.count = count;
this.classifier = classifier;
}
public int getFrom() {
return from;
}
public int getCount() {
return count;
}
public String getClassifier() {
return classifier;
}
}
================================================
FILE: magnet/src/test/java/magnet/internal/FactoryFilter_MagnetInstanceManagerTest.java
================================================
package magnet.internal;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import magnet.Classifier;
@RunWith(MockitoJUnitRunner.Silent.class)
public class FactoryFilter_MagnetInstanceManagerTest {
private MagnetInstanceManager instanceManager;
@Mock FactoryFilter factoryFilter;
@Mock InstanceFactory<Interface1> instanceFactory1;
@Mock InstanceFactory<Interface2> instanceFactory21;
@Mock InstanceFactory<Interface2> instanceFactory22;
@Before
public void before() {
instanceManager = new MagnetInstanceManager();
InstanceFactory[] factories = new InstanceFactory[]{
instanceFactory1,
instanceFactory21,
instanceFactory22,
};
Map<Class, Object> index = new HashMap<>();
index.put(Interface1.class, new Range(0, 1, Classifier.NONE));
index.put(Interface2.class, new Range(1, 2, Classifier.NONE));
instanceManager.register(factories, index);
}
@Test
public void getOptionalFactoryReturnsFactoryWhenFilterReturnsTrue() {
when(factoryFilter.filter(instanceFactory1)).thenReturn(true);
InstanceFactory<Interface1> factory = instanceManager
.getFilteredInstanceFactory(Interface1.class, Classifier.NONE, factoryFilter);
assertThat(factory).isSameInstanceAs(instanceFactory1);
}
@Test
public void getOptionalFactoryReturnsNullWhenFilterReturnsTrue() {
when(factoryFilter.filter(instanceFactory1)).thenReturn(false);
InstanceFactory<Interface1> factory = instanceManager
.getFilteredInstanceFactory(Interface1.class, Classifier.NONE, factoryFilter);
assertThat(factory).isNull();
}
@Test
public void getOptionalFactoryReturnsFactoryWhenOneOfFiltersReturnsTrue() {
when(factoryFilter.filter(instanceFactory21)).thenReturn(false);
when(factoryFilter.filter(instanceFactory22)).thenReturn(true);
InstanceFactory<Interface2> factory = instanceManager
.getFilteredInstanceFactory(Interface2.class, Classifier.NONE, factoryFilter);
assertThat(factory).isSameInstanceAs(instanceFactory22);
}
@Test
public void getOptionalFactoryReturnsNullWhenAllFiltersReturnFalse() {
when(factoryFilter.filter(instanceFactory21)).thenReturn(false);
when(factoryFilter.filter(instanceFactory22)).thenReturn(false);
InstanceFactory<Interface2> factory = instanceManager
.getFilteredInstanceFactory(Interface2.class, Classifier.NONE, factoryFilter);
assertThat(factory).isNull();
}
@Test(expected = IllegalStateException.class)
public void getOptionalFactoryFailsWhenMultipleFactoriesDetected() {
when(factoryFilter.filter(instanceFactory21)).thenReturn(true);
when(factoryFilter.filter(instanceFactory22)).thenReturn(true);
instanceManager.getFilteredInstanceFactory(Interface2.class, Classifier.NONE, factoryFilter);
}
@Test
public void getManyFactoriesReturnsEmptyListWhenAllFiltersReturnFalse() {
when(instanceFactory21.getSelector()).thenReturn(new String[]{"test"});
when(instanceFactory22.getSelector()).thenReturn(new String[]{"test"});
when(factoryFilter.filter(instanceFactory21)).thenReturn(false);
when(factoryFilter.filter(instanceFactory22)).thenReturn(false);
List<InstanceFactory<Interface2>> factories = instanceManager
.getManyInstanceFactories(Interface2.class, Classifier.NONE, factoryFilter);
assertThat(factories).isNotNull();
assertThat(factories).isEmpty();
}
@Test
public void getManyFactoriesReturnsSingleFactoryWhenSingleFilterReturnsTrue() {
when(instanceFactory21.getSelector()).thenReturn(new String[]{"test"});
when(instanceFactory22.getSelector()).thenReturn(new String[]{"test"});
when(factoryFilter.filter(instanceFactory21)).thenReturn(false);
when(factoryFilter.filter(instanceFactory22)).thenReturn(true);
List<InstanceFactory<Interface2>> factories = instanceManager
.getManyInstanceFactories(Interface2.class, Classifier.NONE, factoryFilter);
assertThat(factories).isNotNull();
assertThat(factories).hasSize(1);
assertThat(factories.get(0)).isSameInstanceAs(instanceFactory22);
}
@Test
public void getManyFactoriesReturnsAllFactoriesWhenAllFiltersReturnTrue() {
when(instanceFactory21.getSelector()).thenReturn(new String[]{"test"});
when(instanceFactory22.getSelector()).thenReturn(new String[]{"test"});
when(factoryFilter.filter(instanceFactory21)).thenReturn(true);
when(factoryFilter.filter(instanceFactory22)).thenReturn(true);
List<InstanceFactory<Interface2>> factories = instanceManager
.getManyInstanceFactories(Interface2.class, Classifier.NONE, factoryFilter);
assertThat(factories).isNotNull();
assertThat(factories).hasSize(2);
assertThat(factories.get(0)).isSameInstanceAs(instanceFactory21);
assertThat(factories.get(1)).isSameInstanceAs(instanceFactory22);
}
@Test
public void getManyFactoriesReturnsAllFactoriesWhenNoSelectorsDefined() {
when(instanceFactory21.getSelector()).thenReturn(null);
when(instanceFactory22.getSelector()).thenReturn(null);
List<InstanceFactory<Interface2>> factories = instanceManager
.getManyInstanceFactories(Interface2.class, Classifier.NONE, factoryFilter);
verify(factoryFilter, never()).filter(any());
assertThat(factories).isNotNull();
assertThat(factories).hasSize(2);
assertThat(factories.get(0)).isSameInstanceAs(instanceFactory21);
assertThat(factories.get(1)).isSameInstanceAs(instanceFactory22);
}
@Test
public void getManyFactoriesReturnsFactoriesWhenSomeFactoriesHaveSelectors() {
when(instanceFactory21.getSelector()).thenReturn(null);
when(instanceFactory22.getSelector()).thenReturn(new String[]{"test"});
when(factoryFilter.filter(instanceFactory22)).thenReturn(true);
List<InstanceFactory<Interface2>> factories = instanceManager
.getManyInstanceFactories(Interface2.class, Classifier.NONE, factoryFilter);
verify(factoryFilter, never()).filter(instanceFactory21);
assertThat(factories).isNotNull();
assertThat(factories).hasSize(1);
assertThat(factories.get(0)).isSameInstanceAs(instanceFactory22);
}
interface Interface1 {}
interface Interface2 {}
}
================================================
FILE: magnet/src/test/java/magnet/internal/FactoryFilter_MagnetScopeTest.java
================================================
package magnet.internal;
import magnet.SelectorFilter;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.Silent.class)
public class FactoryFilter_MagnetScopeTest {
private InstrumentedScope scope;
@Mock InstanceManager instanceManager;
@Mock InstanceFactory instanceFactory;
@Mock SelectorFilter selectorFilter;
@Before
public void before() {
scope = new InstrumentedScope(new MagnetScope(null, instanceManager));
}
@Test
public void noSelectorReturnsTrue() {
when(instanceFactory.getSelector()).thenReturn(null);
boolean result = scope.filter(instanceFactory);
assertThat(result).isTrue();
}
@Test(expected = IllegalStateException.class)
public void missingSelectorFactoryThrows() {
when(instanceFactory.getSelector()).thenReturn(new String[]{"test"});
scope.filter(instanceFactory);
}
@Test
public void existingSelectorReturnsFilterTrue() {
scope.bind(SelectorFilter.class, selectorFilter, "test");
when(instanceFactory.getSelector()).thenReturn(new String[]{"test"});
when(selectorFilter.filter(any())).thenReturn(true);
boolean result = scope.filter(instanceFactory);
assertThat(result).isTrue();
}
@Test
public void existingSelectorReturnsFilterFalse() {
scope.bind(SelectorFilter.class, selectorFilter, "test");
when(instanceFactory.getSelector()).thenReturn(new String[]{"test"});
when(selectorFilter.filter(any())).thenReturn(false);
boolean result = scope.filter(instanceFactory);
assertThat(result).isFalse();
}
}
================================================
FILE: magnet/src/test/java/magnet/internal/InstanceBucketTest.java
================================================
package magnet.internal;
import magnet.Classifier;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import java.util.List;
import static com.google.common.truth.Truth.assertThat;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class InstanceBucketTest {
@Mock private Factory1 factory1;
@Mock private Factory2 factory2;
@Mock private Interface1 instance1;
@Mock private Interface1 instance2;
@Mock private InstanceBucket.OnInstanceListener listener;
@Mock private MagnetScope scope;
@Test
@SuppressWarnings("unchecked")
public void test_getScope() {
InstanceBucket<String> instances = new InstanceBucket(
scope, factory1, Interface1.class, instance1, Classifier.NONE, listener
);
assertThat(instances.getScope()).isSameInstanceAs(scope);
}
@Test
@SuppressWarnings("unchecked")
public void test_getInstances_SingleItem() {
InstanceBucket<Interface1> instances = new InstanceBucket(
scope, factory1, Interface1.class, instance1, Classifier.NONE, listener
);
List<Interface1> result = instances.getMany();
assertThat(result).containsExactly(instance1);
}
@Test
@SuppressWarnings("unchecked")
public void test_getInstances_ManyItems() {
InstanceBucket<Interface1> instances = new InstanceBucket(
scope, factory1, Interface1.class, instance1, Classifier.NONE, listener
);
instances.registerObject(factory2, Interface1.class, instance2, Classifier.NONE);
List<Interface1> result = instances.getMany();
assertThat(result).containsExactly(instance1, instance2);
}
@Test
@SuppressWarnings("unchecked")
public void test_getSingleInstance() {
InstanceBucket<Interface1> instances = new InstanceBucket(
scope, factory1, Interface1.class, instance1, Classifier.NONE, listener
);
Interface1 result = instances.getSingleInstance();
assertThat(result).isSameInstanceAs(instance1);
}
interface Interface1 {}
abstract static class Factory1 extends InstanceFactory<Interface1> {}
abstract static class Factory2 extends InstanceFactory<Interface1> {}
}
================================================
FILE: magnet/src/test/java/magnet/internal/InstrumentedScope.java
================================================
package magnet.internal;
import magnet.Scope;
import magnet.Visitor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.List;
/** Used for testing MagnetScopeContainer. */
public class InstrumentedScope implements Scope, FactoryFilter {
public final MagnetScope scope;
public InstrumentedScope(MagnetScope scope) {
this.scope = scope;
}
public InstrumentedScope(Scope scope) {
this.scope = (MagnetScope) scope;
}
@Override public <T> @Nullable T getOptional(@NotNull Class<T> type) {
return scope.getOptional(type);
}
@Override public <T> @Nullable T getOptional(@NotNull Class<T> type, @NotNull String classifier) {
return scope.getOptional(type, classifier);
}
@Override public <T> @NotNull T getSingle(@NotNull Class<T> type) {
return scope.getSingle(type);
}
@Override public <T> @NotNull T getSingle(@NotNull Class<T> type, @NotNull String classifier) {
return scope.getSingle(type, classifier);
}
@Override public <T> @NotNull List<T> getMany(@NotNull Class<T> type) {
return scope.getMany(type);
}
@Override public <T> @NotNull List<T> getMany(@NotNull Class<T> type, @NotNull String classifier) {
return scope.getMany(type, classifier);
}
@Override public <T> @NotNull Scope bind(@NotNull Class<T> type, @NotNull T instance) {
scope.bind(type, instance);
return this;
}
@Override public <T> @NotNull Scope bind(@NotNull Class<T> type, @NotNull T instance, @NotNull String classifier) {
scope.bind(type, instance, classifier);
return this;
}
@Override public @NotNull Scope createSubscope() {
return new InstrumentedScope((MagnetScope) scope.createSubscope());
}
@Override public @NotNull Scope limit(String... limits) {
return scope.limit(limits);
}
@Override public void dispose() {
scope.dispose();
}
@Override public boolean isDisposed() {
return scope.isDisposed();
}
@Override public void accept(Visitor visitor, int depth) {
scope.accept(visitor, depth);
}
@Override public boolean filter(InstanceFactory factory) { return scope.filter(factory); }
/** Returns and object registered right in this scope or null if no object was registered. */
@SuppressWarnings("unchecked") <T> T getOptionalInScope(Class<T> type, String classifier) {
InstanceBucket<T> instance = scope.instanceBuckets.get(MagnetScope.key(type, classifier));
return instance == null ? null : instance.getSingleInstance();
}
/** Returns list of objects registered right in this scope. */
@SuppressWarnings("unchecked") <T> List<T> getManyInScope(Class<T> type, String classifier) {
InstanceBucket<T> instance = scope.instanceBuckets.get(MagnetScope.key(type, classifier));
return instance == null ? Collections.emptyList() : instance.getMany();
}
/** Injects given object right into the scope, as I would be injected using given factory. */
@SuppressWarnings("unchecked") public <T> InstrumentedScope instrumentObjectIntoScope(
InstanceFactory<T> factory, Class<T> objectType, T object, String classifier
) {
String key = MagnetScope.key(objectType, classifier);
InstanceBucket existing = scope.instanceBuckets.get(key);
if (existing == null) {
scope.instanceBuckets.put(
key,
new InstanceBucket(scope, factory, objectType, object, classifier, scope)
);
} else {
existing.registerObject(factory, objectType, object, classifier);
}
return this;
}
InstrumentedScope createInstrumentedSubscope() {
return new InstrumentedScope((MagnetScope) scope.createSubscope());
}
}
================================================
FILE: magnet/src/test/java/magnet/internal/MagnetInstanceManagerTest.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet.internal;
import magnet.Classifier;
import magnet.Scope;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.Silent.class)
public class MagnetInstanceManagerTest {
private static final String CLASSIFIER_LOCAL = "local";
@Mock InstanceFactory<Type1> instanceFactoryType1Impl1;
@Mock InstanceFactory<Type1> instanceFactoryType1Impl2;
@Mock InstanceFactory<Type2> instanceFactoryType2Impl1;
@Mock InstanceFactory<Type2> instanceFactoryType2Impl2;
@Mock InstanceFactory<Type3> instanceFactoryType3Impl1;
@Mock FactoryFilter factoryFilter;
@Mock Scope scope;
private MagnetInstanceManager instManager;
@Before
public void before() {
instManager = new MagnetInstanceManager();
when(factoryFilter.filter(any())).thenReturn(true);
when(instanceFactoryType1Impl1.create(scope)).thenReturn(new Type1Impl());
when(instanceFactoryType1Impl2.create(scope)).thenReturn(new Type1Impl());
when(instanceFactoryType2Impl1.create(scope)).thenReturn(new Type2Impl());
when(instanceFactoryType2Impl2.create(scope)).thenReturn(new Type2Impl());
when(instanceFactoryType3Impl1.create(scope)).thenReturn(new Type3Impl());
InstanceFactory[] factories = new InstanceFactory[]{
instanceFactoryType1Impl1,
instanceFactoryType1Impl2,
instanceFactoryType2Impl1,
instanceFactoryType2Impl2,
instanceFactoryType3Impl1
};
Map<Class, Object> index = new HashMap<>();
Map<String, Range> ranges1 = new HashMap<>();
ranges1.put(Classifier.NONE, new Range(0, 1, Classifier.NONE));
ranges1.put(CLASSIFIER_LOCAL, new Range(1, 1, CLASSIFIER_LOCAL));
index.put(Type1.class, ranges1);
index.put(Type2.class, new Range(2, 2, Classifier.NONE));
index.put(Type3.class, new Range(4, 1, CLASSIFIER_LOCAL));
instManager.register(factories, index);
}
@Test
public void getOptionalFactory_Classified_Existing_SingleTypeInstance() {
// when
InstanceFactory<Type3> factory = instManager.getFilteredInstanceFactory(
Type3.class, CLASSIFIER_LOCAL, factoryFilter);
// then
assertThat(factory).isNotNull();
}
@Test
public void getOptionalFactory_Classified_Existing_ManyTypeInstances() {
// when
InstanceFactory<Type1> factory = instManager.getFilteredInstanceFactory(
Type1.class, CLASSIFIER_LOCAL, factoryFilter);
// then
assertThat(factory).isNotNull();
}
@Test
public void getOptionalFactory_NotClassified_Existing() {
// when
InstanceFactory<Type1> factory = instManager.getFilteredInstanceFactory(
Type1.class, Classifier.NONE, factoryFilter);
// then
assertThat(factory).isNotNull();
}
@Test
public void getOptionalFactory_Classified_NotExisting() {
// when
InstanceFactory<String> factory = instManager.getFilteredInstanceFactory(
String.class, CLASSIFIER_LOCAL, factoryFilter);
// then
assertThat(factory).isNull();
}
@Test
public void getOptionalFactory_NotClassified_NotExisting() {
// when
InstanceFactory<String> factory = instManager.getFilteredInstanceFactory(
String.class, Classifier.NONE, factoryFilter);
// then
assertThat(factory).isNull();
}
@Test
public void getManyFactories_NotClassified_ManyTypeInstances() {
// when
List<InstanceFactory<Type1>> factories = instManager.getManyInstanceFactories(
Type1.class, Classifier.NONE, factoryFilter);
// then
assertThat(factories).hasSize(1);
assertThat(factories.get(0)).isEqualTo(instanceFactoryType1Impl1);
}
@Test
public void getManyFactories_Classified_ManyTypeInstances() {
// when
List<InstanceFactory<Type1>> factories = instManager.getManyInstanceFactories(
Type1.class, CLASSIFIER_LOCAL, factoryFilter);
// then
assertThat(factories).hasSize(1);
assertThat(factories.get(0)).isEqualTo(instanceFactoryType1Impl2);
}
@Test
public void getManyFactories_NotClassified_SingleTypeInstances() {
// when
List<InstanceFactory<Type2>> factories = instManager.getManyInstanceFactories(
Type2.class, Classifier.NONE, factoryFilter);
// then
assertThat(factories).hasSize(2);
assertThat(factories).containsExactly(instanceFactoryType2Impl1, instanceFactoryType2Impl2);
}
@Test
public void getManyFactories_Classified_SingleTypeInstances() {
// when
List<InstanceFactory<Type3>> factories = instManager.getManyInstanceFactories(
Type3.class, CLASSIFIER_LOCAL, factoryFilter);
// then
assertThat(factories).hasSize(1);
assertThat(factories.get(0)).isEqualTo(instanceFactoryType3Impl1);
}
interface Type1 {}
interface Type2 {}
interface Type3 {}
class Type1Impl implements Type1 {}
class Type2Impl implements Type2 {}
class Type3Impl implements Type3 {}
}
================================================
FILE: magnet/src/test/java/magnet/internal/MagnetScope_CircularDependencyTest.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet.internal;
import magnet.Scope;
import magnet.Scoping;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RunWith(JUnit4.class)
public class MagnetScope_CircularDependencyTest {
private MagnetScope scope;
@Before
public void before() {
scope = new MagnetScope(null, new StubInstanceManager());
}
@Test(expected = IllegalStateException.class)
public void dependency_One_Two_Three_One() {
scope.getSingle(MenuItem.class, "one");
}
@Test(expected = IllegalStateException.class)
public void dependency_Four_Four() {
scope.getSingle(MenuItem.class, "four");
}
@Test(expected = IllegalStateException.class)
public void dependency_Five_Constructor_Five() {
scope.getSingle(MenuItem.class, "five");
}
private static class MenuItemOneFactory extends InstanceFactory<MenuItem> {
@Override public MenuItem create(Scope scope) {
scope.getSingle(MenuItem.class, "two");
return new MenuItemOne();
}
@Override public Scoping getScoping() { return Scoping.TOPMOST; }
}
private static class MenuItemTwoFactory extends InstanceFactory<MenuItem> {
@Override public MenuItem create(Scope scope) {
scope.getSingle(MenuItem.class, "three");
return new MenuItemTwo();
}
@Override public Scoping getScoping() { return Scoping.TOPMOST; }
}
private static class MenuItemThreeFactory extends InstanceFactory<MenuItem> {
@Override public MenuItem create(Scope scope) {
scope.getSingle(MenuItem.class, "one");
return new MenuItemThree();
}
@Override public Scoping getScoping() { return Scoping.TOPMOST; }
}
private static class MenuItemFourFactory extends InstanceFactory<MenuItem> {
@Override public MenuItem create(Scope scope) {
scope.getSingle(MenuItem.class, "four");
return new MenuItemFour();
}
@Override public Scoping getScoping() { return Scoping.TOPMOST; }
}
private static class MenuItemFiveFactory extends InstanceFactory<MenuItem> {
@Override public MenuItem create(Scope scope) {
return new MenuItemFive(scope);
}
@Override public Scoping getScoping() { return Scoping.TOPMOST; }
}
private static class StubInstanceManager implements InstanceManager {
private final Map<String, InstanceFactory<MenuItem>> factories;
StubInstanceManager() {
factories = new HashMap<>();
factories.put("one", new MenuItemOneFactory());
factories.put("two", new MenuItemTwoFactory());
factories.put("three", new MenuItemThreeFactory());
factories.put("four", new MenuItemFourFactory());
factories.put("five", new MenuItemFiveFactory());
}
@Override
public <T> InstanceFactory getInstanceFactory(
Class<T> instanceType, String classifier, Class<InstanceFactory<T>> factoryType
) {
throw new UnsupportedOperationException();
}
@Override public <T> InstanceFactory<T> getFilteredInstanceFactory(
Class<T> type, String classifier, FactoryFilter factoryFilter
) {
//noinspection unchecked
return (InstanceFactory<T>) factories.get(classifier);
}
@Override public <T> List<InstanceFactory<T>> getManyInstanceFactories(
Class<T> type, String classifier, FactoryFilter factoryFilter
) {
throw new UnsupportedOperationException();
}
}
private interface MenuItem {}
private static class MenuItemOne implements MenuItem {}
private static class MenuItemTwo implements MenuItem {}
private static class MenuItemThree implements MenuItem {}
private static class MenuItemFour implements MenuItem {}
private static class MenuItemFive implements MenuItem {
public MenuItemFive(Scope scope) {
scope.getSingle(MenuItem.class, "five");
}
}
}
================================================
FILE: magnet/src/test/java/magnet/internal/MagnetScope_DisposeTest.java
================================================
package magnet.internal;
import magnet.Classifier;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class MagnetScope_DisposeTest {
@Mock private InstanceManager instanceManager;
@Mock private Factory1 factory1;
@Mock private Factory2 factory2;
@Mock private Factory3 factory3;
@Mock private Factory4 factory4;
@Mock private Interface instance1;
@Mock private Interface instance2;
@Mock private Interface instance3;
@Mock private Interface instance4;
@Test
public void disposeSingleScope_NoClassifier() {
InstrumentedScope scope = new InstrumentedScope(
new MagnetScope(null, instanceManager)
);
when(factory1.isDisposable()).thenReturn(true);
scope.instrumentObjectIntoScope(factory1, Interface.class, instance1, Classifier.NONE);
scope.instrumentObjectIntoScope(factory2, Interface.class, instance2, Classifier.NONE);
when(factory3.isDisposable()).thenReturn(true);
scope.instrumentObjectIntoScope(factory3, Interface.class, instance3, Classifier.NONE);
scope.dispose();
verify(factory1, times(1)).dispose(instance1);
verify(factory2, never()).dispose(any());
verify(factory3, times(1)).dispose(instance3);
}
@Test
public void disposeSingleScope_WithClassifiers() {
InstrumentedScope scope = new InstrumentedScope(
new MagnetScope(null, instanceManager)
);
when(factory1.isDisposable()).thenReturn(true);
scope.instrumentObjectIntoScope(factory1, Interface.class, instance1, "classifier1");
scope.instrumentObjectIntoScope(factory2, Interface.class, instance2, "classifier2");
when(factory3.isDisposable()).thenReturn(true);
scope.instrumentObjectIntoScope(factory3, Interface.class, instance3, Classifier.NONE);
scope.dispose();
verify(factory1, times(1)).dispose(instance1);
verify(factory2, never()).dispose(any());
verify(factory3, times(1)).dispose(instance3);
}
@Test
public void disposingParentScope_DisposesChildrenScopes() {
MagnetScope parentScope;
InstrumentedScope parent = new InstrumentedScope(parentScope = new MagnetScope(null, instanceManager));
when(factory1.isDisposable()).thenReturn(true);
parent.instrumentObjectIntoScope(factory1, Interface.class, instance1, Classifier.NONE);
InstrumentedScope child = new InstrumentedScope((MagnetScope) parentScope.createSubscope());
when(factory2.isDisposable()).thenReturn(true);
child.instrumentObjectIntoScope(factory2, Interface.class, instance2, Classifier.NONE);
child.instrumentObjectIntoScope(factory3, Interface.class, instance3, Classifier.NONE);
parent.dispose();
verify(factory1, times(1)).dispose(instance1);
verify(factory2, times(1)).dispose(instance2);
verify(factory3, never()).dispose(instance3);
}
@Test
public void disposingChildScope_KeepsParentScopes() {
MagnetScope parentScope;
InstrumentedScope parent = new InstrumentedScope(parentScope = new MagnetScope(null, instanceManager));
parent.instrumentObjectIntoScope(factory1, Interface.class, instance1, Classifier.NONE);
InstrumentedScope child = new InstrumentedScope((MagnetScope) parentScope.createSubscope());
when(factory2.isDisposable()).thenReturn(true);
child.instrumentObjectIntoScope(factory2, Interface.class, instance2, Classifier.NONE);
child.dispose();
verify(factory2, times(1)).dispose(instance2);
verify(factory1, never()).dispose(any());
}
@Test(expected = IllegalStateException.class)
public void disposedScopeThrowsException() {
InstrumentedScope scope = new InstrumentedScope(
new MagnetScope(null, instanceManager)
);
when(factory1.isDisposable()).thenReturn(true);
scope.instrumentObjectIntoScope(factory1, Interface.class, instance1, "classifier1");
scope.dispose();
scope.getOptional(String.class);
}
@Test
public void disposeChildScope_InReversOrdered() {
InstrumentedScope scope = new InstrumentedScope(
new MagnetScope(null, instanceManager)
);
when(factory1.isDisposable()).thenReturn(true);
when(factory2.isDisposable()).thenReturn(true);
when(factory3.isDisposable()).thenReturn(true);
scope.instrumentObjectIntoScope(factory1, Interface.class, instance1, Classifier.NONE);
scope.instrumentObjectIntoScope(factory2, Interface.class, instance2, Classifier.NONE);
scope.instrumentObjectIntoScope(factory3, Interface.class, instance3, Classifier.NONE);
scope.dispose();
InOrder order = inOrder(factory3, factory2, factory1);
order.verify(factory3, times(1)).dispose(instance3);
order.verify(factory2, times(1)).dispose(instance2);
order.verify(factory1, times(1)).dispose(instance1);
}
@Test
public void disposeParentScope_InReversOrdered() {
when(factory1.isDisposable()).thenReturn(true);
when(factory2.isDisposable()).thenReturn(true);
when(factory3.isDisposable()).thenReturn(true);
MagnetScope parentScope;
InstrumentedScope parent = new InstrumentedScope(parentScope = new MagnetScope(null, instanceManager));
parent.instrumentObjectIntoScope(factory1, Interface.class, instance1, Classifier.NONE);
InstrumentedScope child = new InstrumentedScope((MagnetScope) parentScope.createSubscope());
when(factory2.isDisposable()).thenReturn(true);
child.instrumentObjectIntoScope(factory2, Interface.class, instance2, Classifier.NONE);
parent.instrumentObjectIntoScope(factory3, Interface.class, instance3, Classifier.NONE);
parent.dispose();
InOrder order = inOrder(factory2, factory3, factory1);
order.verify(factory2, times(1)).dispose(instance2);
order.verify(factory3, times(1)).dispose(instance3);
order.verify(factory1, times(1)).dispose(instance1);
}
@Test
public void disposeFirstChildThenParentScopes() {
when(factory1.isDisposable()).thenReturn(true);
InstrumentedScope parent =
new InstrumentedScope(new MagnetScope(null, instanceManager))
.instrumentObjectIntoScope(factory1, Interface.class, instance1, Classifier.NONE);
when(factory2.isDisposable()).thenReturn(true);
InstrumentedScope child =
parent.createInstrumentedSubscope()
.instrumentObjectIntoScope(factory2, Interface.class, instance2, Classifier.NONE);
child.dispose();
parent.dispose();
InOrder order = inOrder(factory2, factory1);
order.verify(factory2, times(1)).dispose(instance2);
order.verify(factory1, times(1)).dispose(instance1);
}
@Test
public void disposeMultipleChildScopes_123() {
InstrumentedScope[] child = prepareMultipleChildrenScopes();
child[1].dispose();
child[2].dispose();
child[3].dispose();
child[0].dispose();
InOrder order = inOrder(factory2, factory3, factory4, factory1);
order.verify(factory2, times(1)).dispose(instance2);
order.verify(factory3, times(1)).dispose(instance3);
order.verify(factory4, times(1)).dispose(instance4);
order.verify(factory1, times(1)).dispose(instance1);
}
@Test
public void disposeMultipleChildScopes_132() {
InstrumentedScope[] child = prepareMultipleChildrenScopes();
child[1].dispose();
child[3].dispose();
child[2].dispose();
child[0].dispose();
InOrder order = inOrder(factory2, factory4, factory3, factory1);
order.verify(factory2, times(1)).dispose(instance2);
order.verify(factory4, times(1)).dispose(instance4);
order.verify(factory3, times(1)).dispose(instance3);
order.verify(factory1, times(1)).dispose(instance1);
}
@Test
public void disposeMultipleChildScopes_213() {
InstrumentedScope[] child = prepareMultipleChildrenScopes();
child[2].dispose();
child[1].dispose();
child[3].dispose();
child[0].dispose();
InOrder order = inOrder(factory3, factory2, factory4, factory1);
order.verify(factory3, times(1)).dispose(instance3);
order.verify(factory2, times(1)).dispose(instance2);
order.verify(factory4, times(1)).dispose(instance4);
order.verify(factory1, times(1)).dispose(instance1);
}
@Test
public void disposeMultipleChildScopes_231() {
InstrumentedScope[] child = prepareMultipleChildrenScopes();
child[2].dispose();
child[3].dispose();
child[1].dispose();
child[0].dispose();
InOrder order = inOrder(factory3, factory4, factory2, factory1);
order.verify(factory3, times(1)).dispose(instance3);
order.verify(factory4, times(1)).dispose(instance4);
order.verify(factory2, times(1)).dispose(instance2);
order.verify(factory1, times(1)).dispose(instance1);
}
@Test
public void disposeMultipleChildScopes_312() {
InstrumentedScope[] child = prepareMultipleChildrenScopes();
child[3].dispose();
child[1].dispose();
child[2].dispose();
child[0].dispose();
InOrder order = inOrder(factory4, factory2, factory3, factory1);
order.verify(factory4, times(1)).dispose(instance4);
order.verify(factory2, times(1)).dispose(instance2);
order.verify(factory3, times(1)).dispose(instance3);
order.verify(factory1, times(1)).dispose(instance1);
}
@Test
public void disposeMultipleChildScopes_321() {
InstrumentedScope[] child = prepareMultipleChildrenScopes();
child[3].dispose();
child[2].dispose();
child[1].dispose();
child[0].dispose();
InOrder order = inOrder(factory4, factory3, factory2, factory1);
order.verify(factory4, times(1)).dispose(instance4);
order.verify(factory3, times(1)).dispose(instance3);
order.verify(factory2, times(1)).dispose(instance2);
order.verify(factory1, times(1)).dispose(instance1);
}
private InstrumentedScope[] prepareMultipleChildrenScopes() {
when(factory1.isDisposable()).thenReturn(true);
InstrumentedScope parent =
new InstrumentedScope(new MagnetScope(null, instanceManager))
.instrumentObjectIntoScope(factory1, Interface.class, instance1, Classifier.NONE);
when(factory2.isDisposable()).thenReturn(true);
InstrumentedScope child1 =
parent.createInstrumentedSubscope()
.instrumentObjectIntoScope(factory2, Interface.class, instance2, Classifier.NONE);
when(factory3.isDisposable()).thenReturn(true);
InstrumentedScope child2 =
parent.createInstrumentedSubscope()
.instrumentObjectIntoScope(factory3, Interface.class, instance3, Classifier.NONE);
when(factory4.isDisposable()).thenReturn(true);
InstrumentedScope child3 =
parent.createInstrumentedSubscope()
.instrumentObjectIntoScope(factory4, Interface.class, instance4, Classifier.NONE);
return new InstrumentedScope[]{parent, child1, child2, child3};
}
interface Interface {}
abstract static class Factory1 extends InstanceFactory<Interface> {}
abstract static class Factory2 extends InstanceFactory<Interface> {}
abstract static class Factory3 extends InstanceFactory<Interface> {}
abstract static class Factory4 extends InstanceFactory<Interface> {}
}
================================================
FILE: magnet/src/test/java/magnet/internal/MagnetScope_FindDeepForSiblingTypesTest.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet.internal;
import magnet.Classifier;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.Silent.class)
public class MagnetScope_FindDeepForSiblingTypesTest {
@Mock private Implementation1Factory factory1;
@Mock private SiblingImplementation1Factory factory21;
@Mock private SiblingImplementation2Factory factory22;
@Mock private Implementation instance1;
@Mock private SiblingImplementation instance2;
private MagnetInstanceManager instanceManager;
@Before
public void before() {
instanceManager = new MagnetInstanceManager();
InstanceFactory[] factories = new InstanceFactory[]{factory1, factory21, factory22};
Map<Class, Object> index = new HashMap<>();
index.put(Interface.class, new Range(0, 2, Classifier.NONE));
index.put(SiblingInterface.class, new Range(2, 1, Classifier.NONE));
instanceManager.register(factories, index);
when(factory1.create(any())).thenReturn(Mockito.mock(Interface.class));
when(factory21.create(any())).thenReturn(Mockito.mock(Interface.class));
when(factory22.create(any())).thenReturn(Mockito.mock(SiblingInterface.class));
when(factory21.getSiblingTypes()).thenReturn(new Class[]{SiblingInterface.class, SiblingImplementation2Factory.class});
when(factory22.getSiblingTypes()).thenReturn(new Class[]{Interface.class, SiblingImplementation1Factory.class});
}
@Test
public void getMany_collectsAlsoSiblingInstancesFromScope() {
// given
InstrumentedScope scope0 = new InstrumentedScope(
new MagnetScope(null, instanceManager)
);
scope0.instrumentObjectIntoScope(factory21, Interface.class, instance2, Classifier.NONE);
scope0.instrumentObjectIntoScope(factory22, SiblingInterface.class, instance2, Classifier.NONE);
InstrumentedScope scope1 = (InstrumentedScope) scope0.createSubscope();
scope1.instrumentObjectIntoScope(factory1, Interface.class, instance1, Classifier.NONE);
// when
List<Interface> many = scope1.getMany(Interface.class);
// then
assertThat(many).containsExactly(instance1, instance2);
}
// -- configuration
private interface Interface {}
private interface SiblingInterface {}
private static class Implementation implements Interface {}
private static class SiblingImplementation implements Interface, SiblingInterface {}
private abstract static class Implementation1Factory extends InstanceFactory<Interface> {}
private abstract static class SiblingImplementation1Factory extends InstanceFactory<Interface> {}
private abstract static class SiblingImplementation2Factory extends InstanceFactory<SiblingInterface> {}
}
================================================
FILE: magnet/src/test/java/magnet/internal/MagnetScope_GetManyTest.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet.internal;
import magnet.Scope;
import magnet.Scoping;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.google.common.truth.Truth.assertThat;
@RunWith(JUnit4.class)
public class MagnetScope_GetManyTest {
private InstrumentedScope scope1;
private InstrumentedScope scope2;
@Before
public void before() {
scope1 = new InstrumentedScope(
new MagnetScope(null, new StubInstanceManager()));
scope2 = (InstrumentedScope) scope1
.createSubscope()
.bind(Dependency2.class, new Dependency2());
}
@Test
public void getSingleScopedMany() {
// when
List<MenuItem> oneList = scope1.getMany(MenuItem.class, "one");
// then
assertThat(oneList).hasSize(3);
assertThat(oneList).containsNoDuplicates();
List<MenuItem> onesInScope = scope1.getManyInScope(MenuItem.class, "one");
assertThat(onesInScope).hasSize(3);
assertThat(onesInScope).containsNoDuplicates();
assertThat(onesInScope).containsAtLeastElementsIn(oneList);
}
@Test(expected = IllegalStateException.class)
public void getMultiScopedMany_requestScope1() {
scope1.getMany(MenuItem.class, "two");
}
@Test
public void getMultiScopedMany_requestScope2() {
// when
List<MenuItem> twoList = scope2.getMany(MenuItem.class, "two");
// then
assertThat(twoList).hasSize(2);
assertThat(twoList).containsNoDuplicates();
List<MenuItem> oneScope1 = scope1.getManyInScope(MenuItem.class, "one");
List<MenuItem> twoScope1 = scope1.getManyInScope(MenuItem.class, "two");
List<MenuItem> oneScope2 = scope2.getManyInScope(MenuItem.class, "one");
List<MenuItem> twoScope2 = scope2.getManyInScope(MenuItem.class, "two");
assertThat(oneScope1).hasSize(3);
assertThat(twoScope1).hasSize(1);
assertThat(oneScope2).hasSize(0);
assertThat(twoScope2).hasSize(1);
assertThat(twoList).contains(twoScope1.get(0));
assertThat(twoList).contains(twoScope2.get(0));
}
private static class MenuItemOne1Factory extends InstanceFactory<MenuItem> {
@Override public MenuItem create(Scope scope) {
return new MenuItemOne1();
}
@Override public Scoping getScoping() { return Scoping.TOPMOST; }
}
private static class MenuItemOne2Factory extends InstanceFactory<MenuItem> {
@Override public MenuItem create(Scope scope) {
return new MenuItemOne2();
}
@Override public Scoping getScoping() { return Scoping.TOPMOST; }
}
private static class MenuItemOne3Factory extends InstanceFactory<MenuItem> {
@Override public MenuItem create(Scope scope) {
return new MenuItemOne3();
}
@Override public Scoping getScoping() { return Scoping.TOPMOST; }
}
private static class MenuItemTwo1Factory extends InstanceFactory<MenuItem> {
@Override public MenuItem create(Scope scope) {
return new MenuItemTwo1();
}
@Override public Scoping getScoping() { return Scoping.TOPMOST; }
}
private static class MenuItemTwo2Factory extends InstanceFactory<MenuItem> {
@Override public MenuItem create(Scope scope) {
scope.getSingle(Dependency2.class);
scope.getMany(MenuItem.class, "one");
return new MenuItemTwo2();
}
@Override public Scoping getScoping() { return Scoping.TOPMOST; }
}
@SuppressWarnings("unchecked")
private static class StubInstanceManager implements InstanceManager {
private final Map<String, Object> factories;
StubInstanceManager() {
factories = new HashMap<>();
List<InstanceFactory> oneList = new ArrayList<>();
oneList.add(new MenuItemOne1Factory());
oneList.add(new MenuItemOne2Factory());
oneList.add(new MenuItemOne3Factory());
factories.put("one", oneList);
List<InstanceFactory> twoList = new ArrayList<>();
twoList.add(new MenuItemTwo1Factory());
twoList.add(new MenuItemTwo2Factory());
factories.put("two", twoList);
}
@Override
public <T> InstanceFactory getInstanceFactory(
Class<T> instanceType, String classifier, Class<InstanceFactory<T>> factoryType
) {
throw new UnsupportedOperationException();
}
@Override public <T> InstanceFactory<T> getFilteredInstanceFactory(
Class<T> type, String classifier, FactoryFilter factoryFilter
) {
return (InstanceFactory<T>) factories.get(classifier);
}
@Override public <T> List<InstanceFactory<T>> getManyInstanceFactories(
Class<T> type, String classifier, FactoryFilter factoryFilter
) {
return (List<InstanceFactory<T>>) factories.get(classifier);
}
}
private interface MenuItem {}
private static class MenuItemOne1 implements MenuItem {}
private static class MenuItemOne2 implements MenuItem {}
private static class MenuItemOne3 implements MenuItem {}
private static class MenuItemTwo1 implements MenuItem {}
private static class MenuItemTwo2 implements MenuItem {}
private static class Dependency2 {}
}
================================================
FILE: magnet/src/test/java/magnet/internal/MagnetScope_ManyInstancesInMultipleScopesTest.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet.internal;
import magnet.Classifier;
import magnet.Scope;
import magnet.Scoping;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.ArrayList;
import java.util.List;
import static com.google.common.truth.Truth.assertThat;
@RunWith(JUnit4.class)
public class MagnetScope_ManyInstancesInMultipleScopesTest {
private InstrumentedScope scope1;
private InstrumentedScope scope2;
private InstrumentedScope scope3;
private InstanceImpl1Factory factory1 = new InstanceImpl1Factory();
private InstanceImpl2Factory factory2 = new InstanceImpl2Factory();
private InstanceImpl3Factory factory3 = new InstanceImpl3Factory();
@Before
public void before() {
scope1 = new InstrumentedScope(new MagnetScope(null, new StubInstanceManager()));
scope1.instrumentObjectIntoScope(factory1, InstanceType.class, new InstanceImpl1(), Classifier.NONE);
scope2 = (InstrumentedScope) scope1.createSubscope();
scope2.instrumentObjectIntoScope(factory2, InstanceType.class, new InstanceImpl2(), Classifier.NONE);
scope3 = (InstrumentedScope) scope2.createSubscope();
}
@Test
public void getSingleScopedMany() {
// given
// when
List<InstanceType> instances = scope3.getMany(InstanceType.class, "");
// then
assertThat(instances).hasSize(3);
assertThat(instances).containsNoDuplicates();
assertThat(scope3.getOptionalInScope(InstanceType.class, "")).isNull();
assertThat(scope2.getOptionalInScope(InstanceType.class, "")).isNotNull();
List<InstanceType> instancesInScope1 = scope1.getManyInScope(InstanceType.class, "");
assertThat(instancesInScope1).isNotNull();
assertThat(instancesInScope1).hasSize(2);
}
private static class InstanceImpl1Factory extends InstanceFactory<InstanceType> {
@Override public InstanceType create(Scope scope) { return new InstanceImpl1(); }
@Override public Scoping getScoping() { return Scoping.TOPMOST; }
}
private static class InstanceImpl2Factory extends InstanceFactory<InstanceType> {
@Override public InstanceType create(Scope scope) { return new InstanceImpl2(); }
@Override public Scoping getScoping() { return Scoping.TOPMOST; }
}
private static class InstanceImpl3Factory extends InstanceFactory<InstanceType> {
@Override public InstanceType create(Scope scope) { return new InstanceImpl3(); }
@Override public Scoping getScoping() { return Scoping.TOPMOST; }
}
@SuppressWarnings("unchecked")
private class StubInstanceManager implements InstanceManager {
private final List instanceTypeFactories = new ArrayList<>();
StubInstanceManager() {
instanceTypeFactories.add(factory1);
instanceTypeFactories.add(factory2);
instanceTypeFactories.add(factory3);
}
@Override
public <T> InstanceFactory getInstanceFactory(
Class<T> instanceType, String classifier, Class<InstanceFactory<T>> factoryType
) {
throw new UnsupportedOperationException();
}
@Override public <T> InstanceFactory<T> getFilteredInstanceFactory(
Class<T> type, String classifier, FactoryFilter factoryFilter
) {
throw new UnsupportedOperationException();
}
@Override public <T> List<InstanceFactory<T>> getManyInstanceFactories(
Class<T> type, String classifier, FactoryFilter factoryFilter
) {
if (type == InstanceType.class) {
return (List<InstanceFactory<T>>) instanceTypeFactories;
}
throw new UnsupportedOperationException();
}
}
private interface InstanceType {}
private static class InstanceImpl1 implements InstanceType {}
private static class InstanceImpl2 implements InstanceType {}
private static class InstanceImpl3 implements InstanceType {}
}
================================================
FILE: magnet/src/test/java/magnet/internal/MagnetScope_RegisterAndGetTest.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet.internal;
import static com.google.common.truth.Truth.assertThat;
import magnet.Scope;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class MagnetScope_RegisterAndGetTest {
@Mock
InstanceManager instanceManager;
private Scope scope;
@Before
public void before() {
scope = new MagnetScope(null, instanceManager);
}
@Test
public void noClassifier_GetOptionalNotRegistered() {
// when
Integer dependency = scope.getOptional(Integer.class);
// then
assertThat(dependency).isNull();
}
@Test
public void noClassifier_GetOptionalRegistered() {
// given
scope.bind(Integer.class, 100);
// when
Integer dependency = scope.getOptional(Integer.class);
// then
assertThat(dependency).isEqualTo(100);
}
@Test(expected = IllegalStateException.class)
public void noClassifier_GetSingleNotRegistered() {
scope.getSingle(Integer.class);
}
@Test
public void noClassifier_GetSingleRegistered() {
// given
scope.bind(Integer.class, 100);
// when
Integer dependency = scope.getSingle(Integer.class);
// then
assertThat(dependency).isEqualTo(100);
}
@Test(expected = IllegalStateException.class)
public void noClassifier_RegisterOverwrite() {
scope.bind(Integer.class, 100);
scope.bind(Integer.class, 200);
}
@Test
public void classifier_GetOptionalNotRegistered() {
// when
Integer dependency = scope.getOptional(Integer.class, "common");
// then
assertThat(dependency).isNull();
}
@Test
public void classifier_GetOptionalRegisteredNoClassifier() {
// given
scope.bind(Integer.class, 100, "common");
// when
Integer dependency = scope.getOptional(Integer.class);
// then
assertThat(dependency).isNull();
}
@Test
public void classifier_GetOptionalRegisteredWrongClassifier() {
// given
scope.bind(Integer.class, 100, "common");
// when
Integer dependency = scope.getOptional(Integer.class, "wrong");
// then
assertThat(dependency).isNull();
}
@Test(expected = IllegalStateException.class)
public void classifier_GetSingleNotRegistered() {
scope.getSingle(Integer.class, "common");
}
@Test
public void classifier_GetSingleRegistered() {
// given
scope.bind(Integer.class, 100, "common");
// when
Integer dependency = scope.getSingle(Integer.class, "common");
// then
assertThat(dependency).isEqualTo(100);
}
@Test(expected = IllegalStateException.class)
public void classifier_RegisterOverwrite() {
scope.bind(Integer.class, 100, "common");
scope.bind(Integer.class, 200, "common");
}
}
================================================
FILE: magnet/src/test/java/magnet/internal/MagnetScope_SiblingTypesTest.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet.internal;
import magnet.Classifier;
import magnet.Scope;
import magnet.Scoping;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import java.util.HashMap;
import java.util.Map;
import static com.google.common.truth.Truth.assertThat;
@RunWith(MockitoJUnitRunner.Silent.class)
public class MagnetScope_SiblingTypesTest {
@Test
public void sameInstanceIsRegisteredScope() {
MagnetInstanceManager instanceManager = createMagnetInstanceManager(Scoping.TOPMOST);
Scope topMost = new MagnetScope(null, instanceManager);
Scope directScope = topMost.createSubscope();
Interface1 instance1 = directScope.getSingle(Interface1.class);
Interface2 instance2 = directScope.getSingle(Interface2.class);
assertThat(instance1).isSameInstanceAs(instance2);
}
@Test
public void sameInstanceIsRegisteredScopeInReverseOrder() {
MagnetInstanceManager instanceManager = createMagnetInstanceManager(Scoping.TOPMOST);
Scope topMost = new MagnetScope(null, instanceManager);
Scope directScope = topMost.createSubscope();
Interface2 instance2 = directScope.getSingle(Interface2.class);
Interface1 instance1 = directScope.getSingle(Interface1.class);
assertThat(instance1).isSameInstanceAs(instance2);
}
@Test
public void sameInstanceIsRegisteredInTopMostScope() {
MagnetInstanceManager instanceManager = createMagnetInstanceManager(Scoping.TOPMOST);
Scope topMost = new MagnetScope(null, instanceManager);
Scope directScope = topMost.createSubscope();
directScope.getSingle(Interface1.class);
Interface1 instance1 = topMost.getSingle(Interface1.class);
Interface2 instance2 = topMost.getSingle(Interface2.class);
assertThat(instance1).isSameInstanceAs(instance2);
}
@Test
public void sameInstanceIsRegisteredInDirectScope() {
MagnetInstanceManager instanceManager = createMagnetInstanceManager(Scoping.DIRECT);
Scope topMost = new MagnetScope(null, instanceManager);
Scope directScope = topMost.createSubscope();
Interface1 instance1 = directScope.getSingle(Interface1.class);
Interface2 instance2 = directScope.getSingle(Interface2.class);
assertThat(instance1).isSameInstanceAs(instance2);
}
@Test
public void sameInstanceIsNotRegisteredInTopMostScope() {
MagnetInstanceManager instanceManager = createMagnetInstanceManager(Scoping.DIRECT);
MagnetScope topMost = new MagnetScope(null, instanceManager);
Scope directScope = topMost.createSubscope();
directScope.getSingle(Interface1.class);
assertThat(topMost.instanceBuckets).isEmpty();
}
private static MagnetInstanceManager createMagnetInstanceManager(Scoping scoping) {
MagnetInstanceManager instanceManager = new MagnetInstanceManager();
InstanceFactory[] factories = new InstanceFactory[]{
new ImplementationInterface1Factory(scoping),
new ImplementationInterface2Factory(scoping)
};
Map<Class, Object> index = new HashMap<>();
index.put(Interface1.class, new Range(0, 1, Classifier.NONE));
index.put(Interface2.class, new Range(1, 1, Classifier.NONE));
instanceManager.register(factories, index);
return instanceManager;
}
interface Interface1 {}
interface Interface2 {}
static class Implementation implements Interface1, Interface2 {}
static class ImplementationInterface1Factory extends InstanceFactory<Interface1> {
private Scoping scoping;
ImplementationInterface1Factory(Scoping scoping) { this.scoping = scoping; }
@Override public Interface1 create(Scope scope) { return new Implementation(); }
@Override public Scoping getScoping() { return this.scoping; }
@Override public Class[] getSiblingTypes() {
return new Class[]{Interface2.class, ImplementationInterface2Factory.class};
}
}
static class ImplementationInterface2Factory extends InstanceFactory<Interface2> {
private Scoping scoping;
ImplementationInterface2Factory(Scoping scoping) { this.scoping = scoping; }
@Override public Interface2 create(Scope scope) { return new Implementation(); }
@Override public Scoping getScoping() { return this.scoping; }
@Override public Class[] getSiblingTypes() {
return new Class[]{Interface1.class, ImplementationInterface1Factory.class};
}
}
}
================================================
FILE: magnet/src/test/java/magnet/internal/MagnetScopingDirectTest.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet.internal;
import magnet.Scope;
import magnet.Scoping;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.google.common.truth.Truth.assertThat;
@RunWith(JUnit4.class)
public class MagnetScopingDirectTest {
private InstrumentedScope scope1;
private InstrumentedScope scope2;
private InstrumentedScope scope3;
@Before
public void before() {
InstanceManager instanceManager = new StubInstanceManager();
scope1 = (InstrumentedScope) new InstrumentedScope(
new MagnetScope(null, instanceManager))
.bind(Dependency1.class, new Dependency1());
scope2 = (InstrumentedScope) scope1
.createSubscope()
.bind(Dependency2.class, new Dependency2());
scope3 = (InstrumentedScope) scope2
.createSubscope()
.bind(Dependency3.class, new Dependency3());
}
@Test
public void itemOne_Scope1() {
// when
MenuItem menuItem = scope1.getSingle(MenuItem.class, "one");
// then
assertThat(menuItem).isNotNull();
assertThat(scope1.getOptionalInScope(MenuItem.class, "one")).isNotNull();
}
@Test
public void itemOne_Scope2() {
// when
MenuItem menuItem = scope2.getSingle(MenuItem.class, "one");
// then
assertThat(menuItem).isNotNull();
assertThat(scope2.getOptionalInScope(MenuItem.class, "one")).isNotNull();
assertThat(scope1.getOptionalInScope(MenuItem.class, "one")).isNull();
}
@Test
public void itemOne_Scope3() {
// when
MenuItem menuItem = scope3.getSingle(MenuItem.class, "one");
// then
assertThat(menuItem).isNotNull();
assertThat(scope3.getOptionalInScope(MenuItem.class, "one")).isNotNull();
assertThat(scope2.getOptionalInScope(MenuItem.class, "one")).isNull();
assertThat(scope1.getOptionalInScope(MenuItem.class, "one")).isNull();
}
@Test(expected = IllegalStateException.class)
public void itemTwo_Scope1() {
// when
MenuItem menuItem = scope1.getSingle(MenuItem.class, "two");
}
@Test
public void itemTwo_Scope2() {
// when
MenuItem menuItem = scope2.getSingle(MenuItem.class, "two");
// then
assertThat(menuItem).isNotNull();
assertThat(scope2.getOptionalInScope(MenuItem.class, "two")).isNotNull();
assertThat(scope1.getOptionalInScope(MenuItem.class, "two")).isNull();
}
@Test
public void itemTwo_Scope3() {
// when
MenuItem menuItem = scope3.getSingle(MenuItem.class, "two");
// then
assertThat(menuItem).isNotNull();
assertThat(scope3.getOptionalInScope(MenuItem.class, "two")).isNotNull();
assertThat(scope2.getOptionalInScope(MenuItem.class, "two")).isNull();
assertThat(scope1.getOptionalInScope(MenuItem.class, "two")).isNull();
}
@Test(expected = IllegalStateException.class)
public void itemThree_Scope1() {
// when
MenuItem menuItem = scope1.getSingle(MenuItem.class, "three");
}
@Test(expected = IllegalStateException.class)
public void itemThree_Scope2() {
// when
MenuItem menuItem = scope2.getSingle(MenuItem.class, "three");
}
@Test
public void itemThree_Scope3() {
// when
MenuItem menuItem = scope3.getSingle(MenuItem.class, "three");
// then
assertThat(menuItem).isNotNull();
assertThat(scope3.getOptionalInScope(MenuItem.class, "three")).isNotNull();
assertThat(scope2.getOptionalInScope(MenuItem.class, "three")).isNull();
assertThat(scope1.getOptionalInScope(MenuItem.class, "three")).isNull();
}
private static class MenuItemOneFactory extends InstanceFactory<MenuItem> {
@Override public MenuItem create(Scope scope) {
scope.getSingle(Dependency1.class);
return new MenuItemOne();
}
@Override public Scoping getScoping() { return Scoping.DIRECT; }
}
private static class MenuItemTwoFactory extends InstanceFactory<MenuItem> {
@Override public MenuItem create(Scope scope) {
scope.getSingle(MenuItem.class, "one");
scope.getSingle(Dependency2.class);
return new MenuItemTwo();
}
@Override public Scoping getScoping() { return Scoping.DIRECT; }
}
private static class MenuItemThreeFactory extends InstanceFactory<MenuItem> {
@Override public MenuItem create(Scope scope) {
scope.getSingle(MenuItem.class, "two");
scope.getSingle(Dependency3.class);
return new MenuItemThree();
}
@Override public Scoping getScoping() { return Scoping.DIRECT; }
}
@SuppressWarnings("unchecked")
private static class StubInstanceManager implements InstanceManager {
private final Map<String, InstanceFactory<MenuItem>> factories;
StubInstanceManager() {
factories = new HashMap<>();
factories.put("one", new MenuItemOneFactory());
factories.put("two", new MenuItemTwoFactory());
factories.put("three", new MenuItemThreeFactory());
}
@Override
public <T> InstanceFactory getInstanceFactory(
Class<T> instanceType, String classifier, Class<InstanceFactory<T>> factoryType
) {
throw new UnsupportedOperationException();
}
@Override public <T> InstanceFactory<T> getFilteredInstanceFactory(
Class<T> type, String classifier, FactoryFilter factoryFilter
) {
return (InstanceFactory<T>) factories.get(classifier);
}
@Override public <T> List<InstanceFactory<T>> getManyInstanceFactories(
Class<T> type, String classifier, FactoryFilter factoryFilter
) {
throw new UnsupportedOperationException();
}
}
private interface MenuItem {}
private static class MenuItemOne implements MenuItem {}
private static class MenuItemTwo implements MenuItem {}
private static class MenuItemThree implements MenuItem {}
private static class Dependency1 {}
private static class Dependency2 {}
private static class Dependency3 {}
}
================================================
FILE: magnet/src/test/java/magnet/internal/MagnetScopingNoneTest.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet.internal;
import magnet.Scope;
import magnet.Scoping;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.google.common.truth.Truth.assertThat;
@RunWith(JUnit4.class)
public class MagnetScopingNoneTest {
private InstrumentedScope scope1;
private InstrumentedScope scope2;
private InstrumentedScope scope3;
@Before
public void before() {
InstanceManager instanceManager = new StubInstanceManager();
scope1 = (InstrumentedScope) new InstrumentedScope(
new MagnetScope(null, instanceManager))
.bind(Dependency1.class, new Dependency1());
scope2 = (InstrumentedScope) scope1
.createSubscope()
.bind(Dependency2.class, new Dependency2());
scope3 = (InstrumentedScope) scope2
.createSubscope()
.bind(Dependency3.class, new Dependency3());
}
@Test
public void itemOne_requestedWithinScope1() {
// when
MenuItem menuItem = scope1.getSingle(MenuItem.class, "one");
// then
assertThat(menuItem).isNotNull();
assertThat(scope3.getOptionalInScope(MenuItem.class, "one")).isNull();
assertThat(scope2.getOptionalInScope(MenuItem.class, "one")).isNull();
assertThat(scope1.getOptionalInScope(MenuItem.class, "one")).isNull();
}
@Test
public void itemOne_requestedWithinScope2() {
// when
MenuItem menuItem = scope2.getSingle(MenuItem.class, "one");
// then
assertThat(menuItem).isNotNull();
assertThat(scope3.getOptionalInScope(MenuItem.class, "one")).isNull();
assertThat(scope2.getOptionalInScope(MenuItem.class, "one")).isNull();
assertThat(scope1.getOptionalInScope(MenuItem.class, "one")).isNull();
}
@Test
public void itemOne_requestedWithinScope3() {
// when
MenuItem menuItem = scope3.getSingle(MenuItem.class, "one");
// then
assertThat(menuItem).isNotNull();
assertThat(scope3.getOptionalInScope(MenuItem.class, "one")).isNull();
assertThat(scope2.getOptionalInScope(MenuItem.class, "one")).isNull();
assertThat(scope1.getOptionalInScope(MenuItem.class, "one")).isNull();
}
@Test(expected = IllegalStateException.class)
public void itemTwo_requestedWithinScope1() {
// when
scope1.getSingle(MenuItem.class, "two");
}
@Test
public void itemTwo_requestedWithinScope2() {
// when
MenuItem menuItem = scope2.getSingle(MenuItem.class, "two");
// then
assertThat(menuItem).isNotNull();
assertThat(scope3.getOptionalInScope(MenuItem.class, "two")).isNull();
assertThat(scope2.getOptionalInScope(MenuItem.class, "two")).isEqualTo(menuItem);
assertThat(scope1.getOptionalInScope(MenuItem.class, "two")).isNull();
assertThat(scope3.getOptionalInScope(MenuItem.class, "one")).isNull();
assertThat(scope2.getOptionalInScope(MenuItem.class, "one")).isNull();
assertThat(scope1.getOptionalInScope(MenuItem.class, "one")).isNull();
}
@Test
public void itemTwo_requestedWithinScope3() {
// when
MenuItem menuItem = scope3.getSingle(MenuItem.class, "two");
// then
assertThat(menuItem).isNotNull();
assertThat(scope3.getOptionalInScope(MenuItem.class, "two")).isNull();
assertThat(scope2.getOptionalInScope(MenuItem.class, "two")).isEqualTo(menuItem);
assertThat(scope1.getOptionalInScope(MenuItem.class, "two")).isNull();
assertThat(scope3.getOptionalInScope(MenuItem.class, "one")).isNull();
assertThat(scope2.getOptionalInScope(MenuItem.class, "one")).isNull();
assertThat(scope1.getOptionalInScope(MenuItem.class, "one")).isNull();
}
@Test(expected = IllegalStateException.class)
public void itemThree_requestedWithinScope1() {
// when
scope1.getSingle(MenuItem.class, "three");
}
@Test(expected = IllegalStateException.class)
public void itemThree_requestedWithinScope2() {
// when
scope2.getSingle(MenuItem.class, "three");
}
@Test
public void itemThree_requestedWithinScope3() {
// when
MenuItem menuItem = scope3.getSingle(MenuItem.class, "three");
// then
assertThat(menuItem).isNotNull();
assertThat(scope3.getOptionalInScope(MenuItem.class, "two")).isNull();
assertThat(scope2.getOptionalInScope(MenuItem.class, "two")).isNotNull();
assertThat(scope1.getOptionalInScope(MenuItem.class, "two")).isNull();
assertThat(scope3.getOptionalInScope(MenuItem.class, "one")).isNull();
assertThat(scope2.getOptionalInScope(MenuItem.class, "one")).isNull();
assertThat(scope1.getOptionalInScope(MenuItem.class, "one")).isNull();
}
private static class MenuItemOneFactory extends InstanceFactory<MenuItem> {
@Override public MenuItem create(Scope scope) {
scope.getSingle(Dependency1.class);
return new MenuItemOne();
}
@Override public Scoping getScoping() { return Scoping.UNSCOPED; }
}
private static class MenuItemTwoFactory extends InstanceFactory<MenuItem> {
@Override public MenuItem create(Scope scope) {
scope.getSingle(Dependency1.class);
scope.getSingle(Dependency2.class);
scope.getSingle(MenuItem.class, "one");
return new MenuItemTwo();
}
@Override public Scoping getScoping() { return Scoping.TOPMOST; }
}
private static class MenuItemThreeFactory extends InstanceFactory<MenuItem> {
@Override public MenuItem create(Scope scope) {
scope.getSingle(Dependency1.class);
scope.getSingle(Dependency3.class);
scope.getSingle(MenuItem.class, "one");
scope.getSingle(MenuItem.class, "two");
return new MenuItemThree();
}
@Override public Scoping getScoping() { return Scoping.UNSCOPED; }
}
private static class StubInstanceManager implements InstanceManager {
private final Map<String, InstanceFactory<MenuItem>> factories;
StubInstanceManager() {
factories = new HashMap<>();
factories.put("one", new MenuItemOneFactory());
factories.put("two", new MenuItemTwoFactory());
factories.put("three", new MenuItemThreeFactory());
}
@Override
public <T> InstanceFactory getInstanceFactory(
Class<T> instanceType, String classifier, Class<InstanceFactory<T>> factoryType
) {
throw new UnsupportedOperationException();
}
@Override public <T> InstanceFactory<T> getFilteredInstanceFactory(
Class<T> type, String classifier, FactoryFilter factoryFilter
) {
//noinspection unchecked
return (InstanceFactory<T>) factories.get(classifier);
}
@Override public <T> List<InstanceFactory<T>> getManyInstanceFactories(
Class<T> type, String classifier, FactoryFilter factoryFilter
) {
throw new UnsupportedOperationException();
}
}
private interface MenuItem {}
private static class MenuItemOne implements MenuItem {}
private static class MenuItemTwo implements MenuItem {}
private static class MenuItemThree implements MenuItem {}
private static class Dependency1 {}
private static class Dependency2 {}
private static class Dependency3 {}
}
================================================
FILE: magnet/src/test/java/magnet/internal/MagnetScopingTopmostDependsOnDirectTest.java
================================================
/*
* Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package magnet.internal;
import magnet.Scope;
import magnet.Scoping;
impo
gitextract_enrgbkx0/ ├── .editorconfig ├── .github/ │ ├── stale.yml │ └── workflows/ │ └── android.yml ├── .gitignore ├── .project ├── .settings/ │ └── org.eclipse.buildship.core.prefs ├── CHANGELOG.md ├── LICENSE ├── README.md ├── build.gradle ├── documentation/ │ └── diagrams/ │ └── design.graphml ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat ├── magnet/ │ ├── build.gradle │ ├── gradle.properties │ └── src/ │ ├── main/ │ │ └── java/ │ │ └── magnet/ │ │ ├── Classifier.java │ │ ├── Factory.java │ │ ├── Instance.java │ │ ├── Magnet.java │ │ ├── Registry.java │ │ ├── Scope.java │ │ ├── Scoping.java │ │ ├── SelectorFilter.java │ │ ├── Visitor.java │ │ └── internal/ │ │ ├── FactoryFilter.java │ │ ├── Generated.java │ │ ├── ImmutableArrayList.java │ │ ├── Index.java │ │ ├── InstanceBucket.java │ │ ├── InstanceFactory.java │ │ ├── InstanceManager.java │ │ ├── InternalFactory.java │ │ ├── MagnetInstanceManager.java │ │ ├── MagnetScope.java │ │ └── Range.java │ └── test/ │ ├── java/ │ │ └── magnet/ │ │ └── internal/ │ │ ├── FactoryFilter_MagnetInstanceManagerTest.java │ │ ├── FactoryFilter_MagnetScopeTest.java │ │ ├── InstanceBucketTest.java │ │ ├── InstrumentedScope.java │ │ ├── MagnetInstanceManagerTest.java │ │ ├── MagnetScope_CircularDependencyTest.java │ │ ├── MagnetScope_DisposeTest.java │ │ ├── MagnetScope_FindDeepForSiblingTypesTest.java │ │ ├── MagnetScope_GetManyTest.java │ │ ├── MagnetScope_ManyInstancesInMultipleScopesTest.java │ │ ├── MagnetScope_RegisterAndGetTest.java │ │ ├── MagnetScope_SiblingTypesTest.java │ │ ├── MagnetScopingDirectTest.java │ │ ├── MagnetScopingNoneTest.java │ │ ├── MagnetScopingTopmostDependsOnDirectTest.java │ │ ├── MagnetScopingTopmostDependsOnTopmostTest.java │ │ ├── MagnetScopingTopmostDependsOnUnscopedTest.java │ │ ├── Scope_GetManyAnySiblingTypesTest_Issue95.java │ │ ├── Scope_LimitDirectScoping_DependencyInNonReachableChildScopeTest.java │ │ ├── Scope_LimitDirectScoping_InstanceWithDependencyTest.java │ │ ├── Scope_LimitDirectScoping_SingleInstanceTest.java │ │ ├── Scope_LimitTest.java │ │ ├── Scope_LimitWithDependencyTest.java │ │ ├── VisitInstancesTest.java │ │ ├── VisitScopesTest.java │ │ ├── events/ │ │ │ ├── ObservableScopeVisitor.java │ │ │ ├── OnEnterScope.java │ │ │ ├── OnExitScope.java │ │ │ └── OnInstance.java │ │ └── observer/ │ │ ├── ScopeObserver.java │ │ └── ScopeValidator.java │ └── resources/ │ └── mockito-extensions/ │ └── org.mockito.plugins.MockMaker ├── magnet-kotlin/ │ ├── build.gradle │ ├── gradle.properties │ └── src/ │ ├── main/ │ │ └── java/ │ │ └── magnet/ │ │ ├── MagnetExt.kt │ │ ├── ScopeExt.kt │ │ └── internal/ │ │ ├── ManyLazy.kt │ │ ├── OptionalLazy.kt │ │ └── SingleLazy.kt │ └── test/ │ └── java/ │ └── magnet/ │ └── kotlin/ │ ├── ScopeExtTest.kt │ └── internal/ │ ├── ManyLazyTest.kt │ ├── OptionalLazyTest.kt │ └── SingleLazyTest.kt ├── magnet-processor/ │ ├── build.gradle │ ├── gradle.properties │ ├── libs/ │ │ └── tools.jar │ └── src/ │ ├── main/ │ │ ├── java/ │ │ │ └── magnet/ │ │ │ └── processor/ │ │ │ ├── MagnetProcessor.kt │ │ │ ├── common/ │ │ │ │ ├── AptUtils.kt │ │ │ │ └── KotlinMethodMetadata.kt │ │ │ ├── instances/ │ │ │ │ ├── FactoryTypeModel.kt │ │ │ │ ├── InstanceProcessor.kt │ │ │ │ ├── aspects/ │ │ │ │ │ ├── classifier/ │ │ │ │ │ │ └── ClassifierAttributeParser.kt │ │ │ │ │ ├── disabled/ │ │ │ │ │ │ └── DisabledAttributeParser.kt │ │ │ │ │ ├── disposer/ │ │ │ │ │ │ ├── DisposeMethodGenerator.kt │ │ │ │ │ │ ├── DisposerAttributeParser.kt │ │ │ │ │ │ ├── DisposerValidator.kt │ │ │ │ │ │ └── IsDisposableMethodGenerator.kt │ │ │ │ │ ├── factory/ │ │ │ │ │ │ ├── CreateMethodGenerator.kt │ │ │ │ │ │ ├── CustomFactoryCreateMethodGenerator.kt │ │ │ │ │ │ ├── FactoryAttributeParser.kt │ │ │ │ │ │ └── StandardFactoryCreateMethodGenerator.kt │ │ │ │ │ ├── index/ │ │ │ │ │ │ └── FactoryIndexCodeGenerator.kt │ │ │ │ │ ├── limitedto/ │ │ │ │ │ │ ├── GetLimitMethodGenerator.kt │ │ │ │ │ │ ├── LimitedToAttributeParser.kt │ │ │ │ │ │ └── LimitedToValidator.kt │ │ │ │ │ ├── scoping/ │ │ │ │ │ │ ├── GetScopingMethodGenerator.kt │ │ │ │ │ │ └── ScopingAttributeParser.kt │ │ │ │ │ ├── selector/ │ │ │ │ │ │ ├── GetSelectorMethodGenerator.kt │ │ │ │ │ │ └── SelectorAttributeParser.kt │ │ │ │ │ ├── siblings/ │ │ │ │ │ │ └── GetSiblingTypesMethodGenerator.kt │ │ │ │ │ └── type/ │ │ │ │ │ ├── TypeAndTypesValidator.kt │ │ │ │ │ ├── TypeAttributeParser.kt │ │ │ │ │ └── TypesAttributeParser.kt │ │ │ │ ├── generator/ │ │ │ │ │ ├── CodeGenerator.kt │ │ │ │ │ ├── CodeWriter.kt │ │ │ │ │ └── FactoryTypeCodeGenerator.kt │ │ │ │ └── parser/ │ │ │ │ ├── AspectValidator.kt │ │ │ │ ├── AttributeParser.kt │ │ │ │ ├── InstanceParser.kt │ │ │ │ ├── InstanceParserForClass.kt │ │ │ │ ├── InstanceParserForMethod.kt │ │ │ │ └── ParserInstance.kt │ │ │ └── registry/ │ │ │ ├── Model.kt │ │ │ ├── RegistryGenerator.kt │ │ │ ├── RegistryParser.kt │ │ │ ├── RegistryProcessor.kt │ │ │ └── instances/ │ │ │ ├── IndexGeneratorVisitor.kt │ │ │ ├── Indexer.kt │ │ │ ├── InstanceIndexGenerator.kt │ │ │ ├── Model.kt │ │ │ └── SectionsCreatorVisitor.kt │ │ └── resources/ │ │ └── META-INF/ │ │ ├── gradle/ │ │ │ └── incremental.annotation.processors │ │ └── services/ │ │ └── javax.annotation.processing.Processor │ └── test/ │ ├── java/ │ │ └── magnet/ │ │ └── processor/ │ │ ├── GenerateRegistryForInstanceFactoriesTest.kt │ │ ├── IndexerTest.kt │ │ ├── InstanceCustomFactoryProcessorTest.kt │ │ ├── InstanceDisposerTest.kt │ │ ├── InstanceIndexProcessorTest.kt │ │ ├── MagnetProcessorFactoryNamesTest.kt │ │ ├── MagnetProcessorTest.kt │ │ ├── SelectorInFactoryClassTest.kt │ │ └── SiblingTypesTest.kt │ └── resources/ │ ├── GenerateRegistryForInstanceFactoriesTest/ │ │ ├── App.java │ │ ├── Implementation1.java │ │ ├── Implementation3_1.java │ │ ├── Implementation3_2.java │ │ ├── Implementation4_1.java │ │ ├── Implementation4_2.java │ │ ├── Implementation5_1.java │ │ ├── Implementation5_2.java │ │ ├── Implementation6_1.java │ │ ├── Implementation6_2.java │ │ ├── Interface1.java │ │ ├── Interface3.java │ │ ├── Interface4.java │ │ ├── Interface5.java │ │ ├── Interface6_1.java │ │ ├── Interface6_2.java │ │ ├── Interface7.java │ │ └── expected/ │ │ ├── MagnetIndexer1.java │ │ ├── MagnetIndexer2.java │ │ ├── MagnetIndexer3.java │ │ ├── MagnetIndexer4.java │ │ ├── MagnetIndexer5.java │ │ ├── MagnetIndexer6.java │ │ └── MagnetIndexer7.java │ ├── InstanceCustomFactoryProcessorTest/ │ │ ├── CustomFactory1.java │ │ ├── CustomFactory2.java │ │ ├── CustomFactory3.java │ │ ├── Implementation1.java │ │ ├── Implementation2.java │ │ ├── Implementation3.java │ │ ├── Interface1.java │ │ ├── Interface2.java │ │ ├── Interface3.java │ │ └── expected/ │ │ ├── Implementation1MagnetFactory.java │ │ ├── Implementation2MagnetFactory.java │ │ └── Implementation3MagnetFactory.java │ ├── InstanceDisposerTest/ │ │ ├── Implementation1.java │ │ ├── Implementation2.java │ │ ├── Implementation3.java │ │ ├── Implementation4.java │ │ ├── Implementation5.java │ │ ├── Interface.java │ │ └── expected/ │ │ └── Implementation1MagnetFactory.java │ ├── InstanceIndexProcessorTest/ │ │ ├── Implementation1.java │ │ ├── Implementation2.java │ │ ├── Interface1.java │ │ ├── Interface2.java │ │ └── generated/ │ │ ├── app_test_Implementation1MagnetFactory.java │ │ └── app_test_Implementation2MagnetFactory.java │ ├── MagnetProcessorFactoryNamesTest/ │ │ ├── Delegate1.java │ │ ├── Interface1.java │ │ └── generated/ │ │ ├── Delegate1MagnetFactory.java │ │ └── Interface1DelegateMagnetFactory.java │ ├── MagnetProcessorTest/ │ │ ├── AppExtensionRegistry.java │ │ ├── Constructor_PackagePrivate_PackagePrivate/ │ │ │ └── UnderTest.java │ │ ├── Constructor_PackagePrivate_Private/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── Constructor_Private/ │ │ │ └── UnderTest.java │ │ ├── Constructor_Protected/ │ │ │ └── UnderTest.java │ │ ├── Constructor_Public_PackagePrivate/ │ │ │ └── UnderTest.java │ │ ├── Constructor_Public_Private/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── Constructor_Public_Protected/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── Constructor_Public_Public/ │ │ │ └── UnderTest.java │ │ ├── Constructor_Public_Public_Kotlin/ │ │ │ └── UnderTest.java │ │ ├── Covariance_Constructor_ManyParameter/ │ │ │ ├── Foo.java │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── Covariance_Constructor_SingleParameter/ │ │ │ ├── Foo.java │ │ │ └── UnderTest.java │ │ ├── DefaultArguments_JvmOverloads_AtTheEnd/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── DefaultArguments_JvmOverloads_InTheMiddle/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── DefaultArguments_JvmOverloads_Mixed/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── DisabledTab.java │ │ ├── Executor.java │ │ ├── ExecutorImpl.java │ │ ├── ExecutorMaster.java │ │ ├── Generics_GetOptional_Unchecked/ │ │ │ ├── Dependency.java │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── Generics_GetSingle_Unchecked/ │ │ │ ├── Dependency.java │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── Generics_ProvideTypeWithParameter/ │ │ │ ├── Parameter.java │ │ │ ├── Type.java │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestProvideTypeMagnetFactory.java │ │ ├── Generics_ProvideTypeWithParameter_NoClassifier/ │ │ │ ├── Parameter.java │ │ │ ├── Type.java │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestProvideTypeMagnetFactory.java │ │ ├── HomePage.java │ │ ├── HomePageMenuItem.java │ │ ├── HomePageNoParams.java │ │ ├── HomePageWithClassifierParams.java │ │ ├── HomePageWithGenericParam.java │ │ ├── HomePageWithManyParameterizedParams.java │ │ ├── HomePageWithManyParameterizedWildcardInParams.java │ │ ├── HomePageWithManyParameterizedWildcardKnownParams.java │ │ ├── HomePageWithManyParameterizedWildcardOutParams.java │ │ ├── HomePageWithManyParams.java │ │ ├── HomePageWithManyWildcardParams.java │ │ ├── HomePageWithParams.java │ │ ├── HomePageWithScope.java │ │ ├── HomePageWithStaticConstructor.java │ │ ├── HomePageWithStaticConstructorDisabled.java │ │ ├── HomePageWithStaticConstructorSingle.java │ │ ├── HomeRepository.java │ │ ├── Lazy_Constructor_ManyParameter/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── Lazy_Constructor_ManyParameter_NullableGenericType/ │ │ │ └── UnderTest.java │ │ ├── Lazy_Constructor_ManyParameter_NullableListType/ │ │ │ └── UnderTest.java │ │ ├── Lazy_Constructor_ManyParameter_Wildcard/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── Lazy_Constructor_NoKotlinMetadata/ │ │ │ └── UnderTest.java │ │ ├── Lazy_Constructor_OptionalParameter/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── Lazy_Constructor_OptionalParameter_Wildcard/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── Lazy_Constructor_SingleParameter/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── Lazy_Constructor_SingleParameter_ParameterizedType/ │ │ │ ├── Foo.java │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── Lazy_Constructor_SingleParameter_Wildcard/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── Lazy_Method_NoKotlinMetadata/ │ │ │ └── UnderTest.java │ │ ├── Lazy_Method_OptionalParameter/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestProvideUnderTestDepMagnetFactory.java │ │ ├── Lazy_Method_OptionalParameter_Wildcard/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestProvideUnderTestDepMagnetFactory.java │ │ ├── Lazy_Method_SingleParameter/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestProvideUnderTestDepMagnetFactory.java │ │ ├── Lazy_Method_SingleParameter_Wildcard/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestProvideUnderTestDepMagnetFactory.java │ │ ├── Limit_Empty_NoGetter/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── Limit_NotEmpty_HasGetter/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── Limit_ReservedAsterisks_Fails/ │ │ │ └── UnderTest.java │ │ ├── Limit_ScopingDirect_GeneratesGetter/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── Limit_ScopingUnscoped_Fails/ │ │ │ └── UnderTest.java │ │ ├── MenuItem.java │ │ ├── Page.java │ │ ├── ScopeParameter_CustomName/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── ScopeParameter_CustomName_KotlinClass/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── ScopeParameter_DefaultName/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── StaticMethodNeedsDependencyWithClassifier/ │ │ │ ├── Constants.java │ │ │ ├── Input.java │ │ │ ├── Output.java │ │ │ ├── StaticFunction.java │ │ │ └── generated/ │ │ │ └── StaticFunctionProvideInputMagnetFactory.java │ │ ├── StaticMethodProvidesInnerClass/ │ │ │ ├── PowerManager.java │ │ │ ├── PowerManagerProvider.java │ │ │ └── expected/ │ │ │ └── PowerManagerProviderProvideWakeLockMagnetFactory.java │ │ ├── Tab.java │ │ ├── TypeAutoDetect_ExtendsObjectNoInterfaces/ │ │ │ ├── UnderTest.java │ │ │ └── expected/ │ │ │ └── UnderTestMagnetFactory.java │ │ ├── UnimplementedTab.java │ │ ├── UserData.java │ │ ├── UserPage.java │ │ ├── UserPageMenuItem.java │ │ ├── WorkProcessor.java │ │ └── generated/ │ │ ├── ForInterfaceWithGenericType_ExecutorMagnetFactory.java │ │ ├── HomePageMagnetFactory.java │ │ ├── HomePageNoParamsMagnetFactory.java │ │ ├── HomePageWithClassifierParamsMagnetFactory.java │ │ ├── HomePageWithManyParameterizedParamsMagnetFactory.java │ │ ├── HomePageWithManyParameterizedWildcardInParamsMagnetFactory.java │ │ ├── HomePageWithManyParameterizedWildcardKnownParamsMagnetFactory.java │ │ ├── HomePageWithManyParameterizedWildcardOutParamsMagnetFactory.java │ │ ├── HomePageWithManyParamsMagnetFactory.java │ │ ├── HomePageWithManyWildcardParamsMagnetFactory.java │ │ ├── HomePageWithParamsMagnetFactory.java │ │ ├── HomePageWithScopeMagnetFactory.java │ │ └── HomePageWithStaticConstructorSingleCreateRepositoriesMagnetFactory.java │ ├── SelectorInFactoryClassTest/ │ │ ├── Implementation1.java │ │ ├── Implementation10.java │ │ ├── Implementation2.java │ │ ├── Implementation3.java │ │ ├── Implementation4.java │ │ ├── Implementation5.java │ │ ├── Implementation6.java │ │ ├── Implementation7.java │ │ ├── Implementation8.java │ │ ├── Implementation9.java │ │ ├── Interface.java │ │ └── generated/ │ │ ├── Implementation10MagnetFactory.java │ │ ├── Implementation1MagnetFactory.java │ │ ├── Implementation7MagnetFactory.java │ │ ├── Implementation8MagnetFactory.java │ │ └── Implementation9MagnetFactory.java │ └── SiblingTypesTest/ │ ├── Implementation1.java │ ├── Implementation2.java │ ├── Implementation3.java │ ├── Implementation4.java │ ├── Implementation5.java │ ├── Interface1.java │ ├── Interface2.java │ └── generated/ │ ├── Implementation4Interface1MagnetFactory.java │ └── Implementation4Interface2MagnetFactory.java ├── magnetx-app/ │ ├── build.gradle │ ├── gradle.properties │ └── src/ │ └── main/ │ └── kotlin/ │ └── magnetx/ │ └── AppExtension.kt ├── magnetx-app-rx3android/ │ ├── build.gradle │ ├── gradle.properties │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ └── java/ │ └── magnetx/ │ └── RxAndroidAppExtension.kt ├── magnetx-app-rxandroid/ │ ├── build.gradle │ ├── gradle.properties │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ └── java/ │ └── magnetx/ │ └── RxAndroidAppExtension.kt ├── magnetx-app-stetho/ │ ├── build.gradle │ ├── gradle.properties │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ └── java/ │ └── magnetx/ │ └── app/ │ └── stetho/ │ └── StethoAppExtension.kt ├── magnetx-app-stetho-scope/ │ ├── build.gradle │ ├── gradle.properties │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ └── java/ │ └── magnetx/ │ └── app/ │ └── stetho/ │ └── scope/ │ ├── ScopeDumper.kt │ ├── StethoScopeDumpPlugin.kt │ └── StethoScopeInitializer.kt ├── magnetx-selector-android/ │ ├── build.gradle │ ├── gradle.properties │ └── src/ │ └── main/ │ └── kotlin/ │ └── magnetx/ │ └── AndroidSelectorFilter.kt ├── magnetx-selector-features/ │ ├── build.gradle │ ├── gradle.properties │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ └── java/ │ └── magnetx/ │ └── FeaturesSelectorFilter.kt └── settings.gradle
SYMBOL INDEX (1158 symbols across 255 files)
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/App.java
class App (line 5) | @Registry
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Implementation1.java
class Implementation1 (line 5) | @Instance(type = Interface1.class)
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Implementation3_1.java
class Implementation3_1 (line 5) | @Instance(type = Interface3.class)
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Implementation3_2.java
class Implementation3_2 (line 5) | @Instance(type = Interface3.class)
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Implementation4_1.java
class Implementation4_1 (line 5) | @Instance(
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Implementation4_2.java
class Implementation4_2 (line 5) | @Instance(
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Implementation5_1.java
class Implementation5_1 (line 5) | @Instance(
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Implementation5_2.java
class Implementation5_2 (line 5) | @Instance(
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Implementation6_1.java
class Implementation6_1 (line 5) | @Instance(type = Interface6_1.class)
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Implementation6_2.java
class Implementation6_2 (line 5) | @Instance(type = Interface6_2.class)
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Interface1.java
type Interface1 (line 3) | interface Interface1 {}
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Interface3.java
type Interface3 (line 3) | interface Interface3 {}
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Interface4.java
type Interface4 (line 3) | interface Interface4 {}
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Interface5.java
type Interface5 (line 3) | interface Interface5 {}
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Interface6_1.java
type Interface6_1 (line 3) | interface Interface6_1 {}
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Interface6_2.java
type Interface6_2 (line 3) | interface Interface6_2 {}
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Interface7.java
type Interface7 (line 5) | interface Interface7 {
class Implementation7 (line 7) | @Instance(type = Interface7.class)
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/expected/MagnetIndexer1.java
class MagnetIndexer (line 7) | @Generated
method register (line 9) | public static void register(MagnetInstanceManager instanceManager) {
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/expected/MagnetIndexer2.java
class MagnetIndexer (line 6) | @Generated
method register (line 8) | public static void register(MagnetInstanceManager instanceManager) {
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/expected/MagnetIndexer3.java
class MagnetIndexer (line 8) | @Generated
method register (line 10) | public static void register(MagnetInstanceManager instanceManager) {
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/expected/MagnetIndexer4.java
class MagnetIndexer (line 8) | @Generated
method register (line 10) | public static void register(MagnetInstanceManager instanceManager) {
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/expected/MagnetIndexer5.java
class MagnetIndexer (line 8) | @Generated
method register (line 10) | public static void register(MagnetInstanceManager instanceManager) {
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/expected/MagnetIndexer6.java
class MagnetIndexer (line 8) | @Generated
method register (line 10) | public static void register(MagnetInstanceManager instanceManager) {
FILE: magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/expected/MagnetIndexer7.java
class MagnetIndexer (line 7) | @Generated
method register (line 9) | public static void register(MagnetInstanceManager instanceManager) {
FILE: magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/CustomFactory1.java
class CustomFactory1 (line 8) | class CustomFactory1 implements Factory<Interface1> {
method create (line 10) | @NotNull
FILE: magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/CustomFactory2.java
class CustomFactory2 (line 8) | class CustomFactory2<T> implements Factory<T> {
method create (line 10) | @NotNull
FILE: magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/CustomFactory3.java
class CustomFactory3 (line 8) | class CustomFactory3 implements Factory<Interface3> {
method create (line 10) | @NotNull
FILE: magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/Implementation1.java
class Implementation1 (line 5) | @Instance(
FILE: magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/Implementation2.java
class Implementation2 (line 5) | @Instance(
FILE: magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/Implementation3.java
class Implementation3 (line 5) | @Instance(
method Implementation3 (line 11) | public Implementation3(String value1, Long value2) {}
FILE: magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/Interface1.java
type Interface1 (line 3) | public interface Interface1 {}
FILE: magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/Interface2.java
type Interface2 (line 3) | public interface Interface2 {}
FILE: magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/Interface3.java
type Interface3 (line 3) | public interface Interface3 {}
FILE: magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/expected/Implementation1MagnetFactory.java
class Implementation1MagnetFactory (line 9) | @Generated
method create (line 14) | @Override
method instantiate (line 22) | @Override
method getType (line 27) | public static Class getType() {
FILE: magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/expected/Implementation2MagnetFactory.java
class Implementation2MagnetFactory (line 9) | @Generated
method create (line 14) | @Override
method instantiate (line 22) | @Override
method getType (line 27) | public static Class getType() {
FILE: magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/expected/Implementation3MagnetFactory.java
class Implementation3MagnetFactory (line 9) | @Generated
method create (line 14) | @Override
method instantiate (line 22) | @Override
method getType (line 29) | public static Class getType() {
FILE: magnet-processor/src/test/resources/InstanceDisposerTest/Implementation1.java
class Implementation1 (line 5) | @Instance(
method disposeIt (line 11) | void disposeIt() {}
FILE: magnet-processor/src/test/resources/InstanceDisposerTest/Implementation2.java
class Implementation2 (line 5) | @Instance(
method dispose (line 11) | void dispose() {}
FILE: magnet-processor/src/test/resources/InstanceDisposerTest/Implementation3.java
class Implementation3 (line 5) | @Instance(
method disposeIt (line 11) | void disposeIt(String value) {}
FILE: magnet-processor/src/test/resources/InstanceDisposerTest/Implementation4.java
class Implementation4 (line 5) | @Instance(
method disposeIt (line 11) | String disposeIt() { return null; }
FILE: magnet-processor/src/test/resources/InstanceDisposerTest/Implementation5.java
class Implementation5 (line 6) | @Instance(
method disposeIt (line 13) | void disposeIt() { return null; }
FILE: magnet-processor/src/test/resources/InstanceDisposerTest/Interface.java
type Interface (line 3) | public interface Interface {}
FILE: magnet-processor/src/test/resources/InstanceDisposerTest/expected/Implementation1MagnetFactory.java
class Implementation1MagnetFactory (line 7) | @Generated
method create (line 10) | @Override
method isDisposable (line 15) | @Override
method dispose (line 20) | @Override
method getType (line 25) | public static Class getType() {
FILE: magnet-processor/src/test/resources/InstanceIndexProcessorTest/Implementation1.java
class Implementation1 (line 6) | @Instance(
method Implementation1 (line 12) | Implementation1() {}
method getId (line 14) | @Override
FILE: magnet-processor/src/test/resources/InstanceIndexProcessorTest/Implementation2.java
class Implementation2 (line 6) | @Instance(type = Interface2.class)
FILE: magnet-processor/src/test/resources/InstanceIndexProcessorTest/Interface1.java
type Interface1 (line 3) | public interface Interface1 {
method getId (line 4) | int getId();
FILE: magnet-processor/src/test/resources/InstanceIndexProcessorTest/Interface2.java
type Interface2 (line 3) | public interface Interface2 {}
FILE: magnet-processor/src/test/resources/InstanceIndexProcessorTest/generated/app_test_Implementation1MagnetFactory.java
class app_test_Implementation1MagnetFactory (line 8) | @Generated
FILE: magnet-processor/src/test/resources/InstanceIndexProcessorTest/generated/app_test_Implementation2MagnetFactory.java
class app_test_Implementation2MagnetFactory (line 8) | @Generated
FILE: magnet-processor/src/test/resources/MagnetProcessorFactoryNamesTest/Delegate1.java
class Delegate1 (line 5) | @Instance(type = Delegate1.class)
FILE: magnet-processor/src/test/resources/MagnetProcessorFactoryNamesTest/Interface1.java
type Interface1 (line 5) | interface Interface1 {
class Delegate (line 7) | @Instance(type = Interface1.Delegate.class)
FILE: magnet-processor/src/test/resources/MagnetProcessorFactoryNamesTest/generated/Delegate1MagnetFactory.java
class Delegate1MagnetFactory (line 7) | @Generated
method create (line 9) | @Override
method getType (line 14) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorFactoryNamesTest/generated/Interface1DelegateMagnetFactory.java
class Interface1DelegateMagnetFactory (line 7) | @Generated
method create (line 9) | @Override
method getType (line 14) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/AppExtensionRegistry.java
type AppExtensionRegistry (line 5) | @Registry
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Constructor_PackagePrivate_PackagePrivate/UnderTest.java
class UnderTest (line 6) | @Instance(type = UnderTest.class)
method UnderTest (line 9) | UnderTest(Scope scope) { }
method UnderTest (line 10) | UnderTest() { }
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Constructor_PackagePrivate_Private/UnderTest.java
class UnderTest (line 6) | @Instance(type = UnderTest.class)
method UnderTest (line 9) | UnderTest(Scope scope) { }
method UnderTest (line 10) | private UnderTest() { }
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Constructor_PackagePrivate_Private/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 7) | @Generated
method create (line 9) | @Override
method getType (line 14) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Constructor_Private/UnderTest.java
class UnderTest (line 5) | @Instance(type = UnderTest.class)
method UnderTest (line 8) | private UnderTest() { }
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Constructor_Protected/UnderTest.java
class UnderTest (line 5) | @Instance(type = UnderTest.class)
method UnderTest (line 8) | protected UnderTest() { }
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Constructor_Public_PackagePrivate/UnderTest.java
class UnderTest (line 6) | @Instance(type = UnderTest.class)
method UnderTest (line 9) | public UnderTest(Scope scope) { }
method UnderTest (line 10) | UnderTest() { }
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Constructor_Public_Private/UnderTest.java
class UnderTest (line 6) | @Instance(type = UnderTest.class)
method UnderTest (line 9) | public UnderTest(Scope scope) { }
method UnderTest (line 10) | private UnderTest() { }
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Constructor_Public_Private/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 7) | @Generated
method create (line 9) | @Override
method getType (line 14) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Constructor_Public_Protected/UnderTest.java
class UnderTest (line 6) | @Instance(type = UnderTest.class)
method UnderTest (line 9) | public UnderTest(Scope scope) { }
method UnderTest (line 10) | protected UnderTest() { }
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Constructor_Public_Protected/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 7) | @Generated
method create (line 9) | @Override
method getType (line 14) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Constructor_Public_Public/UnderTest.java
class UnderTest (line 6) | @Instance(type = UnderTest.class)
method UnderTest (line 9) | public UnderTest(Scope scope) { }
method UnderTest (line 10) | public UnderTest() { }
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Constructor_Public_Public_Kotlin/UnderTest.java
class UnderTest (line 8) | @Metadata(
method UnderTest (line 19) | public UnderTest(@NotNull String value) {
method UnderTest (line 23) | public UnderTest(@NotNull Scope parentScope) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Covariance_Constructor_ManyParameter/Foo.java
class Foo (line 3) | public class Foo {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Covariance_Constructor_ManyParameter/UnderTest.java
class UnderTest (line 7) | @Instance(type = UnderTest.class)
method UnderTest (line 10) | public UnderTest(List<? extends Foo> dep) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Covariance_Constructor_ManyParameter/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 8) | @Generated
method create (line 10) | @Override
method getType (line 16) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Covariance_Constructor_SingleParameter/Foo.java
class Foo (line 3) | public class Foo {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Covariance_Constructor_SingleParameter/UnderTest.java
class UnderTest (line 5) | @Instance(type = UnderTest.class)
method UnderTest (line 8) | public UnderTest(T dep) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/DefaultArguments_JvmOverloads_AtTheEnd/UnderTest.java
class UnderTest (line 7) | @Metadata(
method UnderTest (line 19) | public UnderTest(@NotNull String value1, @NotNull String value2, @NotN...
method UnderTest (line 23) | public UnderTest(@NotNull String value1, @NotNull String value2) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/DefaultArguments_JvmOverloads_AtTheEnd/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 7) | @Generated
method create (line 9) | @Override
method getType (line 16) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/DefaultArguments_JvmOverloads_InTheMiddle/UnderTest.java
class UnderTest (line 7) | @Metadata(
method UnderTest (line 19) | public UnderTest(@NotNull String value1, @NotNull String value2, @NotN...
method UnderTest (line 23) | public UnderTest(@NotNull String value1, @NotNull String value3) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/DefaultArguments_JvmOverloads_InTheMiddle/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 7) | @Generated
method create (line 9) | @Override
method getType (line 16) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/DefaultArguments_JvmOverloads_Mixed/UnderTest.java
class UnderTest (line 7) | @Metadata(
method UnderTest (line 19) | public UnderTest(@NotNull String value1, @NotNull String value2, @NotN...
method UnderTest (line 23) | public UnderTest(@NotNull String value1, @NotNull String value2, @NotN...
method UnderTest (line 27) | public UnderTest(@NotNull String value1, @NotNull String value3) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/DefaultArguments_JvmOverloads_Mixed/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 7) | @Generated
method create (line 9) | @Override
method getType (line 16) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/DisabledTab.java
class UnimplementedTypeTab (line 5) | @Instance(type = Tab.class, disabled = true)
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Executor.java
type Executor (line 3) | interface Executor<R extends Runnable> {
method execute (line 5) | void execute(R runnable);
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/ExecutorImpl.java
class ExecutorImpl (line 5) | @Instance(
method execute (line 10) | @Override
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/ExecutorMaster.java
class ExecutorMaster (line 5) | @Instance(type = ExecutorMaster.class)
method ExecutorMaster (line 8) | public ExecutorMaster(Executor<Runnable> executor) {}
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Generics_GetOptional_Unchecked/Dependency.java
type Dependency (line 3) | interface Dependency<T extends Runnable> {
method run (line 4) | void run();
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Generics_GetOptional_Unchecked/UnderTest.java
class UnderTest (line 7) | @Instance(type = UnderTest.class)
method UnderTest (line 9) | public UnderTest(@Nullable Dependency<Thread> dependency) { }
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Generics_GetOptional_Unchecked/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 7) | @Generated
method create (line 10) | @Override
method getType (line 17) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Generics_GetSingle_Unchecked/Dependency.java
type Dependency (line 3) | interface Dependency<T extends Runnable> {
method run (line 4) | void run();
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Generics_GetSingle_Unchecked/UnderTest.java
class UnderTest (line 5) | @Instance(type = UnderTest.class)
method UnderTest (line 7) | public UnderTest(Dependency<Thread> dependency) { }
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Generics_GetSingle_Unchecked/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 7) | @Generated
method create (line 10) | @Override
method getType (line 17) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Generics_ProvideTypeWithParameter/Parameter.java
class Parameter (line 3) | class Parameter {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Generics_ProvideTypeWithParameter/Type.java
type Type (line 3) | interface Type<Parameter> {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Generics_ProvideTypeWithParameter/UnderTest.java
class UnderTest (line 5) | class UnderTest {
method provideType (line 7) | @Instance(type = Type.class, classifier = "parameter-type")
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Generics_ProvideTypeWithParameter/expected/UnderTestProvideTypeMagnetFactory.java
class UnderTestProvideTypeMagnetFactory (line 7) | @Generated
method create (line 9) | @Override
method getType (line 14) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Generics_ProvideTypeWithParameter_NoClassifier/Parameter.java
class Parameter (line 3) | class Parameter {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Generics_ProvideTypeWithParameter_NoClassifier/Type.java
type Type (line 3) | interface Type<Parameter> {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Generics_ProvideTypeWithParameter_NoClassifier/UnderTest.java
class UnderTest (line 5) | class UnderTest {
method provideType (line 7) | @Instance(type = Type.class)
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Generics_ProvideTypeWithParameter_NoClassifier/expected/UnderTestProvideTypeMagnetFactory.java
class UnderTestProvideTypeMagnetFactory (line 7) | @Generated
method create (line 9) | @Override
method getType (line 14) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/HomePage.java
class HomePage (line 9) | @Instance(type = Page.class)
method HomePage (line 12) | HomePage(
method show (line 18) | @Override
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/HomePageMenuItem.java
class HomePageMenuItem (line 7) | @Instance(
method HomePageMenuItem (line 13) | HomePageMenuItem(Scope scope) {
method getId (line 16) | @Override
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/HomePageNoParams.java
class HomePageNoParams (line 6) | @Instance(type = Page.class)
method HomePageNoParams (line 9) | HomePageNoParams() { }
method show (line 11) | @Override
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/HomePageWithClassifierParams.java
class HomePageWithClassifierParams (line 11) | @Instance(type = Page.class)
method HomePageWithClassifierParams (line 16) | HomePageWithClassifierParams(
method show (line 21) | @Override
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/HomePageWithGenericParam.java
class HomePageWithGenericParam (line 6) | @Instance(type = Page.class)
method HomePageWithGenericParam (line 9) | HomePageWithGenericParam(T genericThing) { }
method show (line 11) | @Override
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/HomePageWithManyParameterizedParams.java
class HomePageWithManyParameterizedParams (line 12) | @Instance(type = Page.class)
method HomePageWithManyParameterizedParams (line 15) | HomePageWithManyParameterizedParams(
method show (line 22) | @Override
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/HomePageWithManyParameterizedWildcardInParams.java
class HomePageWithManyParameterizedWildcardInParams (line 12) | @Instance(type = Page.class)
method HomePageWithManyParameterizedWildcardInParams (line 15) | HomePageWithManyParameterizedWildcardInParams(
method show (line 22) | @Override
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/HomePageWithManyParameterizedWildcardKnownParams.java
class HomePageWithManyParameterizedWildcardKnownParams (line 12) | @Instance(type = Page.class)
method HomePageWithManyParameterizedWildcardKnownParams (line 15) | HomePageWithManyParameterizedWildcardKnownParams(
method show (line 22) | @Override
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/HomePageWithManyParameterizedWildcardOutParams.java
class HomePageWithManyParameterizedWildcardOutParams (line 12) | @Instance(type = Page.class)
method HomePageWithManyParameterizedWildcardOutParams (line 15) | HomePageWithManyParameterizedWildcardOutParams(
method show (line 22) | @Override
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/HomePageWithManyParams.java
class HomePageWithManyParams (line 13) | @Instance(type = Page.class)
method HomePageWithManyParams (line 16) | HomePageWithManyParams(
method show (line 23) | @Override
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/HomePageWithManyWildcardParams.java
class HomePageWithManyWildcardParams (line 9) | @Instance(type = Page.class)
method HomePageWithManyWildcardParams (line 12) | HomePageWithManyWildcardParams(
method show (line 16) | @Override
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/HomePageWithParams.java
class HomePageWithParams (line 12) | @Instance(type = Page.class)
method HomePageWithParams (line 15) | HomePageWithParams(
method show (line 20) | @Override
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/HomePageWithScope.java
class HomePageWithScope (line 7) | @Instance(type = Page.class)
method HomePageWithScope (line 10) | HomePageWithScope(Scope scope) { }
method show (line 12) | @Override
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/HomePageWithStaticConstructor.java
class HomePageWithStaticConstructor (line 8) | public class HomePageWithStaticConstructor implements Page {
method HomePageWithStaticConstructor (line 10) | public HomePageWithStaticConstructor(
method show (line 14) | @Override
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/HomePageWithStaticConstructorDisabled.java
class HomePageWithStaticConstructorDisabled (line 11) | public class HomePageWithStaticConstructorDisabled {
method create (line 13) | @Instance(
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/HomePageWithStaticConstructorSingle.java
class HomePageWithStaticConstructorSingle (line 11) | public class HomePageWithStaticConstructorSingle {
method create (line 13) | @Instance(
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/HomeRepository.java
type HomeRepository (line 3) | public interface HomeRepository {
method getHomePageData (line 5) | String[] getHomePageData();
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Constructor_ManyParameter/UnderTest.java
class UnderTest (line 10) | @Metadata(
method UnderTest (line 20) | public UnderTest(@NotNull Lazy<List<String>> dep) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Constructor_ManyParameter/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 10) | @Generated
method create (line 12) | @Override
method getType (line 18) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Constructor_ManyParameter_NullableGenericType/UnderTest.java
class UnderTest (line 10) | @Metadata(
method UnderTest (line 20) | public UnderTest(@NotNull Lazy<List<String>> dep) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Constructor_ManyParameter_NullableListType/UnderTest.java
class UnderTest (line 10) | @Metadata(
method UnderTest (line 20) | public UnderTest(@NotNull Lazy<List<String>> dep) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Constructor_ManyParameter_Wildcard/UnderTest.java
class UnderTest (line 10) | @Metadata(
method UnderTest (line 20) | public UnderTest(@NotNull Lazy<? extends List<? extends String>> dep) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Constructor_ManyParameter_Wildcard/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 10) | @Generated
method create (line 12) | @Override
method getType (line 18) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Constructor_NoKotlinMetadata/UnderTest.java
class UnderTest (line 7) | @Instance(type = UnderTest.class)
method UnderTest (line 10) | public UnderTest(@NotNull Lazy<String> dep) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Constructor_OptionalParameter/UnderTest.java
class UnderTest (line 8) | @Metadata(
method UnderTest (line 18) | public UnderTest(@NotNull Lazy<String> dep) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Constructor_OptionalParameter/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 9) | @Generated
method create (line 11) | @Override
method getType (line 17) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Constructor_OptionalParameter_Wildcard/UnderTest.java
class UnderTest (line 8) | @Metadata(
method UnderTest (line 18) | public UnderTest(@NotNull Lazy<? extends String> dep) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Constructor_OptionalParameter_Wildcard/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 9) | @Generated
method create (line 11) | @Override
method getType (line 17) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Constructor_SingleParameter/UnderTest.java
class UnderTest (line 8) | @Metadata(
method UnderTest (line 18) | public UnderTest(@NotNull Lazy<String> dep) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Constructor_SingleParameter/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 9) | @Generated
method create (line 11) | @Override
method getType (line 17) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Constructor_SingleParameter_ParameterizedType/Foo.java
class Foo (line 3) | public class Foo<T> {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Constructor_SingleParameter_ParameterizedType/UnderTest.java
class UnderTest (line 8) | @Metadata(
method UnderTest (line 18) | public UnderTest(@NotNull Lazy<Foo<String>> dep) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Constructor_SingleParameter_ParameterizedType/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 9) | @Generated
method create (line 11) | @Override
method getType (line 17) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Constructor_SingleParameter_Wildcard/UnderTest.java
class UnderTest (line 8) | @Metadata(
method UnderTest (line 18) | public UnderTest(@NotNull Lazy<? extends String> dep) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Constructor_SingleParameter_Wildcard/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 9) | @Generated
method create (line 11) | @Override
method getType (line 17) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Method_NoKotlinMetadata/UnderTest.java
class UnderTest (line 7) | public class UnderTest {
method provideUnderTest (line 9) | @Instance(type = UnderTest.class)
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Method_OptionalParameter/UnderTest.java
class UnderTest (line 8) | @Metadata(
method provideUnderTest (line 17) | @Instance(type = UnderTest.class)
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Method_OptionalParameter/expected/UnderTestProvideUnderTestDepMagnetFactory.java
class UnderTestProvideUnderTestDepMagnetFactory (line 9) | @Generated
method create (line 11) | @Override
method getType (line 17) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Method_OptionalParameter_Wildcard/UnderTest.java
class UnderTest (line 8) | @Metadata(
method provideUnderTest (line 17) | @Instance(type = UnderTest.class)
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Method_OptionalParameter_Wildcard/expected/UnderTestProvideUnderTestDepMagnetFactory.java
class UnderTestProvideUnderTestDepMagnetFactory (line 9) | @Generated
method create (line 11) | @Override
method getType (line 17) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Method_SingleParameter/UnderTest.java
class UnderTest (line 8) | @Metadata(
method provideUnderTest (line 17) | @Instance(type = UnderTest.class)
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Method_SingleParameter/expected/UnderTestProvideUnderTestDepMagnetFactory.java
class UnderTestProvideUnderTestDepMagnetFactory (line 9) | @Generated
method create (line 11) | @Override
method getType (line 17) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Method_SingleParameter_Wildcard/UnderTest.java
class UnderTest (line 8) | @Metadata(
method provideUnderTest (line 17) | @Instance(type = UnderTest.class)
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Lazy_Method_SingleParameter_Wildcard/expected/UnderTestProvideUnderTestDepMagnetFactory.java
class UnderTestProvideUnderTestDepMagnetFactory (line 9) | @Generated
method create (line 11) | @Override
method getType (line 17) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Limit_Empty_NoGetter/UnderTest.java
class UnderTest (line 6) | @Instance(
method UnderTest (line 11) | public UnderTest(Scope scope) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Limit_Empty_NoGetter/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 7) | @Generated
method create (line 9) | @Override
method getType (line 14) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Limit_NotEmpty_HasGetter/UnderTest.java
class UnderTest (line 6) | @Instance(
method UnderTest (line 11) | public UnderTest(Scope scope) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Limit_NotEmpty_HasGetter/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 7) | @Generated
method create (line 9) | @Override
method getLimit (line 14) | @Override
method getType (line 19) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Limit_ReservedAsterisks_Fails/UnderTest.java
class UnderTest (line 6) | @Instance(
method UnderTest (line 11) | public UnderTest(Scope scope) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Limit_ScopingDirect_GeneratesGetter/UnderTest.java
class UnderTest (line 7) | @Instance(
method UnderTest (line 13) | public UnderTest(Scope scope) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Limit_ScopingDirect_GeneratesGetter/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 8) | @Generated
method create (line 10) | @Override
method getScoping (line 15) | @Override
method getLimit (line 20) | @Override
method getType (line 25) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Limit_ScopingUnscoped_Fails/UnderTest.java
class UnderTest (line 7) | @Instance(
method UnderTest (line 13) | public UnderTest(Scope scope) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/MenuItem.java
type MenuItem (line 3) | public interface MenuItem {
method getId (line 4) | int getId();
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Page.java
type Page (line 3) | public interface Page {
method show (line 4) | void show();
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/ScopeParameter_CustomName/UnderTest.java
class UnderTest (line 6) | @Instance(type = UnderTest.class)
method UnderTest (line 9) | public UnderTest(Scope parentScope) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/ScopeParameter_CustomName/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 7) | @Generated
method create (line 9) | @Override
method getType (line 14) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/ScopeParameter_CustomName_KotlinClass/UnderTest.java
class UnderTest (line 8) | @Metadata(
method UnderTest (line 20) | public UnderTest(@NotNull Scope parentScope) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/ScopeParameter_CustomName_KotlinClass/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 7) | @Generated
method create (line 9) | @Override
method getType (line 14) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/ScopeParameter_DefaultName/UnderTest.java
class UnderTest (line 6) | @Instance(type = UnderTest.class)
method UnderTest (line 9) | public UnderTest(Scope scope) {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/ScopeParameter_DefaultName/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 7) | @Generated
method create (line 9) | @Override
method getType (line 14) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/StaticMethodNeedsDependencyWithClassifier/Constants.java
class Constants (line 3) | public final class Constants {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/StaticMethodNeedsDependencyWithClassifier/Input.java
type Input (line 3) | public interface Input { }
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/StaticMethodNeedsDependencyWithClassifier/Output.java
class Output (line 3) | public class Output { }
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/StaticMethodNeedsDependencyWithClassifier/StaticFunction.java
class StaticFunction (line 6) | public class StaticFunction {
method provide (line 8) | @Instance(type = Output.class)
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/StaticMethodNeedsDependencyWithClassifier/generated/StaticFunctionProvideInputMagnetFactory.java
class StaticFunctionProvideInputMagnetFactory (line 7) | @Generated
method create (line 10) | @Override
method getType (line 16) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/StaticMethodProvidesInnerClass/PowerManager.java
class PowerManager (line 3) | public class PowerManager {
class WakeLock (line 4) | public static class WakeLock {
method aquire (line 5) | public void aquire(Long timeout) {}
method release (line 6) | public void release() {}
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/StaticMethodProvidesInnerClass/PowerManagerProvider.java
class PowerManagerProvider (line 5) | public class PowerManagerProvider {
method provideWakeLock (line 7) | @Instance(type = PowerManager.WakeLock.class)
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/StaticMethodProvidesInnerClass/expected/PowerManagerProviderProvideWakeLockMagnetFactory.java
class PowerManagerProviderProvideWakeLockMagnetFactory (line 7) | @Generated
method create (line 10) | @Override
method getType (line 15) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/Tab.java
type Tab (line 3) | interface Tab {}
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/TypeAutoDetect_ExtendsObjectNoInterfaces/UnderTest.java
class UnderTest (line 7) | @Instance
method UnderTest (line 9) | public UnderTest() { }
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/TypeAutoDetect_ExtendsObjectNoInterfaces/expected/UnderTestMagnetFactory.java
class UnderTestMagnetFactory (line 7) | @Generated
method create (line 10) | @Override
method getType (line 15) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/UnimplementedTab.java
class UnimplementedTypeTab (line 5) | @Instance(type = Tab.class)
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/UserData.java
type UserData (line 3) | public interface UserData {
method getFullName (line 5) | String getFullName();
method getEmail (line 6) | String getEmail();
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/UserPage.java
class UserPage (line 7) | @Instance(type = Page.class)
method UserPage (line 10) | UserPage(Scope registry) {
method show (line 13) | @Override
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/UserPageMenuItem.java
class UserPageMenuItem (line 7) | @Instance(
method UserPageMenuItem (line 13) | UserPageMenuItem(Scope registry) {
method getId (line 16) | @Override
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/WorkProcessor.java
type WorkProcessor (line 3) | public interface WorkProcessor<I extends Runnable> {
method processWork (line 5) | void processWork(I processor);
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/generated/ForInterfaceWithGenericType_ExecutorMagnetFactory.java
class ExecutorImplMagnetFactory (line 7) | @Generated
method create (line 9) | @Override
method getType (line 14) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/generated/HomePageMagnetFactory.java
class HomePageMagnetFactory (line 10) | @Generated
method create (line 13) | @Override
method getType (line 20) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/generated/HomePageNoParamsMagnetFactory.java
class HomePageNoParamsMagnetFactory (line 8) | @Generated
method create (line 11) | @Override
method getType (line 16) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/generated/HomePageWithClassifierParamsMagnetFactory.java
class HomePageWithClassifierParamsMagnetFactory (line 10) | @Generated
method create (line 13) | @Override
method getType (line 20) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/generated/HomePageWithManyParameterizedParamsMagnetFactory.java
class HomePageWithManyParameterizedParamsMagnetFactory (line 10) | @Generated
method create (line 12) | @Override
method getType (line 22) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/generated/HomePageWithManyParameterizedWildcardInParamsMagnetFactory.java
class HomePageWithManyParameterizedWildcardInParamsMagnetFactory (line 10) | @Generated
method create (line 12) | @Override
method getType (line 22) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/generated/HomePageWithManyParameterizedWildcardKnownParamsMagnetFactory.java
class HomePageWithManyParameterizedWildcardKnownParamsMagnetFactory (line 11) | @Generated
method create (line 13) | @Override
method getType (line 23) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/generated/HomePageWithManyParameterizedWildcardOutParamsMagnetFactory.java
class HomePageWithManyParameterizedWildcardOutParamsMagnetFactory (line 11) | @Generated
method create (line 13) | @Override
method getType (line 23) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/generated/HomePageWithManyParamsMagnetFactory.java
class HomePageWithManyParamsMagnetFactory (line 10) | @Generated
method create (line 13) | @Override
method getType (line 22) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/generated/HomePageWithManyWildcardParamsMagnetFactory.java
class HomePageWithManyWildcardParamsMagnetFactory (line 11) | @Generated
method create (line 14) | @Override
method getType (line 20) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/generated/HomePageWithParamsMagnetFactory.java
class HomePageWithParamsMagnetFactory (line 10) | @Generated
method create (line 13) | @Override
method getType (line 20) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/generated/HomePageWithScopeMagnetFactory.java
class HomePageWithScopeMagnetFactory (line 8) | @Generated
method create (line 11) | @Override
method getType (line 16) | public static Class getType() {
FILE: magnet-processor/src/test/resources/MagnetProcessorTest/generated/HomePageWithStaticConstructorSingleCreateRepositoriesMagnetFactory.java
class HomePageWithStaticConstructorSingleCreateRepositoriesMagnetFactory (line 11) | @Generated
method create (line 14) | @Override
method getScoping (line 20) | @Override
method getType (line 25) | public static Class getType() {
FILE: magnet-processor/src/test/resources/SelectorInFactoryClassTest/Implementation1.java
class Implementation1 (line 5) | @Instance(
FILE: magnet-processor/src/test/resources/SelectorInFactoryClassTest/Implementation10.java
class Implementation10 (line 5) | @Instance(
FILE: magnet-processor/src/test/resources/SelectorInFactoryClassTest/Implementation2.java
class Implementation2 (line 5) | @Instance(
FILE: magnet-processor/src/test/resources/SelectorInFactoryClassTest/Implementation3.java
class Implementation3 (line 5) | @Instance(
FILE: magnet-processor/src/test/resources/SelectorInFactoryClassTest/Implementation4.java
class Implementation4 (line 5) | @Instance(
FILE: magnet-processor/src/test/resources/SelectorInFactoryClassTest/Implementation5.java
class Implementation5 (line 5) | @Instance(
FILE: magnet-processor/src/test/resources/SelectorInFactoryClassTest/Implementation6.java
class Implementation6 (line 5) | @Instance(
FILE: magnet-processor/src/test/resources/SelectorInFactoryClassTest/Implementation7.java
class Implementation7 (line 5) | @Instance(
FILE: magnet-processor/src/test/resources/SelectorInFactoryClassTest/Implementation8.java
class Implementation8 (line 5) | @Instance(
FILE: magnet-processor/src/test/resources/SelectorInFactoryClassTest/Implementation9.java
class Implementation9 (line 5) | @Instance(
FILE: magnet-processor/src/test/resources/SelectorInFactoryClassTest/Interface.java
type Interface (line 3) | interface Interface {}
FILE: magnet-processor/src/test/resources/SelectorInFactoryClassTest/generated/Implementation10MagnetFactory.java
class Implementation10MagnetFactory (line 7) | @Generated
method create (line 11) | @Override
method getSelector (line 16) | @Override
method getType (line 21) | public static Class getType() {
FILE: magnet-processor/src/test/resources/SelectorInFactoryClassTest/generated/Implementation1MagnetFactory.java
class Implementation1MagnetFactory (line 7) | @Generated
method create (line 9) | @Override
method getType (line 14) | public static Class getType() {
FILE: magnet-processor/src/test/resources/SelectorInFactoryClassTest/generated/Implementation7MagnetFactory.java
class Implementation7MagnetFactory (line 7) | @Generated
method create (line 11) | @Override
method getSelector (line 16) | @Override
method getType (line 21) | public static Class getType() {
FILE: magnet-processor/src/test/resources/SelectorInFactoryClassTest/generated/Implementation8MagnetFactory.java
class Implementation8MagnetFactory (line 7) | @Generated
method create (line 11) | @Override
method getSelector (line 16) | @Override
method getType (line 21) | public static Class getType() {
FILE: magnet-processor/src/test/resources/SelectorInFactoryClassTest/generated/Implementation9MagnetFactory.java
class Implementation9MagnetFactory (line 7) | @Generated
method create (line 11) | @Override
method getSelector (line 16) | @Override
method getType (line 21) | public static Class getType() {
FILE: magnet-processor/src/test/resources/SiblingTypesTest/Implementation1.java
class Implementation1 (line 5) | @Instance()
FILE: magnet-processor/src/test/resources/SiblingTypesTest/Implementation2.java
class Implementation1 (line 5) | @Instance(type = Interface1.class, types = {Interface1.class, Interface2...
FILE: magnet-processor/src/test/resources/SiblingTypesTest/Implementation3.java
class Implementation1 (line 5) | @Instance(type = Interface1.class, types = {Interface1.class, Interface2...
FILE: magnet-processor/src/test/resources/SiblingTypesTest/Implementation4.java
class Implementation4 (line 5) | @Instance(types = {Interface1.class, Interface2.class})
FILE: magnet-processor/src/test/resources/SiblingTypesTest/Implementation5.java
class Implementation5 (line 6) | @Instance(types = {Interface1.class, Interface2.class}, scoping = Scopin...
FILE: magnet-processor/src/test/resources/SiblingTypesTest/Interface1.java
type Interface1 (line 3) | interface Interface1 {}
FILE: magnet-processor/src/test/resources/SiblingTypesTest/Interface2.java
type Interface2 (line 3) | interface Interface2 {}
FILE: magnet-processor/src/test/resources/SiblingTypesTest/generated/Implementation4Interface1MagnetFactory.java
class Implementation4Interface1MagnetFactory (line 7) | @Generated
method create (line 11) | @Override
method getSiblingTypes (line 16) | @Override
method getType (line 21) | public static Class getType() {
FILE: magnet-processor/src/test/resources/SiblingTypesTest/generated/Implementation4Interface2MagnetFactory.java
class Implementation4Interface2MagnetFactory (line 7) | @Generated
method create (line 11) | @Override
method getSiblingTypes (line 16) | @Override
method getType (line 21) | public static Class getType() {
FILE: magnet/src/main/java/magnet/Factory.java
type Factory (line 22) | public interface Factory<T> {
method create (line 25) | @NotNull
type Instantiator (line 35) | interface Instantiator<T> {
method instantiate (line 36) | @NotNull
FILE: magnet/src/main/java/magnet/Magnet.java
class Magnet (line 22) | public final class Magnet {
method Magnet (line 24) | private Magnet() { }
method createRootScope (line 26) | public static @NotNull Scope createRootScope() {
FILE: magnet/src/main/java/magnet/Scope.java
type Scope (line 93) | public interface Scope {
method getOptional (line 96) | @Nullable <T> T getOptional(@NotNull Class<T> type);
method getOptional (line 99) | @Nullable <T> T getOptional(@NotNull Class<T> type, @NotNull String cl...
method getSingle (line 102) | @NotNull <T> T getSingle(@NotNull Class<T> type);
method getSingle (line 105) | @NotNull <T> T getSingle(@NotNull Class<T> type, @NotNull String class...
method getMany (line 108) | @NotNull <T> List<T> getMany(@NotNull Class<T> type);
method getMany (line 111) | @NotNull <T> List<T> getMany(@NotNull Class<T> type, @NotNull String c...
method bind (line 114) | @NotNull <T> Scope bind(@NotNull Class<T> type, @NotNull T instance);
method bind (line 117) | @NotNull <T> Scope bind(@NotNull Class<T> type, @NotNull T instance, @...
method limit (line 120) | @NotNull Scope limit(String... limits);
method createSubscope (line 123) | @NotNull Scope createSubscope();
method dispose (line 126) | void dispose();
method isDisposed (line 129) | boolean isDisposed();
method accept (line 132) | void accept(Visitor visitor, int depth);
FILE: magnet/src/main/java/magnet/Scoping.java
type Scoping (line 23) | public enum Scoping {
FILE: magnet/src/main/java/magnet/SelectorFilter.java
class SelectorFilter (line 22) | public abstract class SelectorFilter {
method filter (line 25) | public abstract boolean filter(@NotNull String[] selector);
FILE: magnet/src/main/java/magnet/Visitor.java
type Visitor (line 11) | public interface Visitor {
type Provision (line 14) | enum Provision {BOUND, INJECTED}
type Instance (line 17) | interface Instance {
method getScoping (line 18) | @NotNull Scoping getScoping();
method getClassifier (line 19) | @NotNull String getClassifier();
method getLimit (line 20) | @NotNull String getLimit();
method getType (line 21) | @NotNull Class<?> getType();
method getValue (line 22) | @NotNull Object getValue();
method getProvision (line 23) | @NotNull Provision getProvision();
type Scope (line 27) | interface Scope {
method getLimits (line 28) | @Nullable String[] getLimits();
method onEnterScope (line 38) | boolean onEnterScope(@NotNull Scope scope, @Nullable Scope parent);
method onInstance (line 48) | boolean onInstance(@NotNull Instance instance);
method onExitScope (line 55) | void onExitScope(@NotNull Scope scope);
FILE: magnet/src/main/java/magnet/internal/FactoryFilter.java
type FactoryFilter (line 20) | interface FactoryFilter {
method filter (line 21) | boolean filter(InstanceFactory factory);
FILE: magnet/src/main/java/magnet/internal/ImmutableArrayList.java
class ImmutableArrayList (line 22) | class ImmutableArrayList<E> extends AbstractList<E> {
method ImmutableArrayList (line 26) | ImmutableArrayList(E[] elements) {
method get (line 30) | @Override public E get(int i) {
method size (line 39) | @Override public int size() {
FILE: magnet/src/main/java/magnet/internal/InstanceBucket.java
class InstanceBucket (line 32) | @SuppressWarnings("unchecked")
method InstanceBucket (line 39) | InstanceBucket(
method getScope (line 52) | @NotNull MagnetScope getScope() { return scope; }
method getSingleInstance (line 54) | @NotNull T getSingleInstance() {
method getOptional (line 70) | @Nullable T getOptional(@Nullable Class<InstanceFactory<T>> factoryTyp...
method getMany (line 87) | @NotNull List<T> getMany() {
method registerObject (line 96) | void registerObject(
method hasInstanceWithFactory (line 113) | boolean hasInstanceWithFactory(@Nullable InstanceFactory<T> factory) {
method createSingleInstance (line 117) | private @NotNull InstanceBucket.SingleObjectInstance<T> createSingleIn...
method accept (line 133) | public boolean accept(Visitor visitor) {
type Instance (line 141) | interface Instance<T> {
method hasObjectWithFactory (line 142) | boolean hasObjectWithFactory(@Nullable InstanceFactory<T> factory);
class SingleObjectInstance (line 145) | static abstract class SingleObjectInstance<T> implements Instance<T> {
method SingleObjectInstance (line 150) | SingleObjectInstance(
method accept (line 160) | public boolean accept(Visitor visitor) {
class BoundInstance (line 169) | static class BoundInstance<T> extends SingleObjectInstance<T> implemen...
method BoundInstance (line 170) | BoundInstance(@NotNull Class<T> objectType, @NotNull T object, @NotN...
method hasObjectWithFactory (line 174) | @Override public boolean hasObjectWithFactory(@Nullable InstanceFact...
method getScoping (line 177) | @Override public @NotNull Scoping getScoping() { return Scoping.DIRE...
method getClassifier (line 178) | @Override public @NotNull String getClassifier() { return classifier; }
method getLimit (line 179) | @Override public @NotNull String getLimit() { return ""; }
method getType (line 180) | @Override public @NotNull Class<?> getType() { return objectType; }
method getValue (line 181) | @Override public @NotNull Object getValue() { return object; }
method getProvision (line 182) | @Override public @NotNull Visitor.Provision getProvision() {
class InjectedInstance (line 187) | static class InjectedInstance<T> extends SingleObjectInstance<T> imple...
method InjectedInstance (line 190) | InjectedInstance(
method hasObjectWithFactory (line 200) | @Override public boolean hasObjectWithFactory(@Nullable InstanceFact...
method getScoping (line 203) | @Override public @NotNull Scoping getScoping() { return factory.getS...
method getClassifier (line 204) | @Override public @NotNull String getClassifier() { return classifier; }
method getLimit (line 205) | @Override public @NotNull String getLimit() { return factory.getLimi...
method getType (line 206) | @Override public @NotNull Class<?> getType() { return objectType; }
method getValue (line 207) | @Override public @NotNull Object getValue() { return object; }
method getProvision (line 208) | @Override public @NotNull Visitor.Provision getProvision() {
class MultiObjectInstance (line 213) | private static class MultiObjectInstance<T> implements Instance<T> {
method MultiObjectInstance (line 216) | MultiObjectInstance(@NotNull InstanceBucket.SingleObjectInstance<T> ...
method getMany (line 221) | @NotNull List<T> getMany() {
method getOptional (line 229) | @Nullable T getOptional(@Nullable Class<InstanceFactory<T>> factoryT...
method putSingle (line 235) | void putSingle(@NotNull InstanceBucket.SingleObjectInstance<T> singl...
method hasObjectWithFactory (line 247) | @Override public boolean hasObjectWithFactory(@Nullable InstanceFact...
method accept (line 251) | public boolean accept(Visitor visitor) {
type OnInstanceListener (line 262) | interface OnInstanceListener {
method onInstanceCreated (line 263) | <T> void onInstanceCreated(SingleObjectInstance<T> instance);
FILE: magnet/src/main/java/magnet/internal/InstanceFactory.java
class InstanceFactory (line 23) | public abstract class InstanceFactory<T> {
method create (line 25) | public abstract T create(Scope scope);
method getScoping (line 26) | public Scoping getScoping() { return Scoping.TOPMOST; }
method getLimit (line 27) | public String getLimit() { return ""; }
method getSiblingTypes (line 28) | public Class[] getSiblingTypes() { return null; }
method getSelector (line 29) | public String[] getSelector() { return null; }
method isDisposable (line 31) | public boolean isDisposable() { return false; }
method dispose (line 32) | public void dispose(T instance) {
FILE: magnet/src/main/java/magnet/internal/InstanceManager.java
type InstanceManager (line 25) | interface InstanceManager {
method getInstanceFactory (line 27) | <T> @Nullable InstanceFactory<T> getInstanceFactory(
method getFilteredInstanceFactory (line 30) | <T> @Nullable InstanceFactory<T> getFilteredInstanceFactory(
method getManyInstanceFactories (line 33) | <T> @NotNull List<InstanceFactory<T>> getManyInstanceFactories(
FILE: magnet/src/main/java/magnet/internal/InternalFactory.java
class InternalFactory (line 23) | public final class InternalFactory {
method InternalFactory (line 27) | private InternalFactory() {}
method createRootScope (line 29) | static @NotNull Scope createRootScope(@NotNull InstanceManager instanc...
method createRootScope (line 33) | public static @NotNull Scope createRootScope() {
FILE: magnet/src/main/java/magnet/internal/MagnetInstanceManager.java
class MagnetInstanceManager (line 30) | @SuppressWarnings("unchecked") final class MagnetInstanceManager impleme...
method MagnetInstanceManager (line 35) | MagnetInstanceManager() {
method registerInstanceFactories (line 39) | private void registerInstanceFactories() {
method register (line 55) | void register(InstanceFactory[] factories, Map<Class, Object> index) {
method getInstanceFactory (line 60) | @Override
method getFilteredInstanceFactory (line 77) | @Override
method getManyInstanceFactories (line 114) | @Override
method getOptionalRange (line 140) | private Range getOptionalRange(Class<?> type, String classifier) {
method factoriesFromRange (line 165) | private <T> List<InstanceFactory<T>> factoriesFromRange(Range range, F...
FILE: magnet/src/main/java/magnet/internal/MagnetScope.java
class MagnetScope (line 39) | final class MagnetScope implements Scope, Visitor.Scope, FactoryFilter, ...
method initialValue (line 59) | @Override protected InstantiationContext initialValue() {
method MagnetScope (line 64) | MagnetScope(@Nullable MagnetScope parent, @NotNull InstanceManager ins...
method getOptional (line 71) | @Override
method getOptional (line 79) | @Override
method getSingle (line 87) | @Override
method getSingle (line 92) | @Override
method getMany (line 109) | @Override
method getMany (line 115) | @Override
method bind (line 121) | @Override
method bind (line 127) | @Override
method createSubscope (line 155) | @Override
method limit (line 165) | @Override
method dispose (line 184) | @Override
method isDisposed (line 214) | @Override
method onChildScopeDisposed (line 219) | private void onChildScopeDisposed(MagnetScope childScope) {
method onInstanceCreated (line 238) | @Override
method checkNotDisposed (line 251) | private void checkNotDisposed() {
method filter (line 255) | @Override
method getManyObjects (line 273) | private <T> @NotNull List<T> getManyObjects(Class<T> type, String clas...
method findOrInjectOptional (line 285) | @SuppressWarnings("unchecked")
method findTopMostLimitedObjectDepth (line 397) | private int findTopMostLimitedObjectDepth(String objectLimit, int obje...
method findDirectLimitedObjectDepth (line 410) | private <T> int findDirectLimitedObjectDepth(
method hasLimit (line 443) | private boolean hasLimit(@NotNull String limit) {
method registerInstanceInScope (line 450) | private <T> void registerInstanceInScope(
method findDeepInstanceBucket (line 481) | @Nullable
method key (line 492) | @NotNull
method accept (line 500) | @Override
method acceptAtLevel (line 505) | private void acceptAtLevel(int level, Visitor visitor, int depth) {
method getLimits (line 531) | @Override public @Nullable String[] getLimits() {
method buildInstanceDetails (line 535) | private static <T> void buildInstanceDetails(
method throwLimitNotFound (line 552) | private <T> void throwLimitNotFound(T object, Class<T> objectType, Str...
class InstantiationContext (line 583) | private final static class InstantiationContext {
method onBeginInstantiation (line 587) | void onBeginInstantiation(String key) {
method onEndInstantiation (line 597) | @NotNull Instantiation onEndInstantiation() {
method onDependencyFound (line 603) | void onDependencyFound(int dependencyDepth, @NotNull String dependen...
method createCircularDependencyException (line 611) | private IllegalStateException createCircularDependencyException() {
class Instantiation (line 625) | private final static class Instantiation {
method Instantiation (line 630) | Instantiation(String key) {
method equals (line 634) | @Override
method hashCode (line 642) | @Override
class WeakScopeReference (line 648) | private final static class WeakScopeReference extends WeakReference<Ma...
method WeakScopeReference (line 650) | WeakScopeReference(MagnetScope referent, @Nullable WeakScopeReferenc...
FILE: magnet/src/main/java/magnet/internal/Range.java
class Range (line 20) | final class Range {
method Range (line 26) | public Range(int from, int count, String classifier) {
method getFrom (line 32) | public int getFrom() {
method getCount (line 36) | public int getCount() {
method getClassifier (line 40) | public String getClassifier() {
FILE: magnet/src/test/java/magnet/internal/FactoryFilter_MagnetInstanceManagerTest.java
class FactoryFilter_MagnetInstanceManagerTest (line 21) | @RunWith(MockitoJUnitRunner.Silent.class)
method before (line 31) | @Before
method getOptionalFactoryReturnsFactoryWhenFilterReturnsTrue (line 45) | @Test
method getOptionalFactoryReturnsNullWhenFilterReturnsTrue (line 53) | @Test
method getOptionalFactoryReturnsFactoryWhenOneOfFiltersReturnsTrue (line 61) | @Test
method getOptionalFactoryReturnsNullWhenAllFiltersReturnFalse (line 70) | @Test
method getOptionalFactoryFailsWhenMultipleFactoriesDetected (line 79) | @Test(expected = IllegalStateException.class)
method getManyFactoriesReturnsEmptyListWhenAllFiltersReturnFalse (line 86) | @Test
method getManyFactoriesReturnsSingleFactoryWhenSingleFilterReturnsTrue (line 100) | @Test
method getManyFactoriesReturnsAllFactoriesWhenAllFiltersReturnTrue (line 115) | @Test
method getManyFactoriesReturnsAllFactoriesWhenNoSelectorsDefined (line 131) | @Test
method getManyFactoriesReturnsFactoriesWhenSomeFactoriesHaveSelectors (line 146) | @Test
type Interface1 (line 161) | interface Interface1 {}
type Interface2 (line 162) | interface Interface2 {}
FILE: magnet/src/test/java/magnet/internal/FactoryFilter_MagnetScopeTest.java
class FactoryFilter_MagnetScopeTest (line 14) | @RunWith(MockitoJUnitRunner.Silent.class)
method before (line 23) | @Before
method noSelectorReturnsTrue (line 28) | @Test
method missingSelectorFactoryThrows (line 35) | @Test(expected = IllegalStateException.class)
method existingSelectorReturnsFilterTrue (line 41) | @Test
method existingSelectorReturnsFilterFalse (line 50) | @Test
FILE: magnet/src/test/java/magnet/internal/InstanceBucketTest.java
class InstanceBucketTest (line 13) | @RunWith(MockitoJUnitRunner.StrictStubs.class)
method test_getScope (line 25) | @Test
method test_getInstances_SingleItem (line 34) | @Test
method test_getInstances_ManyItems (line 44) | @Test
method test_getSingleInstance (line 55) | @Test
type Interface1 (line 65) | interface Interface1 {}
class Factory1 (line 66) | abstract static class Factory1 extends InstanceFactory<Interface1> {}
class Factory2 (line 67) | abstract static class Factory2 extends InstanceFactory<Interface1> {}
FILE: magnet/src/test/java/magnet/internal/InstrumentedScope.java
class InstrumentedScope (line 12) | public class InstrumentedScope implements Scope, FactoryFilter {
method InstrumentedScope (line 16) | public InstrumentedScope(MagnetScope scope) {
method InstrumentedScope (line 20) | public InstrumentedScope(Scope scope) {
method getOptional (line 24) | @Override public <T> @Nullable T getOptional(@NotNull Class<T> type) {
method getOptional (line 28) | @Override public <T> @Nullable T getOptional(@NotNull Class<T> type, @...
method getSingle (line 32) | @Override public <T> @NotNull T getSingle(@NotNull Class<T> type) {
method getSingle (line 36) | @Override public <T> @NotNull T getSingle(@NotNull Class<T> type, @Not...
method getMany (line 40) | @Override public <T> @NotNull List<T> getMany(@NotNull Class<T> type) {
method getMany (line 44) | @Override public <T> @NotNull List<T> getMany(@NotNull Class<T> type, ...
method bind (line 48) | @Override public <T> @NotNull Scope bind(@NotNull Class<T> type, @NotN...
method bind (line 53) | @Override public <T> @NotNull Scope bind(@NotNull Class<T> type, @NotN...
method createSubscope (line 58) | @Override public @NotNull Scope createSubscope() {
method limit (line 62) | @Override public @NotNull Scope limit(String... limits) {
method dispose (line 66) | @Override public void dispose() {
method isDisposed (line 70) | @Override public boolean isDisposed() {
method accept (line 74) | @Override public void accept(Visitor visitor, int depth) {
method filter (line 78) | @Override public boolean filter(InstanceFactory factory) { return scop...
method getOptionalInScope (line 81) | @SuppressWarnings("unchecked") <T> T getOptionalInScope(Class<T> type,...
method getManyInScope (line 87) | @SuppressWarnings("unchecked") <T> List<T> getManyInScope(Class<T> typ...
method instrumentObjectIntoScope (line 93) | @SuppressWarnings("unchecked") public <T> InstrumentedScope instrument...
method createInstrumentedSubscope (line 109) | InstrumentedScope createInstrumentedSubscope() {
FILE: magnet/src/test/java/magnet/internal/MagnetInstanceManagerTest.java
class MagnetInstanceManagerTest (line 35) | @RunWith(MockitoJUnitRunner.Silent.class)
method before (line 50) | @Before
method getOptionalFactory_Classified_Existing_SingleTypeInstance (line 83) | @Test
method getOptionalFactory_Classified_Existing_ManyTypeInstances (line 93) | @Test
method getOptionalFactory_NotClassified_Existing (line 103) | @Test
method getOptionalFactory_Classified_NotExisting (line 113) | @Test
method getOptionalFactory_NotClassified_NotExisting (line 123) | @Test
method getManyFactories_NotClassified_ManyTypeInstances (line 133) | @Test
method getManyFactories_Classified_ManyTypeInstances (line 144) | @Test
method getManyFactories_NotClassified_SingleTypeInstances (line 155) | @Test
method getManyFactories_Classified_SingleTypeInstances (line 166) | @Test
type Type1 (line 177) | interface Type1 {}
type Type2 (line 178) | interface Type2 {}
type Type3 (line 179) | interface Type3 {}
class Type1Impl (line 181) | class Type1Impl implements Type1 {}
class Type2Impl (line 182) | class Type2Impl implements Type2 {}
class Type3Impl (line 183) | class Type3Impl implements Type3 {}
FILE: magnet/src/test/java/magnet/internal/MagnetScope_CircularDependencyTest.java
class MagnetScope_CircularDependencyTest (line 30) | @RunWith(JUnit4.class)
method before (line 35) | @Before
method dependency_One_Two_Three_One (line 40) | @Test(expected = IllegalStateException.class)
method dependency_Four_Four (line 45) | @Test(expected = IllegalStateException.class)
method dependency_Five_Constructor_Five (line 50) | @Test(expected = IllegalStateException.class)
class MenuItemOneFactory (line 55) | private static class MenuItemOneFactory extends InstanceFactory<MenuIt...
method create (line 56) | @Override public MenuItem create(Scope scope) {
method getScoping (line 60) | @Override public Scoping getScoping() { return Scoping.TOPMOST; }
class MenuItemTwoFactory (line 63) | private static class MenuItemTwoFactory extends InstanceFactory<MenuIt...
method create (line 64) | @Override public MenuItem create(Scope scope) {
method getScoping (line 68) | @Override public Scoping getScoping() { return Scoping.TOPMOST; }
class MenuItemThreeFactory (line 71) | private static class MenuItemThreeFactory extends InstanceFactory<Menu...
method create (line 72) | @Override public MenuItem create(Scope scope) {
method getScoping (line 76) | @Override public Scoping getScoping() { return Scoping.TOPMOST; }
class MenuItemFourFactory (line 79) | private static class MenuItemFourFactory extends InstanceFactory<MenuI...
method create (line 80) | @Override public MenuItem create(Scope scope) {
method getScoping (line 84) | @Override public Scoping getScoping() { return Scoping.TOPMOST; }
class MenuItemFiveFactory (line 87) | private static class MenuItemFiveFactory extends InstanceFactory<MenuI...
method create (line 88) | @Override public MenuItem create(Scope scope) {
method getScoping (line 91) | @Override public Scoping getScoping() { return Scoping.TOPMOST; }
class StubInstanceManager (line 94) | private static class StubInstanceManager implements InstanceManager {
method StubInstanceManager (line 97) | StubInstanceManager() {
method getInstanceFactory (line 106) | @Override
method getFilteredInstanceFactory (line 112) | @Override public <T> InstanceFactory<T> getFilteredInstanceFactory(
method getManyInstanceFactories (line 118) | @Override public <T> List<InstanceFactory<T>> getManyInstanceFactories(
type MenuItem (line 125) | private interface MenuItem {}
class MenuItemOne (line 127) | private static class MenuItemOne implements MenuItem {}
class MenuItemTwo (line 128) | private static class MenuItemTwo implements MenuItem {}
class MenuItemThree (line 129) | private static class MenuItemThree implements MenuItem {}
class MenuItemFour (line 130) | private static class MenuItemFour implements MenuItem {}
class MenuItemFive (line 132) | private static class MenuItemFive implements MenuItem {
method MenuItemFive (line 133) | public MenuItemFive(Scope scope) {
FILE: magnet/src/test/java/magnet/internal/MagnetScope_DisposeTest.java
class MagnetScope_DisposeTest (line 17) | @RunWith(MockitoJUnitRunner.StrictStubs.class)
method disposeSingleScope_NoClassifier (line 30) | @Test
method disposeSingleScope_WithClassifiers (line 48) | @Test
method disposingParentScope_DisposesChildrenScopes (line 66) | @Test
method disposingChildScope_KeepsParentScopes (line 85) | @Test
method disposedScopeThrowsException (line 101) | @Test(expected = IllegalStateException.class)
method disposeChildScope_InReversOrdered (line 114) | @Test
method disposeParentScope_InReversOrdered (line 134) | @Test
method disposeFirstChildThenParentScopes (line 159) | @Test
method disposeMultipleChildScopes_123 (line 180) | @Test
method disposeMultipleChildScopes_132 (line 197) | @Test
method disposeMultipleChildScopes_213 (line 214) | @Test
method disposeMultipleChildScopes_231 (line 231) | @Test
method disposeMultipleChildScopes_312 (line 248) | @Test
method disposeMultipleChildScopes_321 (line 265) | @Test
method prepareMultipleChildrenScopes (line 282) | private InstrumentedScope[] prepareMultipleChildrenScopes() {
type Interface (line 308) | interface Interface {}
class Factory1 (line 309) | abstract static class Factory1 extends InstanceFactory<Interface> {}
class Factory2 (line 310) | abstract static class Factory2 extends InstanceFactory<Interface> {}
class Factory3 (line 311) | abstract static class Factory3 extends InstanceFactory<Interface> {}
class Factory4 (line 312) | abstract static class Factory4 extends InstanceFactory<Interface> {}
FILE: magnet/src/test/java/magnet/internal/MagnetScope_FindDeepForSiblingTypesTest.java
class MagnetScope_FindDeepForSiblingTypesTest (line 35) | @RunWith(MockitoJUnitRunner.Silent.class)
method before (line 46) | @Before
method getMany_collectsAlsoSiblingInstancesFromScope (line 64) | @Test
type Interface (line 85) | private interface Interface {}
type SiblingInterface (line 86) | private interface SiblingInterface {}
class Implementation (line 88) | private static class Implementation implements Interface {}
class SiblingImplementation (line 89) | private static class SiblingImplementation implements Interface, Sibli...
class Implementation1Factory (line 91) | private abstract static class Implementation1Factory extends InstanceF...
class SiblingImplementation1Factory (line 92) | private abstract static class SiblingImplementation1Factory extends In...
class SiblingImplementation2Factory (line 93) | private abstract static class SiblingImplementation2Factory extends In...
FILE: magnet/src/test/java/magnet/internal/MagnetScope_GetManyTest.java
class MagnetScope_GetManyTest (line 33) | @RunWith(JUnit4.class)
method before (line 39) | @Before
method getSingleScopedMany (line 49) | @Test
method getMultiScopedMany_requestScope1 (line 64) | @Test(expected = IllegalStateException.class)
method getMultiScopedMany_requestScope2 (line 69) | @Test
class MenuItemOne1Factory (line 92) | private static class MenuItemOne1Factory extends InstanceFactory<MenuI...
method create (line 93) | @Override public MenuItem create(Scope scope) {
method getScoping (line 96) | @Override public Scoping getScoping() { return Scoping.TOPMOST; }
class MenuItemOne2Factory (line 99) | private static class MenuItemOne2Factory extends InstanceFactory<MenuI...
method create (line 100) | @Override public MenuItem create(Scope scope) {
method getScoping (line 103) | @Override public Scoping getScoping() { return Scoping.TOPMOST; }
class MenuItemOne3Factory (line 106) | private static class MenuItemOne3Factory extends InstanceFactory<MenuI...
method create (line 107) | @Override public MenuItem create(Scope scope) {
method getScoping (line 110) | @Override public Scoping getScoping() { return Scoping.TOPMOST; }
class MenuItemTwo1Factory (line 113) | private static class MenuItemTwo1Factory extends InstanceFactory<MenuI...
method create (line 114) | @Override public MenuItem create(Scope scope) {
method getScoping (line 117) | @Override public Scoping getScoping() { return Scoping.TOPMOST; }
class MenuItemTwo2Factory (line 120) | private static class MenuItemTwo2Factory extends InstanceFactory<MenuI...
method create (line 121) | @Override public MenuItem create(Scope scope) {
method getScoping (line 126) | @Override public Scoping getScoping() { return Scoping.TOPMOST; }
class StubInstanceManager (line 129) | @SuppressWarnings("unchecked")
method StubInstanceManager (line 133) | StubInstanceManager() {
method getInstanceFactory (line 148) | @Override
method getFilteredInstanceFactory (line 154) | @Override public <T> InstanceFactory<T> getFilteredInstanceFactory(
method getManyInstanceFactories (line 159) | @Override public <T> List<InstanceFactory<T>> getManyInstanceFactories(
type MenuItem (line 166) | private interface MenuItem {}
class MenuItemOne1 (line 168) | private static class MenuItemOne1 implements MenuItem {}
class MenuItemOne2 (line 169) | private static class MenuItemOne2 implements MenuItem {}
class MenuItemOne3 (line 170) | private static class MenuItemOne3 implements MenuItem {}
class MenuItemTwo1 (line 172) | private static class MenuItemTwo1 implements MenuItem {}
class MenuItemTwo2 (line 173) | private static class MenuItemTwo2 implements MenuItem {}
class Dependency2 (line 175) | private static class Dependency2 {}
FILE: magnet/src/test/java/magnet/internal/MagnetScope_ManyInstancesInMultipleScopesTest.java
class MagnetScope_ManyInstancesInMultipleScopesTest (line 32) | @RunWith(JUnit4.class)
method before (line 43) | @Before
method getSingleScopedMany (line 54) | @Test
class InstanceImpl1Factory (line 73) | private static class InstanceImpl1Factory extends InstanceFactory<Inst...
method create (line 74) | @Override public InstanceType create(Scope scope) { return new Insta...
method getScoping (line 75) | @Override public Scoping getScoping() { return Scoping.TOPMOST; }
class InstanceImpl2Factory (line 78) | private static class InstanceImpl2Factory extends InstanceFactory<Inst...
method create (line 79) | @Override public InstanceType create(Scope scope) { return new Insta...
method getScoping (line 80) | @Override public Scoping getScoping() { return Scoping.TOPMOST; }
class InstanceImpl3Factory (line 83) | private static class InstanceImpl3Factory extends InstanceFactory<Inst...
method create (line 84) | @Override public InstanceType create(Scope scope) { return new Insta...
method getScoping (line 85) | @Override public Scoping getScoping() { return Scoping.TOPMOST; }
class StubInstanceManager (line 88) | @SuppressWarnings("unchecked")
method StubInstanceManager (line 92) | StubInstanceManager() {
method getInstanceFactory (line 98) | @Override
method getFilteredInstanceFactory (line 104) | @Override public <T> InstanceFactory<T> getFilteredInstanceFactory(
method getManyInstanceFactories (line 109) | @Override public <T> List<InstanceFactory<T>> getManyInstanceFactories(
type InstanceType (line 119) | private interface InstanceType {}
class InstanceImpl1 (line 121) | private static class InstanceImpl1 implements InstanceType {}
class InstanceImpl2 (line 122) | private static class InstanceImpl2 implements InstanceType {}
class InstanceImpl3 (line 123) | private static class InstanceImpl3 implements InstanceType {}
FILE: magnet/src/test/java/magnet/internal/MagnetScope_RegisterAndGetTest.java
class MagnetScope_RegisterAndGetTest (line 28) | @RunWith(MockitoJUnitRunner.StrictStubs.class)
method before (line 36) | @Before
method noClassifier_GetOptionalNotRegistered (line 41) | @Test
method noClassifier_GetOptionalRegistered (line 50) | @Test
method noClassifier_GetSingleNotRegistered (line 62) | @Test(expected = IllegalStateException.class)
method noClassifier_GetSingleRegistered (line 67) | @Test
method noClassifier_RegisterOverwrite (line 79) | @Test(expected = IllegalStateException.class)
method classifier_GetOptionalNotRegistered (line 85) | @Test
method classifier_GetOptionalRegisteredNoClassifier (line 94) | @Test
method classifier_GetOptionalRegisteredWrongClassifier (line 106) | @Test
method classifier_GetSingleNotRegistered (line 118) | @Test(expected = IllegalStateException.class)
method classifier_GetSingleRegistered (line 123) | @Test
method classifier_RegisterOverwrite (line 135) | @Test(expected = IllegalStateException.class)
FILE: magnet/src/test/java/magnet/internal/MagnetScope_SiblingTypesTest.java
class MagnetScope_SiblingTypesTest (line 31) | @RunWith(MockitoJUnitRunner.Silent.class)
method sameInstanceIsRegisteredScope (line 34) | @Test
method sameInstanceIsRegisteredScopeInReverseOrder (line 45) | @Test
method sameInstanceIsRegisteredInTopMostScope (line 56) | @Test
method sameInstanceIsRegisteredInDirectScope (line 68) | @Test
method sameInstanceIsNotRegisteredInTopMostScope (line 79) | @Test
method createMagnetInstanceManager (line 89) | private static MagnetInstanceManager createMagnetInstanceManager(Scopi...
type Interface1 (line 105) | interface Interface1 {}
type Interface2 (line 106) | interface Interface2 {}
class Implementation (line 108) | static class Implementation implements Interface1, Interface2 {}
class ImplementationInterface1Factory (line 110) | static class ImplementationInterface1Factory extends InstanceFactory<I...
method ImplementationInterface1Factory (line 112) | ImplementationInterface1Factory(Scoping scoping) { this.scoping = sc...
method create (line 113) | @Override public Interface1 create(Scope scope) { return new Impleme...
method getScoping (line 114) | @Override public Scoping getScoping() { return this.scoping; }
method getSiblingTypes (line 115) | @Override public Class[] getSiblingTypes() {
class ImplementationInterface2Factory (line 120) | static class ImplementationInterface2Factory extends InstanceFactory<I...
method ImplementationInterface2Factory (line 122) | ImplementationInterface2Factory(Scoping scoping) { this.scoping = sc...
method create (line 123) | @Override public Interface2 create(Scope scope) { return new Impleme...
method getScoping (line 124) | @Override public Scoping getScoping() { return this.scoping; }
method getSiblingTypes (line 125) | @Override public Class[] getSiblingTypes() {
FILE: magnet/src/test/java/magnet/internal/MagnetScopingDirectTest.java
class MagnetScopingDirectTest (line 32) | @RunWith(JUnit4.class)
method before (line 39) | @Before
method itemOne_Scope1 (line 55) | @Test
method itemOne_Scope2 (line 65) | @Test
method itemOne_Scope3 (line 76) | @Test
method itemTwo_Scope1 (line 88) | @Test(expected = IllegalStateException.class)
method itemTwo_Scope2 (line 94) | @Test
method itemTwo_Scope3 (line 105) | @Test
method itemThree_Scope1 (line 117) | @Test(expected = IllegalStateException.class)
method itemThree_Scope2 (line 123) | @Test(expected = IllegalStateException.class)
method itemThree_Scope3 (line 129) | @Test
class MenuItemOneFactory (line 141) | private static class MenuItemOneFactory extends InstanceFactory<MenuIt...
method create (line 142) | @Override public MenuItem create(Scope scope) {
method getScoping (line 146) | @Override public Scoping getScoping() { return Scoping.DIRECT; }
class MenuItemTwoFactory (line 149) | private static class MenuItemTwoFactory extends InstanceFactory<MenuIt...
method create (line 150) | @Override public MenuItem create(Scope scope) {
method getScoping (line 155) | @Override public Scoping getScoping() { return Scoping.DIRECT; }
class MenuItemThreeFactory (line 158) | private static class MenuItemThreeFactory extends InstanceFactory<Menu...
method create (line 159) | @Override public MenuItem create(Scope scope) {
method getScoping (line 164) | @Override public Scoping getScoping() { return Scoping.DIRECT; }
class StubInstanceManager (line 167) | @SuppressWarnings("unchecked")
method StubInstanceManager (line 171) | StubInstanceManager() {
method getInstanceFactory (line 178) | @Override
method getFilteredInstanceFactory (line 184) | @Override public <T> InstanceFactory<T> getFilteredInstanceFactory(
method getManyInstanceFactories (line 189) | @Override public <T> List<InstanceFactory<T>> getManyInstanceFactories(
type MenuItem (line 196) | private interface MenuItem {}
class MenuItemOne (line 198) | private static class MenuItemOne implements MenuItem {}
class MenuItemTwo (line 199) | private static class MenuItemTwo implements MenuItem {}
class MenuItemThree (line 200) | private static class MenuItemThree implements MenuItem {}
class Dependency1 (line 202) | private static class Dependency1 {}
class Dependency2 (line 203) | private static class Dependency2 {}
class Dependency3 (line 204) | private static class Dependency3 {}
FILE: magnet/src/test/java/magnet/internal/MagnetScopingNoneTest.java
class MagnetScopingNoneTest (line 32) | @RunWith(JUnit4.class)
method before (line 39) | @Before
method itemOne_requestedWithinScope1 (line 55) | @Test
method itemOne_requestedWithinScope2 (line 67) | @Test
method itemOne_requestedWithinScope3 (line 79) | @Test
method itemTwo_requestedWithinScope1 (line 91) | @Test(expected = IllegalStateException.class)
method itemTwo_requestedWithinScope2 (line 97) | @Test
method itemTwo_requestedWithinScope3 (line 113) | @Test
method itemThree_requestedWithinScope1 (line 129) | @Test(expected = IllegalStateException.class)
method itemThree_requestedWithinScope2 (line 135) | @Test(expected = IllegalStateException.class)
method itemThree_requestedWithinScope3 (line 141) | @Test
class MenuItemOneFactory (line 157) | private static class MenuItemOneFactory extends InstanceFactory<MenuIt...
method create (line 158) | @Override public MenuItem create(Scope scope) {
method getScoping (line 162) | @Override public Scoping getScoping() { return Scoping.UNSCOPED; }
class MenuItemTwoFactory (line 165) | private static class MenuItemTwoFactory extends InstanceFactory<MenuIt...
method create (line 166) | @Override public MenuItem create(Scope scope) {
method getScoping (line 172) | @Override public Scoping getScoping() { return Scoping.TOPMOST; }
class MenuItemThreeFactory (line 175) | private static class MenuItemThreeFactory extends InstanceFactory<Menu...
method create (line 176) | @Override public MenuItem create(Scope scope) {
method getScoping (line 183) | @Override public Scoping getScoping() { return Scoping.UNSCOPED; }
class StubInstanceManager (line 186) | private static class StubInstanceManager implements InstanceManager {
method StubInstanceManager (line 189) | StubInstanceManager() {
method getInstanceFactory (line 196) | @Override
method getFilteredInstanceFactory (line 202) | @Override public <T> InstanceFactory<T> getFilteredInstanceFactory(
method getManyInstanceFactories (line 208) | @Override public <T> List<InstanceFactory<T>> getManyInstanceFactories(
type MenuItem (line 215) | private interface MenuItem {}
class MenuItemOne (line 216) | private static class MenuItemOne implements MenuItem {}
class MenuItemTwo (line 217) | private static class MenuItemTwo implements MenuItem {}
class MenuItemThree (line 218) | private static class MenuItemThree implements MenuItem {}
class Dependency1 (line 220) | private static class Dependency1 {}
class Dependency2 (line 221) | private static class Dependency2 {}
class Dependency3 (line 222) | private static class Dependency3 {}
FILE: magnet/src/test/java/magnet/internal/MagnetScopingTopmostDependsOnDirectTest.java
class MagnetScopingTopmostDependsOnDirectTest (line 32) | @RunWith(JUnit4.class)
method before (line 39) | @Before
type MenuItem (line 48) | private interface MenuItem {}
class MenuItemZero (line 50) | private static class MenuItemZero implements MenuItem {}
class MenuItemOne (line 51) | private static class MenuItemOne implements MenuItem {}
class MenuItemTwo (line 52) | private static class MenuItemTwo implements MenuItem {}
class MenuItemThree (line 53) | private static class MenuItemThree implements MenuItem {}
class MenuItemZeroFactory (line 55) | private static class MenuItemZeroFactory extends InstanceFactory<MenuI...
method create (line 56) | @Override public MenuItem create(Scope scope) {
method getScoping (line 59) | @Override public Scoping getScoping() { return Scoping.DIRECT; }
class MenuItemOneFactory (line 62) | private static class MenuItemOneFactory extends InstanceFactory<MenuIt...
method create (line 63) | @Override public MenuItem create(Scope scope) {
method getScoping (line 66) | @Override public Scoping getScoping() { return Scoping.DIRECT; }
class MenuItemTwoFactory (line 69) | private static class MenuItemTwoFactory extends InstanceFactory<MenuIt...
method create (line 70) | @Override public MenuItem create(Scope scope) {
method getScoping (line 74) | @Override public Scoping getScoping() { return Scoping.DIRECT; }
class MenuItemThreeFactory (line 77) | private static class MenuItemThreeFactory extends InstanceFactory<Menu...
method create (line 78) | @Override public MenuItem create(Scope scope) {
method getScoping (line 82) | @Override public Scoping getScoping() { return Scoping.TOPMOST; }
method itemThree_getSingleInScope3 (line 85) | @Test
method itemThree_getSingleInScope2 (line 97) | @Test
method itemThree_getSingleInScope1 (line 109) | @Test
class StubInstanceManager (line 121) | private static class StubInstanceManager implements InstanceManager {
method StubInstanceManager (line 124) | StubInstanceManager() {
method getInstanceFactory (line 132) | @Override
method getFilteredInstanceFactory (line 139) | @Override public <T> InstanceFactory<T> getFilteredInstanceFactory(
method getManyInstanceFactories (line 145) | @Override public <T> List<InstanceFactory<T>> getManyInstanceFactories(
FILE: magnet/src/test/java/magnet/internal/MagnetScopingTopmostDependsOnTopmostTest.java
class MagnetScopingTopmostDependsOnTopmostTest (line 32) | @RunWith(JUnit4.class)
method before (line 39) | @Before
type MenuItem (line 56) | private interface MenuItem {}
class MenuItemZero (line 58) | private static class MenuItemZero implements MenuItem {}
class MenuItemOne (line 59) | private static class MenuItemOne implements MenuItem {}
class MenuItemTwo (line 60) | private static class MenuItemTwo implements MenuItem {}
class MenuItemThree (line 61) | private static class MenuItemThree implements MenuItem {}
class Dependency1 (line 63) | private static class Dependency1 {}
class Dependency2 (line 64) | private static class Dependency2 {}
class Dependency3 (line 65) | private static class Dependency3 {}
class MenuItemZeroFactory (line 67) | private static class MenuItemZeroFactory extends InstanceFactory<MenuI...
method create (line 68) | @Override public MenuItem create(Scope scope) {
method getScoping (line 71) | @Override public Scoping getScoping() { return Scoping.TOPMOST; }
class MenuItemOneFactory (line 74) | private static class MenuItemOneFactory extends InstanceFactory<MenuIt...
method create (line 75) | @Override public MenuItem create(Scope scope) {
method getScoping (line 79) | @Override public Scoping getScoping() { return Scoping.TOPMOST; }
class MenuItemTwoFactory (line 82) | private static class MenuItemTwoFactory extends InstanceFactory<MenuIt...
method create (line 83) | @Override public MenuItem create(Scope scope) {
method getScoping (line 88) | @Override public Scoping getScoping() { return Scoping.TOPMOST; }
class MenuItemThreeFactory (line 91) | private static class MenuItemThreeFactory extends InstanceFactory<Menu...
method create (line 92) | @Override public MenuItem create(Scope scope) {
method getScoping (line 97) | @Override public Scoping getScoping() { return Scoping.TOPMOST; }
method itemZero_getSingleInScope3 (line 100) | @Test
method itemZero_getSingleInScope2 (line 112) | @Test
method itemZero_getSingleInScope1 (line 124) | @Test
method itemOne_getSingleInScope3 (line 136) | @Test
method itemOne_getSingleInScope2 (line 148) | @Test
method itemOne_getSingleInScope1 (line 160) | @Test
method itemTwo_getSingleInScope3 (line 172) | @Test
method itemTwo_getSingleInScope2 (line 188) | @Test
method itemTwo_getSingleInScope1 (line 204) | @Test(expected = IllegalStateException.class)
method itemThree_getSingleInScope3 (line 210) | @Test
method itemThree_getSingleInScope2 (line 230) | @Test(expected = IllegalStateException.class)
method itemThree_getSingleInScope1 (line 236) | @Test(expected = IllegalStateException.class)
class StubInstanceManager (line 242) | private static class StubInstanceManager implements InstanceManager {
method StubInstanceManager (line 245) | StubInstanceManager() {
method getInstanceFactory (line 253) | @Override
method getFilteredInstanceFactory (line 260) | @Override public <T> InstanceFactory<T> getFilteredInstanceFactory(
method getManyInstanceFactories (line 266) | @Override public <T> List<InstanceFactory<T>> getManyInstanceFactories(
FILE: magnet/src/test/java/magnet/internal/MagnetScopingTopmostDependsOnUnscopedTest.java
class MagnetScopingTopmostDependsOnUnscopedTest (line 32) | @RunWith(JUnit4.class)
method before (line 39) | @Before
type MenuItem (line 48) | private interface MenuItem {}
class MenuItemZero (line 50) | private static class MenuItemZero implements MenuItem {}
class MenuItemOne (line 51) | private static class MenuItemOne implements MenuItem {}
class MenuItemTwo (line 52) | private static class MenuItemTwo implements MenuItem {}
class MenuItemThree (line 53) | private static class MenuItemThree implements MenuItem {}
class MenuItemZeroFactory (line 55) | private static class MenuItemZeroFactory extends InstanceFactory<MenuI...
method create (line 56) | @Override public MenuItem create(Scope scope) {
method getScoping (line 59) | @Override public Scoping getScoping() { return Scoping.UNSCOPED; }
class MenuItemOneFactory (line 62) | private static class MenuItemOneFactory extends InstanceFactory<MenuIt...
method create (line 63) | @Override public MenuItem create(Scope scope) {
method getScoping (line 66) | @Override public Scoping getScoping() { return Scoping.UNSCOPED; }
class MenuItemTwoFactory (line 69) | private static class MenuItemTwoFactory extends InstanceFactory<MenuIt...
method create (line 70) | @Override public MenuItem create(Scope scope) {
method getScoping (line 74) | @Override public Scoping getScoping() { return Scoping.UNSCOPED; }
class MenuItemThreeFactory (line 77) | private static class MenuItemThreeFactory extends InstanceFactory<Menu...
method create (line 78) | @Override public MenuItem create(Scope scope) {
method getScoping (line 82) | @Override public Scoping getScoping() { return Scoping.TOPMOST; }
method itemThree_getSingleInScope3 (line 85) | @Test
method itemThree_getSingleInScope2 (line 97) | @Test
method itemThree_getSingleInScope1 (line 109) | @Test
class StubInstanceManager (line 121) | private static class StubInstanceManager implements InstanceManager {
method StubInstanceManager (line 124) | StubInstanceManager() {
method getInstanceFactory (line 132) | @Override
method getFilteredInstanceFactory (line 139) | @Override public <T> InstanceFactory<T> getFilteredInstanceFactory(
method getManyInstanceFactories (line 145) | @Override public <T> List<InstanceFactory<T>> getManyInstanceFactories(
FILE: magnet/src/test/java/magnet/internal/Scope_GetManyAnySiblingTypesTest_Issue95.java
class Scope_GetManyAnySiblingTypesTest_Issue95 (line 16) | @RunWith(JUnit4.class)
method test (line 22) | @Test
class MapInstanceManager (line 47) | @SuppressWarnings("unchecked") private static class MapInstanceManager...
method MapInstanceManager (line 50) | MapInstanceManager() {
method getInstanceFactory (line 69) | @Override @Nullable public <T> InstanceFactory<T> getInstanceFactory(
method getFilteredInstanceFactory (line 74) | @Override @Nullable public <T> InstanceFactory<T> getFilteredInstanc...
method getManyInstanceFactories (line 79) | @Override public <T> @NotNull List<InstanceFactory<T>> getManyInstan...
class Dep1 (line 87) | private static class Dep1 {}
class Dep1Factory (line 88) | private static class Dep1Factory extends InstanceFactory<Dep1> {
method create (line 89) | @Override public Dep1 create(Scope scope) {
type Dep2 (line 96) | private interface Dep2 {}
class Dep2Factory (line 97) | private static class Dep2Factory extends InstanceFactory<Dep2> {
method create (line 98) | @Override public Dep2 create(Scope scope) {
method getSiblingTypes (line 102) | @Override public Class[] getSiblingTypes() {
type Dep2Sibling (line 107) | private interface Dep2Sibling {}
class Dep2SiblingFactory (line 108) | private static class Dep2SiblingFactory extends InstanceFactory<Dep2Si...
method create (line 109) | @Override public Dep2Sibling create(Scope scope) {
method getSiblingTypes (line 113) | @Override public Class[] getSiblingTypes() {
class Dep2Impl (line 118) | private static class Dep2Impl implements Dep2, Dep2Sibling { }
class Dep3 (line 120) | private static class Dep3 {}
class Dep3Factory (line 121) | private static class Dep3Factory extends InstanceFactory<Dep3> {
method create (line 122) | @Override public Dep3 create(Scope scope) {
class Bound1 (line 128) | private static class Bound1 {}
class Bound3 (line 129) | private static class Bound3 {}
FILE: magnet/src/test/java/magnet/internal/Scope_LimitDirectScoping_DependencyInNonReachableChildScopeTest.java
class Scope_LimitDirectScoping_DependencyInNonReachableChildScopeTest (line 18) | @RunWith(JUnit4.class)
method test (line 32) | @Test
class HashMapInstanceManager (line 46) | @SuppressWarnings("unchecked")
method HashMapInstanceManager (line 50) | HashMapInstanceManager() {
method getInstanceFactory (line 55) | @Override public <T> @Nullable InstanceFactory<T> getInstanceFactory(
method getFilteredInstanceFactory (line 60) | @Override public <T> @Nullable InstanceFactory<T> getFilteredInstanc...
method getManyInstanceFactories (line 65) | @Override public <T> @NotNull List<InstanceFactory<T>> getManyInstan...
class Bound2 (line 71) | private static class Bound2 {}
class Dep1 (line 72) | private static class Dep1 {}
class Dep1Factory (line 74) | private static class Dep1Factory extends InstanceFactory<Dep1> {
method create (line 75) | @Override public Dep1 create(Scope scope) {
method getScoping (line 80) | @Override public Scoping getScoping() { return Scoping.DIRECT; }
method getLimit (line 81) | @Override public String getLimit() { return LIMIT; }
class Dep2 (line 84) | private static class Dep2 {}
class Dep2Factory (line 85) | private static class Dep2Factory extends InstanceFactory<Dep2> {
method create (line 86) | @Override public Dep2 create(Scope scope) {
FILE: magnet/src/test/java/magnet/internal/Scope_LimitDirectScoping_InstanceWithDependencyTest.java
class Scope_LimitDirectScoping_InstanceWithDependencyTest (line 19) | @RunWith(JUnit4.class)
method test_GetFromUnderLimitedScope (line 33) | @Test
method test_GetFromLimitedScope (line 51) | @Test
class HashMapInstanceManager (line 65) | @SuppressWarnings("unchecked")
method HashMapInstanceManager (line 69) | HashMapInstanceManager() {
method getInstanceFactory (line 74) | @Override public <T> @Nullable InstanceFactory<T> getInstanceFactory(
method getFilteredInstanceFactory (line 79) | @Override public <T> @Nullable InstanceFactory<T> getFilteredInstanc...
method getManyInstanceFactories (line 84) | @Override public <T> @NotNull List<InstanceFactory<T>> getManyInstan...
class Bound2 (line 90) | private static class Bound2 {}
class Dep1 (line 92) | private static class Dep1 {}
class Dep1Factory (line 93) | private static class Dep1Factory extends InstanceFactory<Dep1> {
method create (line 94) | @Override public Dep1 create(Scope scope) { return new Dep1(); }
method getScoping (line 95) | @Override public Scoping getScoping() { return Scoping.DIRECT; }
method getLimit (line 96) | @Override public String getLimit() { return LIMIT; }
class Dep2 (line 99) | private static class Dep2 {}
class Dep2Factory (line 100) | private static class Dep2Factory extends InstanceFactory<Dep2> {
method create (line 101) | @Override public Dep2 create(Scope scope) {
FILE: magnet/src/test/java/magnet/internal/Scope_LimitDirectScoping_SingleInstanceTest.java
class Scope_LimitDirectScoping_SingleInstanceTest (line 19) | @RunWith(JUnit4.class)
method test_GetFromUnderLimitedScope (line 33) | @Test
method test_GetFromLimitedScope (line 51) | @Test
method test_GetFromAboveLimitedScope (line 69) | @Test
class HashMapInstanceManager (line 83) | @SuppressWarnings("unchecked")
method HashMapInstanceManager (line 87) | HashMapInstanceManager() {
method getInstanceFactory (line 91) | @Override public <T> @Nullable InstanceFactory<T> getInstanceFactory(
method getFilteredInstanceFactory (line 96) | @Override public <T> @Nullable InstanceFactory<T> getFilteredInstanc...
method getManyInstanceFactories (line 101) | @Override public <T> @NotNull List<InstanceFactory<T>> getManyInstan...
class Dep1 (line 107) | private static class Dep1 {}
class Dep1Factory (line 108) | private static class Dep1Factory extends InstanceFactory<Dep1> {
method create (line 109) | @Override public Dep1 create(Scope scope) { return new Dep1(); }
method getScoping (line 110) | @Override public Scoping getScoping() { return Scoping.DIRECT; }
method getLimit (line 111) | @Override public String getLimit() { return LIMIT; }
FILE: magnet/src/test/java/magnet/internal/Scope_LimitTest.java
class Scope_LimitTest (line 15) | @RunWith(JUnit4.class)
method test_limitedInstance_settlesInLimitedSameScope (line 24) | @Test
method test_limitedInstance_settlesInLimitedUpperScope (line 42) | @Test
method test_limitedInstance_settlesInLimitedTopScope (line 60) | @Test
method test_limitedInstance_fails_ifNoLimitFound (line 78) | @Test(expected = IllegalStateException.class)
method test_limitedInstance_fails_ifQueriedAtParentUnlimitedScope (line 89) | @Test(expected = IllegalStateException.class)
method test_limitedInstance_fails_ifNoMatchingLimitFound (line 99) | @Test(expected = IllegalStateException.class)
method test_unlimitedInstance_ignoresLimits_settlesInUnlimitedTopScope (line 110) | @Test
class HashMapInstanceManager (line 128) | @SuppressWarnings("unchecked") private static class HashMapInstanceMan...
method HashMapInstanceManager (line 131) | HashMapInstanceManager() {
method getInstanceFactory (line 136) | @Override @Nullable public <T> InstanceFactory<T> getInstanceFactory(
method getFilteredInstanceFactory (line 141) | @Override @Nullable public <T> InstanceFactory<T> getFilteredInstanc...
method getManyInstanceFactories (line 146) | @Override public <T> @NotNull List<InstanceFactory<T>> getManyInstan...
class Limited (line 152) | private static class Limited {}
class LimitedFactory (line 153) | private static class LimitedFactory extends InstanceFactory<Limited> {
method create (line 154) | @Override public Limited create(Scope scope) { return new Limited(); }
method getLimit (line 155) | @Override public String getLimit() { return LIMIT; }
class Unlimited (line 158) | private static class Unlimited {}
class UnlimitedFactory (line 159) | private static class UnlimitedFactory extends InstanceFactory<Unlimite...
method create (line 160) | @Override public Unlimited create(Scope scope) { return new Unlimite...
FILE: magnet/src/test/java/magnet/internal/Scope_LimitWithDependencyTest.java
class Scope_LimitWithDependencyTest (line 15) | @RunWith(JUnit4.class)
method test_dependingInstance_respectsDependencyLimit (line 26) | @Test
method test_dependingInstance_respectsOwnLimit (line 46) | @Test
method test_dependingInstance_isCollocatedWithDependency (line 66) | @Test
class MapInstanceManager (line 84) | @SuppressWarnings("unchecked") private static class MapInstanceManager...
method MapInstanceManager (line 87) | MapInstanceManager() {
method getInstanceFactory (line 92) | @Override @Nullable public <T> InstanceFactory<T> getInstanceFactory(
method getFilteredInstanceFactory (line 97) | @Override @Nullable public <T> InstanceFactory<T> getFilteredInstanc...
method getManyInstanceFactories (line 102) | @Override public <T> @NotNull List<InstanceFactory<T>> getManyInstan...
class LimitedOne (line 108) | private static class LimitedOne {}
class LimitedOneFactory (line 109) | private static class LimitedOneFactory extends InstanceFactory<Limited...
method create (line 110) | @Override public LimitedOne create(Scope scope) {
method getLimit (line 114) | @Override public String getLimit() { return LIMIT_ONE; }
class LimitedTwo (line 117) | private static class LimitedTwo {}
class LimitedTwoFactory (line 118) | private static class LimitedTwoFactory extends InstanceFactory<Limited...
method create (line 119) | @Override public LimitedTwo create(Scope scope) { return new Limited...
method getLimit (line 120) | @Override public String getLimit() { return LIMIT_TWO; }
FILE: magnet/src/test/java/magnet/internal/VisitInstancesTest.java
class VisitInstancesTest (line 21) | public class VisitInstancesTest {
method before (line 40) | @Before
method visitAllScopes (line 54) | @Test
method visitRootScope (line 74) | @Test
method visitScope_onEnterScope_skipAllInstances (line 89) | @Test
method visitScope_onInstance_skipAfterSecondInstance (line 106) | @Test
class Bound (line 127) | private static class Bound {}
class InjectedTopMost (line 129) | private static class InjectedTopMost {}
class InjectedDirect (line 131) | private static class InjectedDirect {}
class InjectedTopMostFactory (line 133) | private class InjectedTopMostFactory extends InstanceFactory<InjectedT...
method create (line 134) | @Override public InjectedTopMost create(Scope scope) {
class InjectedDirectFactory (line 139) | private class InjectedDirectFactory extends InstanceFactory<InjectedDi...
method create (line 140) | @Override public InjectedDirect create(Scope scope) {
method getScoping (line 144) | @Override public Scoping getScoping() {
FILE: magnet/src/test/java/magnet/internal/VisitScopesTest.java
class VisitScopesTest (line 13) | public class VisitScopesTest {
method before (line 23) | @Before
method visitRootScope_DepthUnlimited (line 32) | @Test
method visitRootScope_Depth0 (line 49) | @Test
method visitRootScope_Depth1 (line 58) | @Test
method visitChildScope_Depth0 (line 71) | @Test
method visitChildScope_Depth1 (line 80) | @Test
FILE: magnet/src/test/java/magnet/internal/events/ObservableScopeVisitor.java
class ObservableScopeVisitor (line 11) | public class ObservableScopeVisitor implements Visitor {
method onEnterScope (line 16) | @Override
method onInstance (line 23) | @Override
method onExitScope (line 29) | @Override
method flushInstances (line 35) | private void flushInstances() {
FILE: magnet/src/test/java/magnet/internal/events/OnEnterScope.java
class OnEnterScope (line 8) | public class OnEnterScope {
method OnEnterScope (line 12) | public OnEnterScope(@NotNull Object scope, @Nullable Object parent) {
method equals (line 17) | @Override
method hashCode (line 26) | @Override
method toString (line 31) | @Override
FILE: magnet/src/test/java/magnet/internal/events/OnExitScope.java
class OnExitScope (line 7) | public class OnExitScope {
method OnExitScope (line 10) | public OnExitScope(@NotNull Object scope) {
method equals (line 14) | @Override
method hashCode (line 22) | @Override
method toString (line 27) | @Override
FILE: magnet/src/test/java/magnet/internal/events/OnInstance.java
class OnInstance (line 10) | public class OnInstance implements Comparable<OnInstance> {
method OnInstance (line 17) | OnInstance(Instance object) {
method OnInstance (line 25) | public OnInstance(
method equals (line 39) | @Override public boolean equals(Object o) {
method hashCode (line 50) | @Override public int hashCode() {
method toString (line 54) | @Override public String toString() {
method compareTo (line 61) | @Override public int compareTo(@NotNull OnInstance o) {
FILE: magnet/src/test/java/magnet/internal/observer/ScopeObserver.java
class ScopeObserver (line 16) | public class ScopeObserver implements Visitor {
method onEnterScope (line 21) | @Override
method onInstance (line 28) | @Override
method onExitScope (line 36) | @Override
method flushScope (line 41) | private void flushScope() {
method assetThat (line 53) | public ScopeValidator assetThat(magnet.Scope scopeA) {
class DefaultScopeValidator (line 63) | private static class DefaultScopeValidator implements ScopeValidator {
method DefaultScopeValidator (line 67) | DefaultScopeValidator(Scope scope) {
method addInstance (line 71) | void addInstance(Instance instance) {
method hasNoInstances (line 75) | @Override public void hasNoInstances() {
method hasInstanceTypes (line 79) | @Override public void hasInstanceTypes(Class<?>... instanceTypes) {
FILE: magnet/src/test/java/magnet/internal/observer/ScopeValidator.java
type ScopeValidator (line 3) | public interface ScopeValidator {
method hasNoInstances (line 4) | void hasNoInstances();
method hasInstanceTypes (line 5) | void hasInstanceTypes(Class<?>... instanceTypes);
Condensed preview — 378 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (606K chars).
[
{
"path": ".editorconfig",
"chars": 43,
"preview": "[*.{kt,kts}]\ndisabled_rules=import-ordering"
},
{
"path": ".github/stale.yml",
"chars": 700,
"preview": "# Number of days of inactivity before an issue becomes stale\ndaysUntilStale: 30\n# Number of days of inactivity before a "
},
{
"path": ".github/workflows/android.yml",
"chars": 474,
"preview": "name: Build Magnet\n\non:\n push:\n branches: [ master ]\n pull_request:\n branches: [ master ]\n\njobs:\n build:\n\n r"
},
{
"path": ".gitignore",
"chars": 120,
"preview": "out/\nbuild/\ncaptures/\nclasses/\nreports/\n\nlibrary/.idea/\n\n.idea/\n.gradle/\n.navigation/\n\n*.iml\n.DS_Store\n\nlocal.properties"
},
{
"path": ".project",
"chars": 726,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>magnet</name>\n\t<comment>Project magnet created by Bui"
},
{
"path": ".settings/org.eclipse.buildship.core.prefs",
"chars": 370,
"preview": "arguments=\nauto.sync=false\nbuild.scans.enabled=false\nconnection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)\nconnect"
},
{
"path": "CHANGELOG.md",
"chars": 1059,
"preview": "# Changelog\n\n## 3.8 (release) - 2023.03.27\n\n- Same as 3.8 (snapshot) \n\n## 3.8 (snapshot) - 2023.01.20\n\n- Bump versions:\n"
},
{
"path": "LICENSE",
"chars": 11363,
"preview": " Apache License\n Version 2.0, January 2004\n "
},
{
"path": "README.md",
"chars": 8247,
"preview": "[](http://kotlinlang.org/)\n[\n maven { url 'https://m"
},
{
"path": "documentation/diagrams/design.graphml",
"chars": 8798,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\" xmlns:java"
},
{
"path": "gradle/wrapper/gradle-wrapper.properties",
"chars": 232,
"preview": "#Wed Dec 18 22:04:35 CET 2019\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-7.5.1-bin.zip\ndistributi"
},
{
"path": "gradle.properties",
"chars": 676,
"preview": "org.gradle.jvmargs=-Xmx1536m\nandroid.useAndroidX=true\n\nGROUP=de.halfbit\nVERSION_NAME=3.8\nVERSION_CODE=0\n\nPOM_DESCRIPTION"
},
{
"path": "gradlew",
"chars": 5296,
"preview": "#!/usr/bin/env sh\n\n##############################################################################\n##\n## Gradle start up"
},
{
"path": "gradlew.bat",
"chars": 2260,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\r\n@rem ##########################################################################\r\n@rem\r\n@r"
},
{
"path": "magnet/build.gradle",
"chars": 334,
"preview": "plugins {\n id 'java-library'\n id 'com.vanniktech.maven.publish'\n}\n\nsourceCompatibility = javaVersion\ntargetCompati"
},
{
"path": "magnet/gradle.properties",
"chars": 73,
"preview": "POM_NAME=Magnet Runtime Library\nPOM_ARTIFACT_ID=magnet\nPOM_PACKAGING=jar\n"
},
{
"path": "magnet/src/main/java/magnet/Classifier.java",
"chars": 1776,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/main/java/magnet/Factory.java",
"chars": 1277,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/main/java/magnet/Instance.java",
"chars": 5028,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/main/java/magnet/Magnet.java",
"chars": 884,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/main/java/magnet/Registry.java",
"chars": 1142,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/main/java/magnet/Scope.java",
"chars": 5212,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/main/java/magnet/Scoping.java",
"chars": 6040,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/main/java/magnet/SelectorFilter.java",
"chars": 924,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/main/java/magnet/Visitor.java",
"chars": 1729,
"preview": "package magnet;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\n/**\n * Implementa"
},
{
"path": "magnet/src/main/java/magnet/internal/FactoryFilter.java",
"chars": 765,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/main/java/magnet/internal/Generated.java",
"chars": 328,
"preview": "package magnet.internal;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.la"
},
{
"path": "magnet/src/main/java/magnet/internal/ImmutableArrayList.java",
"chars": 1281,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/main/java/magnet/internal/Index.java",
"chars": 430,
"preview": "package magnet.internal;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.la"
},
{
"path": "magnet/src/main/java/magnet/internal/InstanceBucket.java",
"chars": 10030,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/main/java/magnet/internal/InstanceFactory.java",
"chars": 1253,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/main/java/magnet/internal/InstanceManager.java",
"chars": 1259,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/main/java/magnet/internal/InternalFactory.java",
"chars": 1183,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/main/java/magnet/internal/MagnetInstanceManager.java",
"chars": 6569,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/main/java/magnet/internal/MagnetScope.java",
"chars": 23555,
"preview": "/*\n * Copyright (C) 2018-2019 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (th"
},
{
"path": "magnet/src/main/java/magnet/internal/Range.java",
"chars": 1149,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/test/java/magnet/internal/FactoryFilter_MagnetInstanceManagerTest.java",
"chars": 6970,
"preview": "package magnet.internal;\n\nimport static com.google.common.truth.Truth.assertThat;\nimport static org.mockito.ArgumentMatc"
},
{
"path": "magnet/src/test/java/magnet/internal/FactoryFilter_MagnetScopeTest.java",
"chars": 1912,
"preview": "package magnet.internal;\n\nimport magnet.SelectorFilter;\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit"
},
{
"path": "magnet/src/test/java/magnet/internal/InstanceBucketTest.java",
"chars": 2304,
"preview": "package magnet.internal;\n\nimport magnet.Classifier;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.m"
},
{
"path": "magnet/src/test/java/magnet/internal/InstrumentedScope.java",
"chars": 3928,
"preview": "package magnet.internal;\n\nimport magnet.Scope;\nimport magnet.Visitor;\nimport org.jetbrains.annotations.NotNull;\nimport o"
},
{
"path": "magnet/src/test/java/magnet/internal/MagnetInstanceManagerTest.java",
"chars": 6173,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/test/java/magnet/internal/MagnetScope_CircularDependencyTest.java",
"chars": 4851,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/test/java/magnet/internal/MagnetScope_DisposeTest.java",
"chars": 12218,
"preview": "package magnet.internal;\n\nimport magnet.Classifier;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.m"
},
{
"path": "magnet/src/test/java/magnet/internal/MagnetScope_FindDeepForSiblingTypesTest.java",
"chars": 3757,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/test/java/magnet/internal/MagnetScope_GetManyTest.java",
"chars": 6194,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/test/java/magnet/internal/MagnetScope_ManyInstancesInMultipleScopesTest.java",
"chars": 4693,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/test/java/magnet/internal/MagnetScope_RegisterAndGetTest.java",
"chars": 3701,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/test/java/magnet/internal/MagnetScope_SiblingTypesTest.java",
"chars": 5230,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/test/java/magnet/internal/MagnetScopingDirectTest.java",
"chars": 7061,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/test/java/magnet/internal/MagnetScopingNoneTest.java",
"chars": 8318,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/test/java/magnet/internal/MagnetScopingTopmostDependsOnDirectTest.java",
"chars": 5488,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/test/java/magnet/internal/MagnetScopingTopmostDependsOnTopmostTest.java",
"chars": 10115,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/test/java/magnet/internal/MagnetScopingTopmostDependsOnUnscopedTest.java",
"chars": 5496,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet/src/test/java/magnet/internal/Scope_GetManyAnySiblingTypesTest_Issue95.java",
"chars": 4675,
"preview": "package magnet.internal;\n\nimport magnet.Scope;\nimport magnet.internal.observer.ScopeObserver;\nimport org.jetbrains.annot"
},
{
"path": "magnet/src/test/java/magnet/internal/Scope_LimitDirectScoping_DependencyInNonReachableChildScopeTest.java",
"chars": 2946,
"preview": "package magnet.internal;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport or"
},
{
"path": "magnet/src/test/java/magnet/internal/Scope_LimitDirectScoping_InstanceWithDependencyTest.java",
"chars": 3645,
"preview": "package magnet.internal;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport or"
},
{
"path": "magnet/src/test/java/magnet/internal/Scope_LimitDirectScoping_SingleInstanceTest.java",
"chars": 3744,
"preview": "package magnet.internal;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport or"
},
{
"path": "magnet/src/test/java/magnet/internal/Scope_LimitTest.java",
"chars": 5746,
"preview": "package magnet.internal;\n\nimport magnet.Scope;\nimport magnet.internal.observer.ScopeObserver;\nimport org.jetbrains.annot"
},
{
"path": "magnet/src/test/java/magnet/internal/Scope_LimitWithDependencyTest.java",
"chars": 4529,
"preview": "package magnet.internal;\n\nimport magnet.Scope;\nimport magnet.internal.observer.ScopeObserver;\nimport org.jetbrains.annot"
},
{
"path": "magnet/src/test/java/magnet/internal/VisitInstancesTest.java",
"chars": 6004,
"preview": "package magnet.internal;\n\nimport magnet.Classifier;\nimport magnet.Magnet;\nimport magnet.Scope;\nimport magnet.Scoping;\nim"
},
{
"path": "magnet/src/test/java/magnet/internal/VisitScopesTest.java",
"chars": 2759,
"preview": "package magnet.internal;\n\nimport magnet.Magnet;\nimport magnet.Scope;\nimport magnet.internal.events.ObservableScopeVisito"
},
{
"path": "magnet/src/test/java/magnet/internal/events/ObservableScopeVisitor.java",
"chars": 1118,
"preview": "package magnet.internal.events;\n\nimport magnet.Visitor;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.a"
},
{
"path": "magnet/src/test/java/magnet/internal/events/OnEnterScope.java",
"chars": 885,
"preview": "package magnet.internal.events;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\ni"
},
{
"path": "magnet/src/test/java/magnet/internal/events/OnExitScope.java",
"chars": 680,
"preview": "package magnet.internal.events;\n\nimport org.jetbrains.annotations.NotNull;\n\nimport java.util.Objects;\n\npublic class OnEx"
},
{
"path": "magnet/src/test/java/magnet/internal/events/OnInstance.java",
"chars": 2020,
"preview": "package magnet.internal.events;\n\nimport magnet.Scoping;\nimport magnet.Visitor.Instance;\nimport magnet.Visitor.Provision;"
},
{
"path": "magnet/src/test/java/magnet/internal/observer/ScopeObserver.java",
"chars": 3391,
"preview": "package magnet.internal.observer;\n\nimport magnet.Visitor;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains"
},
{
"path": "magnet/src/test/java/magnet/internal/observer/ScopeValidator.java",
"chars": 152,
"preview": "package magnet.internal.observer;\n\npublic interface ScopeValidator {\n void hasNoInstances();\n void hasInstanceType"
},
{
"path": "magnet/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker",
"chars": 17,
"preview": "mock-maker-inline"
},
{
"path": "magnet-kotlin/build.gradle",
"chars": 450,
"preview": "plugins {\n id 'kotlin'\n id 'com.vanniktech.maven.publish'\n}\n\ncompileKotlin {\n kotlinOptions {\n jvmTarget"
},
{
"path": "magnet-kotlin/gradle.properties",
"chars": 90,
"preview": "POM_NAME=Magnet Runtime Kotlin Extensions\nPOM_ARTIFACT_ID=magnet-kotlin\nPOM_PACKAGING=jar\n"
},
{
"path": "magnet-kotlin/src/main/java/magnet/MagnetExt.kt",
"chars": 903,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet-kotlin/src/main/java/magnet/ScopeExt.kt",
"chars": 1604,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet-kotlin/src/main/java/magnet/internal/ManyLazy.kt",
"chars": 1216,
"preview": "/*\n * Copyright (C) 2019 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet-kotlin/src/main/java/magnet/internal/OptionalLazy.kt",
"chars": 1201,
"preview": "/*\n * Copyright (C) 2019 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet-kotlin/src/main/java/magnet/internal/SingleLazy.kt",
"chars": 1202,
"preview": "/*\n * Copyright (C) 2019 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet-kotlin/src/test/java/magnet/kotlin/ScopeExtTest.kt",
"chars": 1835,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet-kotlin/src/test/java/magnet/kotlin/internal/ManyLazyTest.kt",
"chars": 1452,
"preview": "package magnet.kotlin.internal\n\nimport com.google.common.truth.Truth.assertThat\nimport org.mockito.kotlin.mock\nimport or"
},
{
"path": "magnet-kotlin/src/test/java/magnet/kotlin/internal/OptionalLazyTest.kt",
"chars": 1479,
"preview": "package magnet.kotlin.internal\n\nimport com.google.common.truth.Truth.assertThat\nimport org.mockito.kotlin.mock\nimport or"
},
{
"path": "magnet-kotlin/src/test/java/magnet/kotlin/internal/SingleLazyTest.kt",
"chars": 1458,
"preview": "package magnet.kotlin.internal\n\nimport com.google.common.truth.Truth.assertThat\nimport org.mockito.kotlin.mock\nimport or"
},
{
"path": "magnet-processor/build.gradle",
"chars": 1535,
"preview": "plugins {\n id 'kotlin'\n id 'com.vanniktech.maven.publish'\n}\n\ncompileKotlin {\n kotlinOptions {\n jvmTarget"
},
{
"path": "magnet-processor/gradle.properties",
"chars": 87,
"preview": "POM_NAME=Magnet Annotation Processor\nPOM_ARTIFACT_ID=magnet-processor\nPOM_PACKAGING=jar"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/MagnetProcessor.kt",
"chars": 3804,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/common/AptUtils.kt",
"chars": 2956,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/common/KotlinMethodMetadata.kt",
"chars": 9106,
"preview": "/*\n * Copyright (C) 2019-2021 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (th"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/FactoryTypeModel.kt",
"chars": 4483,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/InstanceProcessor.kt",
"chars": 2441,
"preview": "package magnet.processor.instances\n\nimport magnet.Instance\nimport magnet.processor.MagnetProcessorEnv\nimport magnet.proc"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/classifier/ClassifierAttributeParser.kt",
"chars": 476,
"preview": "package magnet.processor.instances.aspects.classifier\n\nimport magnet.processor.instances.parser.AttributeParser\nimport m"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/disabled/DisabledAttributeParser.kt",
"chars": 480,
"preview": "package magnet.processor.instances.aspects.disabled\n\nimport magnet.processor.instances.parser.AttributeParser\nimport mag"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/disposer/DisposeMethodGenerator.kt",
"chars": 1031,
"preview": "package magnet.processor.instances.aspects.disposer\n\nimport com.squareup.javapoet.MethodSpec\nimport com.squareup.javapoe"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/disposer/DisposerAttributeParser.kt",
"chars": 1842,
"preview": "package magnet.processor.instances.aspects.disposer\n\nimport magnet.processor.common.throwValidationError\nimport magnet.p"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/disposer/DisposerValidator.kt",
"chars": 674,
"preview": "package magnet.processor.instances.aspects.disposer\n\nimport magnet.Scoping\nimport magnet.processor.MagnetProcessorEnv\nim"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/disposer/IsDisposableMethodGenerator.kt",
"chars": 858,
"preview": "package magnet.processor.instances.aspects.disposer\n\nimport com.squareup.javapoet.MethodSpec\nimport com.squareup.javapoe"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/factory/CreateMethodGenerator.kt",
"chars": 3629,
"preview": "package magnet.processor.instances.aspects.factory\n\nimport com.squareup.javapoet.*\nimport magnet.internal.ManyLazy\nimpor"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/factory/CustomFactoryCreateMethodGenerator.kt",
"chars": 4338,
"preview": "package magnet.processor.instances.aspects.factory\n\nimport com.squareup.javapoet.ClassName\nimport com.squareup.javapoet."
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/factory/FactoryAttributeParser.kt",
"chars": 665,
"preview": "package magnet.processor.instances.aspects.factory\n\nimport com.squareup.javapoet.TypeName\nimport magnet.processor.instan"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/factory/StandardFactoryCreateMethodGenerator.kt",
"chars": 3045,
"preview": "package magnet.processor.instances.aspects.factory\n\nimport com.squareup.javapoet.AnnotationSpec\nimport com.squareup.java"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/index/FactoryIndexCodeGenerator.kt",
"chars": 2861,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/limitedto/GetLimitMethodGenerator.kt",
"chars": 892,
"preview": "package magnet.processor.instances.aspects.limitedto\n\nimport com.squareup.javapoet.MethodSpec\nimport com.squareup.javapo"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/limitedto/LimitedToAttributeParser.kt",
"chars": 472,
"preview": "package magnet.processor.instances.aspects.limitedto\n\nimport magnet.processor.instances.parser.AttributeParser\nimport ma"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/limitedto/LimitedToValidator.kt",
"chars": 969,
"preview": "package magnet.processor.instances.aspects.limitedto\n\nimport magnet.Scoping\nimport magnet.processor.MagnetProcessorEnv\ni"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/scoping/GetScopingMethodGenerator.kt",
"chars": 1125,
"preview": "package magnet.processor.instances.aspects.scoping\n\nimport com.squareup.javapoet.MethodSpec\nimport com.squareup.javapoet"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/scoping/ScopingAttributeParser.kt",
"chars": 464,
"preview": "package magnet.processor.instances.aspects.scoping\n\nimport magnet.processor.instances.parser.AttributeParser\nimport magn"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/selector/GetSelectorMethodGenerator.kt",
"chars": 2039,
"preview": "package magnet.processor.instances.aspects.selector\n\nimport com.squareup.javapoet.ArrayTypeName\nimport com.squareup.java"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/selector/SelectorAttributeParser.kt",
"chars": 1776,
"preview": "package magnet.processor.instances.aspects.selector\n\nimport magnet.processor.common.ValidationException\nimport magnet.pr"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/siblings/GetSiblingTypesMethodGenerator.kt",
"chars": 2681,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/type/TypeAndTypesValidator.kt",
"chars": 3116,
"preview": "/*\n * Copyright (C) 2018-2021 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (th"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/type/TypeAttributeParser.kt",
"chars": 666,
"preview": "package magnet.processor.instances.aspects.type\n\nimport magnet.processor.common.verifyInheritance\nimport magnet.processo"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/aspects/type/TypesAttributeParser.kt",
"chars": 1788,
"preview": "package magnet.processor.instances.aspects.type\n\nimport magnet.processor.common.verifyInheritance\nimport magnet.processo"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/generator/CodeGenerator.kt",
"chars": 181,
"preview": "package magnet.processor.instances.generator\n\nimport magnet.processor.instances.FactoryType\n\ninterface CodeGenerator {\n\n"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/generator/CodeWriter.kt",
"chars": 458,
"preview": "package magnet.processor.instances.generator\n\nimport com.squareup.javapoet.JavaFile\nimport com.squareup.javapoet.TypeSpe"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/generator/FactoryTypeCodeGenerator.kt",
"chars": 6730,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/parser/AspectValidator.kt",
"chars": 651,
"preview": "package magnet.processor.instances.parser\n\nimport magnet.processor.MagnetProcessorEnv\nimport magnet.processor.instances."
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/parser/AttributeParser.kt",
"chars": 1853,
"preview": "package magnet.processor.instances.parser\n\nimport magnet.processor.MagnetProcessorEnv\nimport magnet.processor.instances."
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/parser/InstanceParser.kt",
"chars": 13356,
"preview": "/*\n * Copyright (C) 2018-2019 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (th"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/parser/InstanceParserForClass.kt",
"chars": 8141,
"preview": "/*\n * Copyright (C) 2018-2021 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (th"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/parser/InstanceParserForMethod.kt",
"chars": 7408,
"preview": "/*\n * Copyright (C) 2018-2021 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (th"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/instances/parser/ParserInstance.kt",
"chars": 722,
"preview": "package magnet.processor.instances.parser\n\nimport com.squareup.javapoet.ClassName\nimport com.squareup.javapoet.TypeName\n"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/registry/Model.kt",
"chars": 332,
"preview": "package magnet.processor.registry\n\nimport com.squareup.javapoet.ClassName\n\nclass Model private constructor() {\n\n clas"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/registry/RegistryGenerator.kt",
"chars": 2369,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/registry/RegistryParser.kt",
"chars": 3005,
"preview": "package magnet.processor.registry\n\nimport com.squareup.javapoet.ClassName\nimport magnet.internal.Index\nimport magnet.int"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/registry/RegistryProcessor.kt",
"chars": 1980,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/registry/instances/IndexGeneratorVisitor.kt",
"chars": 3053,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/registry/instances/Indexer.kt",
"chars": 1189,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/registry/instances/InstanceIndexGenerator.kt",
"chars": 2285,
"preview": "package magnet.processor.registry.instances\n\nimport com.squareup.javapoet.ClassName\nimport com.squareup.javapoet.CodeBlo"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/registry/instances/Model.kt",
"chars": 2078,
"preview": "package magnet.processor.registry.instances\n\nimport com.squareup.javapoet.ClassName\n\nclass Model private constructor() {"
},
{
"path": "magnet-processor/src/main/java/magnet/processor/registry/instances/SectionsCreatorVisitor.kt",
"chars": 2058,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet-processor/src/main/resources/META-INF/gradle/incremental.annotation.processors",
"chars": 44,
"preview": "magnet.processor.MagnetProcessor,aggregating"
},
{
"path": "magnet-processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor",
"chars": 32,
"preview": "magnet.processor.MagnetProcessor"
},
{
"path": "magnet-processor/src/test/java/magnet/processor/GenerateRegistryForInstanceFactoriesTest.kt",
"chars": 4711,
"preview": "package magnet.processor\n\nimport com.google.testing.compile.CompilationSubject\nimport com.google.testing.compile.Compile"
},
{
"path": "magnet-processor/src/test/java/magnet/processor/IndexerTest.kt",
"chars": 2377,
"preview": "package magnet.processor\n\nimport com.google.common.truth.Truth.assertThat\nimport com.squareup.javapoet.ClassName\nimport "
},
{
"path": "magnet-processor/src/test/java/magnet/processor/InstanceCustomFactoryProcessorTest.kt",
"chars": 2295,
"preview": "package magnet.processor\n\nimport com.google.testing.compile.CompilationSubject\nimport com.google.testing.compile.Compile"
},
{
"path": "magnet-processor/src/test/java/magnet/processor/InstanceDisposerTest.kt",
"chars": 2724,
"preview": "package magnet.processor\n\nimport com.google.testing.compile.CompilationSubject\nimport com.google.testing.compile.Compile"
},
{
"path": "magnet-processor/src/test/java/magnet/processor/InstanceIndexProcessorTest.kt",
"chars": 1666,
"preview": "package magnet.processor\n\nimport com.google.testing.compile.CompilationSubject\nimport com.google.testing.compile.Compila"
},
{
"path": "magnet-processor/src/test/java/magnet/processor/MagnetProcessorFactoryNamesTest.kt",
"chars": 1503,
"preview": "package magnet.processor\n\nimport com.google.testing.compile.CompilationSubject\nimport com.google.testing.compile.Compile"
},
{
"path": "magnet-processor/src/test/java/magnet/processor/MagnetProcessorTest.kt",
"chars": 35459,
"preview": "/*\n * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de\n *\n * Licensed under the Apache License, Version 2.0 (the \"Li"
},
{
"path": "magnet-processor/src/test/java/magnet/processor/SelectorInFactoryClassTest.kt",
"chars": 5586,
"preview": "package magnet.processor\n\nimport com.google.testing.compile.CompilationSubject\nimport com.google.testing.compile.Compile"
},
{
"path": "magnet-processor/src/test/java/magnet/processor/SiblingTypesTest.kt",
"chars": 3121,
"preview": "package magnet.processor\n\nimport com.google.testing.compile.CompilationSubject.assertThat\nimport com.google.testing.comp"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/App.java",
"chars": 62,
"preview": "package test;\n\nimport magnet.Registry;\n\n@Registry\nclass App {}"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Implementation1.java",
"chars": 121,
"preview": "package test;\n\nimport magnet.Instance;\n\n@Instance(type = Interface1.class)\nclass Implementation1 implements Interface1 {"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Implementation3_1.java",
"chars": 123,
"preview": "package test;\n\nimport magnet.Instance;\n\n@Instance(type = Interface3.class)\nclass Implementation3_1 implements Interface3"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Implementation3_2.java",
"chars": 123,
"preview": "package test;\n\nimport magnet.Instance;\n\n@Instance(type = Interface3.class)\nclass Implementation3_2 implements Interface3"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Implementation4_1.java",
"chars": 153,
"preview": "package test;\n\nimport magnet.Instance;\n\n@Instance(\n type = Interface4.class,\n classifier = \"one\"\n)\nclass Implement"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Implementation4_2.java",
"chars": 153,
"preview": "package test;\n\nimport magnet.Instance;\n\n@Instance(\n type = Interface4.class,\n classifier = \"two\"\n)\nclass Implement"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Implementation5_1.java",
"chars": 154,
"preview": "package test;\n\nimport magnet.Instance;\n\n@Instance(\n type = Interface5.class,\n classifier = \"zero\"\n)\nclass Implemen"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Implementation5_2.java",
"chars": 154,
"preview": "package test;\n\nimport magnet.Instance;\n\n@Instance(\n type = Interface5.class,\n classifier = \"zero\"\n)\nclass Implemen"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Implementation6_1.java",
"chars": 127,
"preview": "package test;\n\nimport magnet.Instance;\n\n@Instance(type = Interface6_1.class)\nclass Implementation6_1 implements Interfac"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Implementation6_2.java",
"chars": 127,
"preview": "package test;\n\nimport magnet.Instance;\n\n@Instance(type = Interface6_2.class)\nclass Implementation6_2 implements Interfac"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Interface1.java",
"chars": 38,
"preview": "package test;\n\ninterface Interface1 {}"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Interface3.java",
"chars": 38,
"preview": "package test;\n\ninterface Interface3 {}"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Interface4.java",
"chars": 38,
"preview": "package test;\n\ninterface Interface4 {}"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Interface5.java",
"chars": 38,
"preview": "package test;\n\ninterface Interface5 {}"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Interface6_1.java",
"chars": 40,
"preview": "package test;\n\ninterface Interface6_1 {}"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Interface6_2.java",
"chars": 40,
"preview": "package test;\n\ninterface Interface6_2 {}"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/Interface7.java",
"chars": 156,
"preview": "package test;\n\nimport magnet.Instance;\n\ninterface Interface7 {\n\n @Instance(type = Interface7.class)\n class Impleme"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/expected/MagnetIndexer1.java",
"chars": 550,
"preview": "package magnet.internal;\n\nimport java.util.HashMap;\nimport java.util.Map;\nimport test.Implementation1MagnetFactory;\n\n@Ge"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/expected/MagnetIndexer2.java",
"chars": 369,
"preview": "package magnet.internal;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\n@Generated\npublic final class MagnetIndexer {"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/expected/MagnetIndexer3.java",
"chars": 650,
"preview": "package magnet.internal;\n\nimport java.util.HashMap;\nimport java.util.Map;\nimport test.Implementation3_1MagnetFactory;\nim"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/expected/MagnetIndexer4.java",
"chars": 795,
"preview": "package magnet.internal;\n\nimport java.util.HashMap;\nimport java.util.Map;\nimport test.Implementation4_1MagnetFactory;\nim"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/expected/MagnetIndexer5.java",
"chars": 654,
"preview": "package magnet.internal;\n\nimport java.util.HashMap;\nimport java.util.Map;\nimport test.Implementation5_1MagnetFactory;\nim"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/expected/MagnetIndexer6.java",
"chars": 732,
"preview": "package magnet.internal;\n\nimport java.util.HashMap;\nimport java.util.Map;\nimport test.Implementation6_1MagnetFactory;\nim"
},
{
"path": "magnet-processor/src/test/resources/GenerateRegistryForInstanceFactoriesTest/expected/MagnetIndexer7.java",
"chars": 580,
"preview": "package magnet.internal;\n\nimport java.util.HashMap;\nimport java.util.Map;\nimport test.Interface7Implementation7MagnetFac"
},
{
"path": "magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/CustomFactory1.java",
"chars": 469,
"preview": "package test;\n\nimport magnet.Factory;\nimport magnet.Scope;\nimport magnet.Scoping;\nimport org.jetbrains.annotations.NotNu"
},
{
"path": "magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/CustomFactory2.java",
"chars": 431,
"preview": "package test;\n\nimport magnet.Factory;\nimport magnet.Scope;\nimport magnet.Scoping;\nimport org.jetbrains.annotations.NotNu"
},
{
"path": "magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/CustomFactory3.java",
"chars": 469,
"preview": "package test;\n\nimport magnet.Factory;\nimport magnet.Scope;\nimport magnet.Scoping;\nimport org.jetbrains.annotations.NotNu"
},
{
"path": "magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/Implementation1.java",
"chars": 170,
"preview": "package test;\n\nimport magnet.Instance;\n\n@Instance(\n type = Interface1.class,\n factory = CustomFactory1.class\n)\npub"
},
{
"path": "magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/Implementation2.java",
"chars": 170,
"preview": "package test;\n\nimport magnet.Instance;\n\n@Instance(\n type = Interface2.class,\n factory = CustomFactory2.class\n)\npub"
},
{
"path": "magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/Implementation3.java",
"chars": 231,
"preview": "package test;\n\nimport magnet.Instance;\n\n@Instance(\n type = Interface3.class,\n factory = CustomFactory3.class\n)\npub"
},
{
"path": "magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/Interface1.java",
"chars": 45,
"preview": "package test;\n\npublic interface Interface1 {}"
},
{
"path": "magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/Interface2.java",
"chars": 45,
"preview": "package test;\n\npublic interface Interface2 {}"
},
{
"path": "magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/Interface3.java",
"chars": 45,
"preview": "package test;\n\npublic interface Interface3 {}"
},
{
"path": "magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/expected/Implementation1MagnetFactory.java",
"chars": 761,
"preview": "package test;\n\nimport magnet.Factory;\nimport magnet.Scope;\nimport magnet.Scoping;\nimport magnet.internal.Generated;\nimpo"
},
{
"path": "magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/expected/Implementation2MagnetFactory.java",
"chars": 785,
"preview": "package test;\n\nimport magnet.Factory;\nimport magnet.Scope;\nimport magnet.Scoping;\nimport magnet.internal.Generated;\nimpo"
},
{
"path": "magnet-processor/src/test/resources/InstanceCustomFactoryProcessorTest/expected/Implementation3MagnetFactory.java",
"chars": 889,
"preview": "package test;\n\nimport magnet.Factory;\nimport magnet.Scope;\nimport magnet.Scoping;\nimport magnet.internal.Generated;\nimpo"
},
{
"path": "magnet-processor/src/test/resources/InstanceDisposerTest/Implementation1.java",
"chars": 187,
"preview": "package test;\n\nimport magnet.Instance;\n\n@Instance(\n type = Interface.class,\n disposer = \"disposeIt\"\n)\npublic class"
},
{
"path": "magnet-processor/src/test/resources/InstanceDisposerTest/Implementation2.java",
"chars": 185,
"preview": "package test;\n\nimport magnet.Instance;\n\n@Instance(\n type = Interface.class,\n disposer = \"disposeIt\"\n)\npublic class"
},
{
"path": "magnet-processor/src/test/resources/InstanceDisposerTest/Implementation3.java",
"chars": 199,
"preview": "package test;\n\nimport magnet.Instance;\n\n@Instance(\n type = Interface.class,\n disposer = \"disposeIt\"\n)\npublic class"
},
{
"path": "magnet-processor/src/test/resources/InstanceDisposerTest/Implementation4.java",
"chars": 203,
"preview": "package test;\n\nimport magnet.Instance;\n\n@Instance(\n type = Interface.class,\n disposer = \"disposeIt\"\n)\npublic class"
},
{
"path": "magnet-processor/src/test/resources/InstanceDisposerTest/Implementation5.java",
"chars": 256,
"preview": "package test;\n\nimport magnet.Instance;\nimport magnet.Scoping;\n\n@Instance(\n type = Interface.class,\n scoping = Scop"
},
{
"path": "magnet-processor/src/test/resources/InstanceDisposerTest/Interface.java",
"chars": 44,
"preview": "package test;\n\npublic interface Interface {}"
},
{
"path": "magnet-processor/src/test/resources/InstanceDisposerTest/expected/Implementation1MagnetFactory.java",
"chars": 581,
"preview": "package test;\n\nimport magnet.Scope;\nimport magnet.internal.Generated;\nimport magnet.internal.InstanceFactory;\n\n@Generate"
},
{
"path": "magnet-processor/src/test/resources/InstanceIndexProcessorTest/Implementation1.java",
"chars": 282,
"preview": "package app.test;\n\nimport app.Interface1;\nimport magnet.Instance;\n\n@Instance(\n type = Interface1.class,\n classifie"
},
{
"path": "magnet-processor/src/test/resources/InstanceIndexProcessorTest/Implementation2.java",
"chars": 148,
"preview": "package app.test;\n\nimport app.Interface2;\nimport magnet.Instance;\n\n@Instance(type = Interface2.class)\nclass Implementati"
},
{
"path": "magnet-processor/src/test/resources/InstanceIndexProcessorTest/Interface1.java",
"chars": 62,
"preview": "package app;\n\npublic interface Interface1 {\n int getId();\n}"
},
{
"path": "magnet-processor/src/test/resources/InstanceIndexProcessorTest/Interface2.java",
"chars": 44,
"preview": "package app;\n\npublic interface Interface2 {}"
},
{
"path": "magnet-processor/src/test/resources/InstanceIndexProcessorTest/generated/app_test_Implementation1MagnetFactory.java",
"chars": 422,
"preview": "package magnet.index;\n\nimport app.test.Implementation1MagnetFactory;\nimport magnet.internal.Generated;\nimport magnet.int"
},
{
"path": "magnet-processor/src/test/resources/InstanceIndexProcessorTest/generated/app_test_Implementation2MagnetFactory.java",
"chars": 407,
"preview": "package magnet.index;\n\nimport app.test.Implementation2MagnetFactory;\nimport magnet.internal.Generated;\nimport magnet.int"
},
{
"path": "magnet-processor/src/test/resources/MagnetProcessorFactoryNamesTest/Delegate1.java",
"chars": 93,
"preview": "package test;\n\nimport magnet.Instance;\n\n@Instance(type = Delegate1.class)\nclass Delegate1 {}\n"
},
{
"path": "magnet-processor/src/test/resources/MagnetProcessorFactoryNamesTest/Interface1.java",
"chars": 135,
"preview": "package test;\n\nimport magnet.Instance;\n\ninterface Interface1 {\n\n @Instance(type = Interface1.Delegate.class)\n clas"
},
{
"path": "magnet-processor/src/test/resources/MagnetProcessorFactoryNamesTest/generated/Delegate1MagnetFactory.java",
"chars": 372,
"preview": "package test;\n\nimport magnet.Scope;\nimport magnet.internal.Generated;\nimport magnet.internal.InstanceFactory;\n\n@Generate"
},
{
"path": "magnet-processor/src/test/resources/MagnetProcessorFactoryNamesTest/generated/Interface1DelegateMagnetFactory.java",
"chars": 421,
"preview": "package test;\n\nimport magnet.Scope;\nimport magnet.internal.Generated;\nimport magnet.internal.InstanceFactory;\n\n@Generate"
},
{
"path": "magnet-processor/src/test/resources/MagnetProcessorTest/AppExtensionRegistry.java",
"chars": 89,
"preview": "package app;\n\nimport magnet.Registry;\n\n@Registry\npublic interface AppExtensionRegistry {}"
},
{
"path": "magnet-processor/src/test/resources/MagnetProcessorTest/Constructor_PackagePrivate_PackagePrivate/UnderTest.java",
"chars": 167,
"preview": "package app;\n\nimport magnet.Instance;\nimport magnet.Scope;\n\n@Instance(type = UnderTest.class)\nclass UnderTest {\n\n Und"
},
{
"path": "magnet-processor/src/test/resources/MagnetProcessorTest/Constructor_PackagePrivate_Private/UnderTest.java",
"chars": 175,
"preview": "package app;\n\nimport magnet.Instance;\nimport magnet.Scope;\n\n@Instance(type = UnderTest.class)\nclass UnderTest {\n\n Und"
},
{
"path": "magnet-processor/src/test/resources/MagnetProcessorTest/Constructor_PackagePrivate_Private/expected/UnderTestMagnetFactory.java",
"chars": 359,
"preview": "package app;\n\nimport magnet.Scope;\nimport magnet.internal.Generated;\nimport magnet.internal.InstanceFactory;\n\n@Generated"
},
{
"path": "magnet-processor/src/test/resources/MagnetProcessorTest/Constructor_Private/UnderTest.java",
"chars": 123,
"preview": "package app;\n\nimport magnet.Instance;\n\n@Instance(type = UnderTest.class)\nclass UnderTest {\n\n private UnderTest() { }\n"
},
{
"path": "magnet-processor/src/test/resources/MagnetProcessorTest/Constructor_Protected/UnderTest.java",
"chars": 125,
"preview": "package app;\n\nimport magnet.Instance;\n\n@Instance(type = UnderTest.class)\nclass UnderTest {\n\n protected UnderTest() { "
},
{
"path": "magnet-processor/src/test/resources/MagnetProcessorTest/Constructor_Public_PackagePrivate/UnderTest.java",
"chars": 174,
"preview": "package app;\n\nimport magnet.Instance;\nimport magnet.Scope;\n\n@Instance(type = UnderTest.class)\nclass UnderTest {\n\n pub"
},
{
"path": "magnet-processor/src/test/resources/MagnetProcessorTest/Constructor_Public_Private/UnderTest.java",
"chars": 182,
"preview": "package app;\n\nimport magnet.Instance;\nimport magnet.Scope;\n\n@Instance(type = UnderTest.class)\nclass UnderTest {\n\n pub"
},
{
"path": "magnet-processor/src/test/resources/MagnetProcessorTest/Constructor_Public_Private/expected/UnderTestMagnetFactory.java",
"chars": 359,
"preview": "package app;\n\nimport magnet.Scope;\nimport magnet.internal.Generated;\nimport magnet.internal.InstanceFactory;\n\n@Generated"
}
]
// ... and 178 more files (download for full content)
About this extraction
This page contains the full source code of the beworker/magnet GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 378 files (18.0 MB), approximately 133.0k tokens, and a symbol index with 1158 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.