Skip to content

Add @BeanTypes Annotation to Limit Injection Types #665

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 5 commits into from
Aug 27, 2024

Conversation

SentryMan
Copy link
Collaborator

  • Creates @BeanTypes annotation to define the injectable types associated with a bean.
  • the values provided to the annotation will also override auto-provides generation

Given the class:

@Component
@BeanTypes(SomeInterface2.class)
public class LimitedOtherComponent extends AbstractSuperClass
    implements SomeInterface, SomeInterface2 {}

the following will be generated:

@Generated("io.avaje.inject.generator")
public final class LimitedOtherComponent$DI  {

  /**
   * Create and register LimitedOtherComponent.
   */
  public static void build(Builder builder) {
    if (builder.isAddBeanFor(SomeInterface2.class)) {
      var bean = new LimitedOtherComponent();
      builder.register(bean);
    }
  }
}

@SentryMan SentryMan added the enhancement New feature or request label Aug 18, 2024
@SentryMan SentryMan added this to the 10.4 milestone Aug 18, 2024
@SentryMan SentryMan requested a review from rbygrave August 18, 2024 15:02
@SentryMan SentryMan self-assigned this Aug 18, 2024
@SentryMan SentryMan changed the title Adds BeanTypes annotation Add @BeanTypes Annotation to Limit Injection Types Aug 18, 2024
@rbygrave
Copy link
Contributor

There are no blackbox tests yet. So it compiles but I don't see tests in blackbox that assert the behaviour. Can we add those tests?

@SentryMan
Copy link
Collaborator Author

SentryMan commented Aug 18, 2024

Ran out of time unfortunately, on a road trip without anything more complex than a phone for the rest of the week.

@SentryMan SentryMan requested a review from rob-bygrave August 25, 2024 19:45
@SentryMan
Copy link
Collaborator Author

Added the tests, please review when you get time

@rbygrave rbygrave merged commit ddabd07 into avaje:master Aug 27, 2024
7 checks passed
@SentryMan SentryMan deleted the auto-provide-filter branch August 27, 2024 12:51
@SentryMan
Copy link
Collaborator Author

@rbygrave please deploy an RC when you find the time

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants