Skip to content

Commit 065a071

Browse files
committed
Merge remote-tracking branch 'upstream/master' into tidy-deprecations
2 parents dccaa6b + d1e1e40 commit 065a071

File tree

6 files changed

+30
-17
lines changed

6 files changed

+30
-17
lines changed

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

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

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

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

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

+22-4
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,42 @@ static Builder newBuilder(Set<String> profiles, ConfigPropertyPlugin plugin, Lis
3535

3636
/**
3737
* Return true if the bean should be created and registered with the context.
38-
* <p/>
38+
* <p>
3939
* Returning false means there has been a supplied bean already registered and
4040
* that we should skip the creation and registration for this bean.
4141
*
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.
49-
* <p/>
49+
* <p>
5050
* Returning false means there has been a supplied bean already registered and
5151
* that we should skip the creation and registration for this bean.
5252
*
5353
* @param types The types that the bean implements and provides
5454
*/
55-
boolean isAddBeanFor(Type... types);
55+
default boolean isBeanAbsent(Type... types) {
56+
return isBeanAbsent(null, types);
57+
}
58+
59+
/**
60+
* @deprecated use {@link #isBeanAbsent(String, Type...)}
61+
*/
62+
@Deprecated(forRemoval = true)
63+
default boolean isAddBeanFor(String name, Type... types) {
64+
return isBeanAbsent(name, types);
65+
}
66+
67+
/**
68+
* @deprecated use {@link #isBeanAbsent(Type...)} instead
69+
*/
70+
@Deprecated(forRemoval = true)
71+
default boolean isAddBeanFor(Type... types) {
72+
return isBeanAbsent(types);
73+
}
5674

5775
/**
5876
* Register the next bean as having Primary priority.

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

+1-6
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,7 @@ public void currentModule(Class<? extends AvajeModule> currentModule) {
4949
}
5050

5151
@Override
52-
public final boolean isAddBeanFor(Type... types) {
53-
return isAddBeanFor(null, types);
54-
}
55-
56-
@Override
57-
public boolean isAddBeanFor(String name, Type... types) {
52+
public boolean isBeanAbsent(String name, Type... types) {
5853
parentMatch = null;
5954
next(name, types);
6055
if (parentOverride || parent == null) {

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

+2-2
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)