-
-
Notifications
You must be signed in to change notification settings - Fork 104
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
Component::applyFallbackStyle helper method #488
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Final nitpicks :p
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is the best solution for this sort of operation. What can this wrap
operator do that an appropriate style merge can't do with fewer levels of nesting?
With an alternative API of something like:
interface Component {
default @NotNull Component applyUnsetStyleFrom(final @NotNull Style /* or StyleBuilderApplicable... */ other) {
return this.style(this.style().merge(other, Merge.Strategy.IF_ABSENT_ON_TARGET));
}
}
would there be any limitations compared to this PR? (well, aside from the name)
Yes, this component wrapping isn't the ideal solution to the problem it solves. However, it is way more intuitive than other solutions. If we can think of a solid name for this apply unset method, I'd be happy to see a PR with that come through too. However, as it stands I think this PR is solid, and introduces a short-hand for a relatively common pattern. |
Should this PR still be considered for 4.10.0? |
I've changed my mind - I think calling this method Think of the case where someone heads onto webui and makes a non-italic lore item. If a developer wants to make that the default, it would be nice to have this method as a no-op in the case where the user has already made the change, for example. |
I've made the method perform a style merge as outlined in #488 (review), but now it theoretically no longer contains any "wrapper"s per se, so i'm confused on how to document this, although it accomplishes the same thing |
|
Yeah I kiinda like this. Would this be worth having in StyleSetter instead of Component? |
Co-authored-by: Riley Park <[email protected]>
Implements and resolves #486.
EDIT: Method was extensively renamed, see discussion below
Of note: I'm not good with javadocs and the explanation is moot at best, please suggest a better wording to describe this "wrapping" feature.
Also, could there possibly be a
default
instance method, to allow formm.wrap(ITALIC.as(false))
, or would that be too unclear in its operation?