@ExportedBean public class SCMHead extends Object implements SCMHeadMixin
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:
SCMHeadMixin.getName()
SCMHeadMixin
sub-interface, they both return the same values from all Java
Bean property getters declared on the sub-interface. Thus, for example ChangeRequestSCMHead
implementations are only considered equal if ChangeRequestSCMHead.getId()
and
ChangeRequestSCMHead.getTarget()
are also equalObject.hashCode()
is:
Object.hashCode()
for a SCMHeadMixin
implementation must be equal to the
String.hashCode()
of SCMHeadMixin.getName()
equals(Object)
and hashCode()
methods enforce the above requirements and
are final.Modifier and Type | Class and Description |
---|---|
static class |
SCMHead.HeadByItem
Means of locating a head given an item.
|
SCMHeadMixin.Equality
Modifier and Type | Field and Description |
---|---|
static AlternativeUiTextProvider.Message<SCMHead> |
PRONOUN
Replaceable pronoun of that points to a
SCMHead . |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(SCMHead o) |
boolean |
equals(Object o)
Indicates whether some other object is "equal to" this one.
|
<T extends Action> |
getAction(Class<T> type)
Deprecated.
this was added to the API in error. Retained for backwards binary compatibility only. Use
SCMSource.fetchActions(SCMHead, SCMHeadEvent, TaskListener) to get the actions associated with a
SCMHead |
List<? extends Action> |
getAllActions()
Deprecated.
this was added to the API in error. Retained for backwards binary compatibility only. Use
SCMSource.fetchActions(SCMHead, SCMHeadEvent, TaskListener) to get the actions associated with a
SCMHead |
String |
getName()
Returns the name.
|
SCMHeadOrigin |
getOrigin()
Returns the origin of the head.
|
String |
getPronoun()
Get the term used in the UI to represent this kind of
SCMHead . |
int |
hashCode() |
String |
toString() |
public static final AlternativeUiTextProvider.Message<SCMHead> PRONOUN
SCMHead
. Defaults to null
depending on the context.public SCMHead(@NonNull String name)
name
- the name.@Exported @NonNull public String getName()
getName
in interface SCMHeadMixin
@Exported @NonNull public SCMHeadOrigin getOrigin()
SCMHeadOrigin.DEFAULT
.
SCMHeadOrigin.DEFAULT
or instances of SCMHeadOrigin.Fork
.
getOrigin
in interface SCMHeadMixin
SCMHeadOrigin.DEFAULT
if there can only ever be one origin.@CheckForNull public String getPronoun()
SCMHead
. Must start with a capital letter.null
to fall back to the calling context's default.public final boolean equals(Object o)
SCMHeadMixin
implementations are equal if and only if:
SCMHeadMixin.getName()
SCMHeadMixin
sub-interface, they both return the same values from all Java
Bean property getters declared on the sub-interface. Thus, for example ChangeRequestSCMHead
implementations are only considered equal if ChangeRequestSCMHead.getId()
and
ChangeRequestSCMHead.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; } }
public int compareTo(SCMHead o)
compareTo
in interface Comparable<SCMHead>
@Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) @Deprecated @NonNull public List<? extends Action> getAllActions()
SCMSource.fetchActions(SCMHead, SCMHeadEvent, TaskListener)
to get the actions associated with a
SCMHead
@Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) @Deprecated @CheckForNull public <T extends Action> T getAction(@NonNull Class<T> type)
SCMSource.fetchActions(SCMHead, SCMHeadEvent, TaskListener)
to get the actions associated with a
SCMHead
null
.T
- a desired action type to query, such as ChangeRequestAction
type
- type tokennull
Copyright © 2016–2022. All rights reserved.