-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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 default implementations of deprecated methods of BuilableItem and Item. #3142
Add default implementations of deprecated methods of BuilableItem and Item. #3142
Conversation
… Item. Currently the interface requires the API user to implement already deprecated methods. It does not make much sense, and the API could be simplified.
* @param useDisplayName if true, returns a display name, otherwise returns a name | ||
* @return | ||
* String like "foo » bar" | ||
* String like "foo » bar". | ||
* {@code null} if item is null or if one of its parents is not an {@link ItemGroup}. |
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.
Just documented it while I was around
@@ -40,13 +40,19 @@ | |||
* Use {@link #scheduleBuild(Cause)}. Since 1.283 | |||
*/ | |||
@Deprecated | |||
boolean scheduleBuild(); | |||
default boolean scheduleBuild() { |
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.
tabs vs spaces :( Should I use tabs or refactor the methods?
This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation. |
Fix your flaky tests. :-) |
@@ -1143,11 +1144,14 @@ private static String normalizeURI(String uri) { | |||
* | |||
* @since 1.515 | |||
* @param p the Item we want the relative display name | |||
* @param g the ItemGroup used as point of reference for the item | |||
* @param g the ItemGroup used as point of reference for the item. | |||
* If the group is not specified, item's path will be used. |
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.
mark it @CheckForNull
please
* @param useDisplayName if true, returns a display name, otherwise returns a name | ||
* @return | ||
* String like "foo » bar" | ||
* String like "foo » bar". | ||
* {@code null} if item is null or if one of its parents is not an {@link ItemGroup}. |
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.
Huh? A parent by definition is an ItemGroup
. I guess you mean is not an Item
?
@@ -1194,8 +1198,10 @@ public static String getRelativeNameFrom(Item p, ItemGroup g, boolean useDisplay | |||
* @param p the Item we want the relative display name | |||
* @param g the ItemGroup used as point of reference for the item | |||
* @return | |||
* String like "foo/bar" | |||
* String like "foo/bar". | |||
* {@code null} if the item is {@code null} or if one of its parents is not an {@link ItemGroup}. |
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.
ditto
@@ -1208,8 +1214,10 @@ public static String getRelativeNameFrom(Item p, ItemGroup g) { | |||
* @param p the Item we want the relative display name | |||
* @param g the ItemGroup used as point of reference for the item | |||
* @return | |||
* String like "Foo » Bar" | |||
* String like "Foo » Bar". | |||
* {@code null} if the item is {@code null} or if one of its parents is not an {@link ItemGroup}. |
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.
ditto
*/ | ||
@Nullable | ||
public static String getRelativeNameFrom(Item p, ItemGroup g, boolean useDisplayName) { |
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.
Really these methods should have been in Items
(cf. #3148). Too late I suppose, unless we deprecate the Functions
versions, which seems too intrusive.
* @since 1.419 | ||
* @return | ||
* String like "../foo/bar" | ||
* String like "../foo/bar". | ||
* {@code null} if item parents is not an {@link ItemGroup}. |
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.
probably s/ItemGroup
/Item
/
* @param g | ||
* The ItemGroup instance used as context to evaluate the relative name of this AbstractItem | ||
* @return | ||
* The name of the current item, relative to p. Nested ItemGroups are separated by {@code /} character. |
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.
use @link
@@ -131,18 +133,28 @@ | |||
/** | |||
* Gets the relative name to this item from the specified group. | |||
* | |||
* @param g | |||
* The ItemGroup instance used as context to evaluate the relative name of this AbstractItem |
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.
Not necessarily an AbstractItem
. Anyway use @link
, or plain words.
@@ -207,7 +224,9 @@ | |||
* | |||
* @since 1.374 | |||
*/ | |||
default void onCreatedFromScratch() {} | |||
default void onCreatedFromScratch() { | |||
// do nothing by default |
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.
Why would there not be default no-op impls of onLoad
and onCopiedFrom
then?
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 was thinking about that, but I decided not to touch it for now since I was unable to find noop implementations.
…ing/BuildableItem_defaults-2
@jglick addressed your comments |
*/ | ||
default String getRelativeNameFrom(ItemGroup g) { | ||
@Nullable |
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.
Not actually sure why these are all @Nullable
rather than @CheckForNull
. Is there some circumstance where a caller would statically know the return value cannot be null?
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.
Yes, generally "in all sane cases" assuming you do not resolve names for things like Promoted Builds plugin PromotionProcess instances or pass nulls. I can add @CheckForNull
, but it may become just another Jenkins.getInstance()
Currently the interface requires the API user to implement already deprecated methods.
It does not make much sense, and the API could be simplified.
Proposed changelog entries
Desired reviewers
@reviewbybees