Package jenkins.scm.api
Class SCMHead
java.lang.Object
jenkins.scm.api.SCMHead
- All Implemented Interfaces:
Serializable
,Comparable<SCMHead>
,SCMHeadMixin
Represents a named SCM branch, change request, tag or mainline. This class is intended to be used as a typed key
rather than passing a
String
around. Each SCMSource
implementation may want to have their own
subclasses in order assist to differentiating between different classes of head via the SCMHeadMixin
interfaces.
Please note the equality contract for SCMHeadMixin
implementations:
Two SCMHeadMixin
implementations are equal if and only if:
- They both are the same class
- They both have the same
SCMHeadMixin.getName()
- For each implemented
SCMHeadMixin
sub-interface, they both return the same values from all Java Bean property getters declared on the sub-interface. Thus, for exampleChangeRequestSCMHead
implementations are only considered equal ifChangeRequestSCMHead.getId()
andChangeRequestSCMHead.getTarget()
are also equal
Object.hashCode()
is:
Object.hashCode()
for aSCMHeadMixin
implementation must be equal to theString.hashCode()
ofSCMHeadMixin.getName()
equals(Object)
and hashCode()
methods enforce the above requirements and
are final.- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Means of locating a head given an item.Nested classes/interfaces inherited from interface jenkins.scm.api.mixin.SCMHeadMixin
SCMHeadMixin.Equality
-
Field Summary
Modifier and TypeFieldDescriptionstatic final AlternativeUiTextProvider.Message<SCMHead>
Replaceable pronoun of that points to aSCMHead
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
final boolean
Indicates whether some other object is "equal to" this one.<T extends Action>
TDeprecated.this was added to the API in error.Deprecated.this was added to the API in error.getName()
Returns the name.Returns the origin of the head.Get the term used in the UI to represent this kind ofSCMHead
.final int
hashCode()
toString()
-
Field Details
-
PRONOUN
Replaceable pronoun of that points to aSCMHead
. Defaults tonull
depending on the context.- Since:
- 2.0
-
-
Constructor Details
-
SCMHead
Constructor.- Parameters:
name
- the name.
-
-
Method Details
-
getName
Returns the name.- Specified by:
getName
in interfaceSCMHeadMixin
- Returns:
- the name.
-
getOrigin
Returns the origin of the head.-
For centralized version control systems such as Subversion, CVS, etc the return value will always be
SCMHeadOrigin.DEFAULT
. - For distributed version control systems such as Git, Mercurial etc the return value may have other values.
-
For centralized distributed version control systems such as GitHub, Bitbucket, etc the return values may
be restricted to
SCMHeadOrigin.DEFAULT
or instances ofSCMHeadOrigin.Fork
.
- Specified by:
getOrigin
in interfaceSCMHeadMixin
- Returns:
- the origin of the head or
SCMHeadOrigin.DEFAULT
if there can only ever be one origin.
-
For centralized version control systems such as Subversion, CVS, etc the return value will always be
-
getPronoun
Get the term used in the UI to represent this kind ofSCMHead
. Must start with a capital letter.- Returns:
- the term or
null
to fall back to the calling context's default. - Since:
- 2.0
-
equals
Indicates whether some other object is "equal to" this one. TwoSCMHeadMixin
implementations are equal if and only if:- They both are the same class
- They both have the same
SCMHeadMixin.getName()
- For each implemented
SCMHeadMixin
sub-interface, they both return the same values from all Java Bean property getters declared on the sub-interface. Thus, for exampleChangeRequestSCMHead
implementations are only considered equal ifChangeRequestSCMHead.getId()
andChangeRequestSCMHead.getTarget()
are also equal
By way of example, any implementation of
ChangeRequestSCMHead
will have their equals behave like so:public static class MyChangeRequestSCMHead extends SCMHead implements ChangeRequestSCMHead { //... // this method is implemented for you, but if you had to write it this is what you would // have to write public boolean equals(Object o) { if (!super.equals(o)) { return false; } // can only be equal if they are the same class MyChangeRequestSCMHead that = (MyChangeRequestSCMHead)o; // because we implement ChangeRequestSCMHead and ChangeRequestSCMHead has a getId() method String id1 = this.getId(); String id2 = that.getId(); if (id1 == null ? id2 != null : !id1.equals(id2)) { return false; } // because we implement ChangeRequestSCMHead and ChangeRequestSCMHead has a getTarget() method SCMHead t1 = this.getTarget(); SCMHead t2 = that.getTarget(); if (t1 == null ? t2 != null : !t1.equals(t2)) { return false; } // we do not implement any other interfaces extending SCMHeadMixin, so we must be equal return true; } }
-
hashCode
public final int hashCode() -
compareTo
- Specified by:
compareTo
in interfaceComparable<SCMHead>
-
toString
-
getAllActions
@Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @Deprecated @NonNull public List<? extends Action> getAllActions()Deprecated.this was added to the API in error. Retained for backwards binary compatibility only. UseSCMSource.fetchActions(SCMHead, SCMHeadEvent, TaskListener)
to get the actions associated with aSCMHead
Returns an empty list.- Returns:
- an empty list
- Since:
- 1.1
-
getAction
@Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @Deprecated @CheckForNull public <T extends Action> T getAction(@NonNull Class<T> type) Deprecated.this was added to the API in error. Retained for backwards binary compatibility only. UseSCMSource.fetchActions(SCMHead, SCMHeadEvent, TaskListener)
to get the actions associated with aSCMHead
Returnsnull
.- Type Parameters:
T
- a desired action type to query, such asChangeRequestAction
- Parameters:
type
- type token- Returns:
null
- Since:
- 1.1
-