Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-43507] Document that overriders must invoke the parent
(If they don't we could get class cast exceptions)
  • Loading branch information
stephenc committed Jun 14, 2017
1 parent 1250284 commit 0b6a184
Showing 1 changed file with 7 additions and 0 deletions.
Expand Up @@ -25,6 +25,7 @@
package jenkins.scm.api.trait;

import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.OverrideMustInvoke;
import hudson.model.Descriptor;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
Expand Down Expand Up @@ -115,6 +116,7 @@ protected SCMHeadAuthorityDescriptor() {
* @param head the {@link SCMHead}.
* @return {@code true} if applicable.
*/
@OverrideMustInvoke
public boolean isApplicableToHead(@NonNull SCMHead head) {
return isApplicableToHead(head.getClass()) && isApplicableToOrigin(head.getOrigin());
}
Expand All @@ -125,6 +127,7 @@ public boolean isApplicableToHead(@NonNull SCMHead head) {
* @param headClass the type of {@link SCMHead}.
* @return {@code true} if applicable.
*/
@OverrideMustInvoke
public boolean isApplicableToHead(@NonNull Class<? extends SCMHeadMixin> headClass) {
return this.headClass.isAssignableFrom(headClass);
}
Expand All @@ -135,6 +138,7 @@ public boolean isApplicableToHead(@NonNull Class<? extends SCMHeadMixin> headCla
* @param revision the {@link SCMRevision}.
* @return {@code true} if applicable.
*/
@OverrideMustInvoke
public boolean isApplicableToRevision(@NonNull SCMRevision revision) {
return isApplicableToHead(revision.getHead()) && isApplicableToRevision(revision.getClass());
}
Expand All @@ -145,6 +149,7 @@ public boolean isApplicableToRevision(@NonNull SCMRevision revision) {
* @param revisionClass the type of {@link SCMRevision}.
* @return {@code true} if applicable.
*/
@OverrideMustInvoke
public boolean isApplicableToRevision(@NonNull Class<? extends SCMRevision> revisionClass) {
return this.revisionClass.isAssignableFrom(revisionClass);
}
Expand All @@ -155,6 +160,7 @@ public boolean isApplicableToRevision(@NonNull Class<? extends SCMRevision> revi
* @param request the {@link SCMSourceRequest}.
* @return {@code true} if applicable.
*/
@OverrideMustInvoke
public boolean isApplicableToRequest(@NonNull SCMSourceRequest request) {
return requestClass.isInstance(request);
}
Expand All @@ -165,6 +171,7 @@ public boolean isApplicableToRequest(@NonNull SCMSourceRequest request) {
* @param requestClass the type of {@link SCMSourceRequest}.
* @return {@code true} if applicable.
*/
@OverrideMustInvoke
public boolean isApplicableToRequest(@NonNull Class<? extends SCMSourceRequest> requestClass) {
return this.requestClass.isAssignableFrom(requestClass);
}
Expand Down

0 comments on commit 0b6a184

Please sign in to comment.