Skip to content

Commit 8eb7e7f

Browse files
authored
Fix references to interceptor. Now using decorator for builders. (helidon-io#7405)
1 parent fcf588c commit 8eb7e7f

3 files changed

Lines changed: 17 additions & 18 deletions

File tree

builder/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The following list of features is currently supported:
2222
- `Map` options - key/value map, builders support any key/value types, but if configuration is used, the key must be a string
2323
- "Singular" for collection based options, which adds setter for a single value (for `List<String> algorithms()`, there would be the following setters: `algorithms(List<String>)`, `addAlgorithms(List<String>)`, `addAlgorithm(String)`)
2424
- A type can be `@Configured`, which adds integration with Helidon common Config module, by adding a static factory method `create(io.helidon.common.Config)` to the generated type, as well as `config(Config)` method to the generated builder, that sets all options annotated with `@ConfiguredOption` from configuration (if present in the Config instance)
25-
- Capability to update the builder before validation (interceptor)
25+
- Capability to update the builder before validation (decorator)
2626
- Support for custom methods (`@Prototype.CustomMethods`) for factory methods, prototype methods, and builder methods
2727

2828
## Non-Goals
@@ -84,4 +84,4 @@ Generated types will be available under `./target/generated-sources/annotations`
8484
* Support for `builder(MyConfigBean)` to create a new builder from an existing instance
8585
* Support for `from(MyConfigBean)` and `from(MyConfigBean.BuilderBase<?, ?>)` to update builder from an instance or builder
8686
* Support for validation of required and non-nullable options (required options are options that have `@ConfiguredOption(required=true)`, non-nullable option is any option that is not primitive, collection, and does not return an `Optional`)
87-
* Support for builder interception (`@Bluprint(builderInterceptor = MyInterceptor.class)`)
87+
* Support for builder decorator (`@Bluprint(decorator = MyDecorator.class)`), `class MyDecorator implements BuilderDecorator`

builder/api/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ Annotations:
8787

8888
Interfaces:
8989

90-
| Interface | Generated | Description |
91-
|--------------------------------|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
92-
| `RuntimeType.Api` | `false` | runtime type must implement this interface to mark which prototype is used to create it |
93-
| `Prototype.Factory` | `false` | if blueprint implements factory, it means the prototype is used to create a single runtime type and will have methods `build` and `get` both on builder an on prototype interface that create a new instance of the runtime object |
94-
| `Prototype.BuilderInterceptor` | `false` | custom interceptor to modidfy buider before validation is done in method `build` |
95-
| `Prototype.Api` | `true` | all prototypes implement this interface |
96-
| `Prototype.Builder` | `true` | all prototype builders implement this interface, defines method `buildPrototype` |
97-
| `Prototype.ConfiguredBuilder` | `true` | all prototype builders that support configuration implement this interface, defines method `config(Config)` |
90+
| Interface | Generated | Description |
91+
|-------------------------------|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
92+
| `RuntimeType.Api` | `false` | runtime type must implement this interface to mark which prototype is used to create it |
93+
| `Prototype.Factory` | `false` | if blueprint implements factory, it means the prototype is used to create a single runtime type and will have methods `build` and `get` both on builder an on prototype interface that create a new instance of the runtime object |
94+
| `Prototype.BuilderDecorator` | `false` | custom decorator to modify builder before validation is done in method `build` |
95+
| `Prototype.Api` | `true` | all prototypes implement this interface |
96+
| `Prototype.Builder` | `true` | all prototype builders implement this interface, defines method `buildPrototype` |
97+
| `Prototype.ConfiguredBuilder` | `true` | all prototype builders that support configuration implement this interface, defines method `config(Config)` |
9898

9999
## Configured providers
100100

builder/api/src/main/java/io/helidon/builder/api/Prototype.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public interface ConfiguredBuilder<BUILDER, PROTOTYPE> extends Builder<BUILDER,
8484
* Any configured option that is defined on this prototype will be checked in configuration, and if it exists,
8585
* it will override current value for that option on this builder.
8686
* Options that do not exist in the provided config will not impact current values.
87-
* The config instance is kept and may be used in builder interceptor, it is not available in prototype implementation.
87+
* The config instance is kept and may be used in builder decorator, it is not available in prototype implementation.
8888
*
8989
* @param config configuration to use
9090
* @return updated builder instance
@@ -221,7 +221,7 @@ public interface Factory<T> {
221221

222222
/**
223223
* Used to decorate the builder, right before method build is called.
224-
* Validations are done AFTER the interceptor is handled.
224+
* Validations are done AFTER the decorator is handled.
225225
* This class may be package local if located in the same package as blueprint.
226226
* The class must have accessible constructor with no parameters.
227227
*
@@ -232,23 +232,22 @@ public interface Factory<T> {
232232

233233
/**
234234
* Provides a contract by which the {@link Prototype.Blueprint}
235-
* annotated type can be intercepted (i.e., including decoration or
236-
* mutation).
235+
* annotated type can be decorated.
237236
* <p>
238237
* The implementation class type must provide a no-arg accessible constructor available to the generated class
239238
* <p>
240-
* Note that when intercepting config, you may get {@code null} even for required types, as these may be configured
241-
* by your very builder interceptor.
239+
* The builder provides accessors to all types, using {@link java.util.Optional} for any field that is optional,
240+
* or any other field unless it has a default value. Primitive types are an exception (unless declared as required).
242241
*
243242
* @param <T> the type of the bean builder to intercept
244243
* @see io.helidon.builder.api.Prototype.Blueprint#decorator()
245244
*/
246245
@FunctionalInterface
247246
public interface BuilderDecorator<T> {
248247
/**
249-
* Provides the ability to intercept (i.e., including decoration or mutation) the target.
248+
* Provides the ability to decorate the target.
250249
*
251-
* @param target the target being intercepted
250+
* @param target the target being decorated
252251
*/
253252
void decorate(T target);
254253
}

0 commit comments

Comments
 (0)