Skip to content

Commit 6bf246e

Browse files
committed
canRegister
1 parent 1df4fbd commit 6bf246e

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

inject-generator/src/main/java/io/avaje/inject/generator/BeanReader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ void buildConditional(Append writer) {
294294
new ConditionalWriter(writer, conditions).write();
295295
}
296296

297-
void buildBeanAbsent(Append writer) {
298-
writer.append(" if (builder.isBeanAbsent(");
297+
void buildCanRegister(Append writer) {
298+
writer.append(" if (builder.canRegister(");
299299
if (name != null && !name.isEmpty()) {
300300
writer.append("\"%s\", ", name);
301301
}

inject-generator/src/main/java/io/avaje/inject/generator/MethodReader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ final class MethodReader {
8686
String destroyMethod = (bean == null) ? null : bean.destroyMethod();
8787
this.destroyPriority = (bean == null) ? null : bean.destroyPriority();
8888
this.beanCloseable = (bean != null) && bean.autoCloseable();
89-
// for multiRegister we desire a qualifier name such that builder.isBeanAbsent() uses it and allows
89+
// for multiRegister we desire a qualifier name such that builder.canRegister() uses it and allows
9090
// other beans of the same type to also register, otherwise it defaults to slightly confusing behaviour
9191
this.name = multiRegister && qualifierName == null ? "multi" : qualifierName;
9292
TypeElement returnElement = multiRegister ? APContext.typeElement(uType.mainType()) : asElement(returnMirror);
@@ -352,7 +352,7 @@ void buildConditional(Append writer) {
352352
}
353353

354354
void buildAddFor(Append writer) {
355-
writer.append(" if (builder.isBeanAbsent(");
355+
writer.append(" if (builder.canRegister(");
356356
if (isVoid) {
357357
writer.append("Void.class");
358358
} else {

inject-generator/src/main/java/io/avaje/inject/generator/SimpleBeanWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ private void writeStaticFactoryMethod() {
172172

173173
private void writeAddFor(MethodReader constructor) {
174174
beanReader.buildConditional(writer);
175-
beanReader.buildBeanAbsent(writer);
175+
beanReader.buildCanRegister(writer);
176176
if (beanReader.registerProvider()) {
177177
indent += " ";
178178
writer.append(" builder.%s(() -> {", beanReader.lazy() ? "registerProvider" : "asPrototype().registerProvider").eol();

inject/src/main/java/io/avaje/inject/spi/Builder.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static Builder newBuilder(Set<String> profiles, ConfigPropertyPlugin plugin, Lis
4242
* @param name The qualifier name
4343
* @param types The types that the bean implements and provides
4444
*/
45-
boolean isBeanAbsent(String name, Type... types);
45+
boolean canRegister(String name, Type... types);
4646

4747
/**
4848
* Return true if the bean should be created and registered with the context.
@@ -52,8 +52,8 @@ static Builder newBuilder(Set<String> profiles, ConfigPropertyPlugin plugin, Lis
5252
*
5353
* @param types The types that the bean implements and provides
5454
*/
55-
default boolean isBeanAbsent(Type... types) {
56-
return isBeanAbsent(null, types);
55+
default boolean canRegister(Type... types) {
56+
return canRegister(null, types);
5757
}
5858

5959
/**
@@ -64,11 +64,11 @@ default boolean isBeanAbsent(Type... types) {
6464
*
6565
* @param name The qualifier name
6666
* @param types The types that the bean implements and provides
67-
* @deprecated use {@link #isBeanAbsent(String, Type...)}
67+
* @deprecated use {@link #canRegister(String, Type...)}
6868
*/
6969
@Deprecated(forRemoval = true)
7070
default boolean isAddBeanFor(String name, Type... types) {
71-
return isBeanAbsent(name, types);
71+
return canRegister(name, types);
7272
}
7373

7474
/**
@@ -78,11 +78,11 @@ default boolean isAddBeanFor(String name, Type... types) {
7878
* skip the creation and registration for this bean.
7979
*
8080
* @param types The types that the bean implements and provides
81-
* @deprecated use {@link #isBeanAbsent(Type...)} instead
81+
* @deprecated use {@link #canRegister(Type...)} instead
8282
*/
8383
@Deprecated(forRemoval = true)
8484
default boolean isAddBeanFor(Type... types) {
85-
return isBeanAbsent(types);
85+
return canRegister(types);
8686
}
8787

8888
/**

inject/src/main/java/io/avaje/inject/spi/DBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void currentModule(Class<? extends AvajeModule> currentModule) {
4949
}
5050

5151
@Override
52-
public boolean isBeanAbsent(String name, Type... types) {
52+
public boolean canRegister(String name, Type... types) {
5353
parentMatch = null;
5454
next(name, types);
5555
if (parentOverride || parent == null) {

inject/src/main/java/io/avaje/inject/spi/DBuilderExtn.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ final class DBuilderExtn extends DBuilder {
3434
}
3535

3636
@Override
37-
public boolean isBeanAbsent(String qualifierName, Type... types) {
38-
if (!super.isBeanAbsent(qualifierName, types)) {
37+
public boolean canRegister(String qualifierName, Type... types) {
38+
if (!super.canRegister(qualifierName, types)) {
3939
enrichParentMatch();
4040
return false;
4141
}

0 commit comments

Comments
 (0)