Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add @BeanTypes Annotation to Limit Injection Types #665

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 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
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

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

Successfully merging this pull request may close these issues.

2 participants