Skip to content

Commit fc0dce6

Browse files
committed
rename isAddBeanFor
1 parent 74aec7b commit fc0dce6

File tree

6 files changed

+41
-12
lines changed

6 files changed

+41
-12
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 buildAddFor(Append writer) {
298-
writer.append(" if (builder.isAddBeanFor(");
297+
void buildBeanAbsent(Append writer) {
298+
writer.append(" if (builder.isBeanAbsent(");
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.isAddBeanFor() uses it and allows
89+
// for multiRegister we desire a qualifier name such that builder.isBeanAbsent() 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.isAddBeanFor(");
355+
writer.append(" if (builder.isBeanAbsent(");
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.buildAddFor(writer);
175+
beanReader.buildBeanAbsent(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: 31 additions & 2 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 isAddBeanFor(String name, Type... types);
45+
boolean isBeanAbsent(String name, Type... types);
4646

4747
/**
4848
* Return true if the bean should be created and registered with the context.
@@ -52,7 +52,36 @@ static Builder newBuilder(Set<String> profiles, ConfigPropertyPlugin plugin, Lis
5252
*
5353
* @param types The types that the bean implements and provides
5454
*/
55-
boolean isAddBeanFor(Type... types);
55+
boolean isBeanAbsent(Type... types);
56+
57+
/**
58+
* Return true if the bean should be created and registered with the context.
59+
*
60+
* <p>Returning false means there has been a supplied bean already registered and that we should
61+
* skip the creation and registration for this bean.
62+
*
63+
* @param name The qualifier name
64+
* @param types The types that the bean implements and provides
65+
* @deprecated use {@link #isBeanAbsent(String, Type...)}
66+
*/
67+
@Deprecated(forRemoval = true)
68+
default boolean isAddBeanFor(String name, Type... types) {
69+
return isBeanAbsent(name, types);
70+
}
71+
72+
/**
73+
* Return true if the bean should be created and registered with the context.
74+
*
75+
* <p>Returning false means there has been a supplied bean already registered and that we should
76+
* skip the creation and registration for this bean.
77+
*
78+
* @param types The types that the bean implements and provides
79+
* @deprecated use {@link #isBeanAbsent(Type...)} instead
80+
*/
81+
@Deprecated(forRemoval = true)
82+
default boolean isAddBeanFor(Type... types) {
83+
return isBeanAbsent(types);
84+
}
5685

5786
/**
5887
* Register the next bean as having Primary priority.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ public void currentModule(Class<? extends AvajeModule> currentModule) {
4949
}
5050

5151
@Override
52-
public final boolean isAddBeanFor(Type... types) {
53-
return isAddBeanFor(null, types);
52+
public final boolean isBeanAbsent(Type... types) {
53+
return isBeanAbsent(null, types);
5454
}
5555

5656
@Override
57-
public boolean isAddBeanFor(String name, Type... types) {
57+
public boolean isBeanAbsent(String name, Type... types) {
5858
parentMatch = null;
5959
next(name, types);
6060
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 isAddBeanFor(String qualifierName, Type... types) {
38-
if (!super.isAddBeanFor(qualifierName, types)) {
37+
public boolean isBeanAbsent(String qualifierName, Type... types) {
38+
if (!super.isBeanAbsent(qualifierName, types)) {
3939
enrichParentMatch();
4040
return false;
4141
}

0 commit comments

Comments
 (0)