Skip to content
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

Add accepted types to ProfileContext #2814

Merged
merged 2 commits into from
Mar 13, 2022

Conversation

J-N-K
Copy link
Member

@J-N-K J-N-K commented Mar 2, 2022

I'm working on a very generic script profile which can be used with every item type. E.g. a script could half all commands from the handler to the item. Since a Dimmer channel accepts different item types, I need to know which types are accepted by the receiving item. This could e.g. also be used to link a String channel (containing a JSON array as result of an HTTP request) to an Number item (for element count in the array).

Even tough I doubt that there are other implementations of ProfileContext out there, I decided to keep it backward compatible and make the implementation of the newly introduced methods optional. If you don't mind the breaking change, I can easily remove them.

Signed-off-by: Jan N. Klug github@klug.nrw

@J-N-K J-N-K requested a review from a team as a code owner March 2, 2022 19:02
Signed-off-by: Jan N. Klug <github@klug.nrw>
@cweitkamp cweitkamp added the enhancement An enhancement or new feature of the Core label Mar 13, 2022
Copy link
Contributor

@cweitkamp cweitkamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I second your doubt on the different implementations of the ProfileContext interface but agree on the default methods.

Comment on lines 40 to 44
public ProfileContextImpl(Configuration configuration) {
this.configuration = configuration;
this.acceptedDataTypes = List.of();
this.acceptedCommandTypes = List.of();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we reuse the second ctor here?

Suggested change
public ProfileContextImpl(Configuration configuration) {
this.configuration = configuration;
this.acceptedDataTypes = List.of();
this.acceptedCommandTypes = List.of();
}
public ProfileContextImpl(Configuration configuration) {
this(configuration, List.of(), List.of());
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Signed-off-by: Jan N. Klug <github@klug.nrw>
@cweitkamp cweitkamp merged commit 73b76fa into openhab:main Mar 13, 2022
@cweitkamp cweitkamp added this to the 3.3 milestone Mar 13, 2022
@J-N-K J-N-K deleted the feature-profilecontext branch March 13, 2022 10:28
splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this pull request Jul 12, 2023
* Add accepted types to ProfileContext

Signed-off-by: Jan N. Klug <github@klug.nrw>
GitOrigin-RevId: 73b76fa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants