Package magnet

Annotation Type Classifier


  • @Retention(CLASS)
    @Target({PARAMETER,METHOD})
    public @interface Classifier
    Magnet can bind multiple instances of the same type into a scope. Use classifier with a unique value to differentiate between those instances.
          // 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,
          ) {
              ...
          }
     
    • Field Summary

      Fields 
      Modifier and Type Fields Description
      static java.lang.String NONE  
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      java.lang.String value  
    • Field Detail

      • NONE

        static final java.lang.String NONE
    • Element Detail

      • value

        java.lang.String value