-
Notifications
You must be signed in to change notification settings - Fork 582
builder interceptor support #5591
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6eb79e6
Support for interceptors
trentjeff 4219005
fix build
trentjeff c0f374c
checkstyles
trentjeff 4564491
javadoc
trentjeff 8937f6c
handle case where common Builder methods interfere with target bean m…
trentjeff f338512
more checkstyles
trentjeff 1a4c6b7
Fix for issue #5608
trentjeff 40e58b6
Fix for issue #5609
trentjeff 3f45f57
address review comments
trentjeff 5991d58
resolved the rest of the review comments
trentjeff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
builder/builder/src/main/java/io/helidon/builder/BuilderInterceptor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (c) 2022 Oracle and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.helidon.builder; | ||
|
||
/** | ||
* Provides a contract by which the {@link Builder}-annotated builder type can be intercepted (i.e., including decoration or | ||
* mutation). | ||
* <p> | ||
* This type is used when {@link Builder#requireLibraryDependencies} is used. When it is turned off, however, an equivalent | ||
* type will be code-generated into each generated bean. | ||
* Note also that in this situation your interceptor implementation does not need to implement this interface contract, | ||
* but instead must adhere to the following: | ||
* <ul> | ||
* <li>The implementation class type must provide a no-arg accessible constructor available to the generated class, unless | ||
* the {@link io.helidon.builder.Builder#interceptorCreateMethod()} is used. | ||
* <li>The implementation class type must provide a method-compatible (lambda) signature to the {@link #intercept} method. | ||
* <li>Any exceptions that might be thrown from the {@link #intercept} method must be an unchecked exception type. | ||
* </ul> | ||
* | ||
* @param <T> the type of the bean builder to intercept | ||
* | ||
* @see io.helidon.builder.Builder#interceptor() | ||
*/ | ||
@FunctionalInterface | ||
public interface BuilderInterceptor<T> { | ||
|
||
/** | ||
* Provides the ability to intercept (i.e., including decoration or mutation) the target. | ||
* | ||
* @param target the target being intercepted | ||
* @return the mutated or replaced target (must not be null) | ||
*/ | ||
T intercept(T target); | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.