Repository: jenkinsci/jenkins
File: core/src/main/java/hudson/model/Queue.java (Java)

Code before:
         *
         * <p>
         * Otherwise this method returns null, indicating that the build can proceed right away.
         *
         * <p>
         * This can be used to define mutual exclusion that goes beyond
         * {@link #getResourceList()}.
         * @return by default, null
         */
        @CheckForNull
        default CauseOfBlockage getCauseOfBlockage() {
            return null;
        }

        /**
         * Unique name of this task.
         *
         * <p>
         * This method is no longer used, left here for compatibility. Just return {@link #getDisplayName()}.
         */
        String getName();

        /**
         * Returns task-specific key which is used by the {@link LoadBalancer} to choose one particular executor
         * amongst all the free executors on all possibly suitable nodes.
         * NOTE: To be able to re-use the same node during the next run this key should not change from one run to
         * another. You probably want to compute that key based on the job's name.
         *
         * @return by default: {@link #getFullDisplayName()}
         * @see hudson.model.LoadBalancer
         */
        default String getAffinityKey() { return getFullDisplayName(); }

        /**
         * Checks the permission to see if the current user can abort this executable.
         * Returns normally from this method if it's OK.
         * <p>
         * NOTE: If you have implemented {@link AccessControlled} this defaults to
         * {@code checkPermission(hudson.model.Item.CANCEL);}
         *
         * @throws AccessDeniedException if the permission is not granted.
         */
        default void checkAbortPermission() {
            if (this instanceof AccessControlled) {
                ((AccessControlled) this).checkPermission(CANCEL);
            }
        }

        /**
         * Returns the URL of this task relative to the context root of the application.
         *

Review comment (suggestion):
We might want to switch the default to `getFullName` if `this instanceof FullyNamed`.

https://github.com/jenkinsci/workflow-durable-task-step-plugin/blob/1b595c29ddd712c7f1ea2b30c4356d979e4a67bc/src/main/java/org/jenkinsci/plugins/workflow/support/steps/ExecutorStepExecution.java#L838-L845 is the other implementation.

Code after:
         * this method returns a non-null object explaining why.
         *
         * <p>
         * Otherwise this method returns null, indicating that the build can proceed right away.
         *
         * <p>
         * This can be used to define mutual exclusion that goes beyond
         * {@link #getResourceList()}.
         * @return by default, null
         */
        @CheckForNull
        default CauseOfBlockage getCauseOfBlockage() {
            return null;
        }

        /**
         * Unique name of this task.
         *
         * <p>
         * This method is no longer used, left here for compatibility. Just return {@link #getDisplayName()}.
         */
        String getName();

        /**
         * Returns task-specific key which is used by the {@link LoadBalancer} to choose one particular executor
         * amongst all the free executors on all possibly suitable nodes.
         * NOTE: To be able to re-use the same node during the next run this key should not change from one run to
         * another. You probably want to compute that key based on the job's name.
         *
         * @return by default: {@link FullyNamed#getFullName()} if implements {@link FullyNamed} or {@link #getFullDisplayName()} otherwise.
         * @see hudson.model.LoadBalancer
         */
        default String getAffinityKey() {
            if (this instanceof FullyNamed fullyNamed) {
                return fullyNamed.getFullName();
            } else {
                return getFullDisplayName();
            }
        }

        /**
         * Checks the permission to see if the current user can abort this executable.
         * Returns normally from this method if it's OK.
         * <p>
         * NOTE: If you have implemented {@link AccessControlled} this defaults to
         * {@code checkPermission(hudson.model.Item.CANCEL);}
         *
         * @throws AccessDeniedException if the permission is not granted.
         */
        default void checkAbortPermission() {
            if (this instanceof AccessControlled) {