Skip to content

Commit

Permalink
EOL JSR 305 (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Jan 24, 2022
1 parent 58f5e20 commit 2a0634a
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import edu.umd.cs.findbugs.annotations.CheckForNull;

import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.IOException;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;

/**
* Role-based authorization via a matrix.
Expand Down Expand Up @@ -96,13 +96,13 @@ public Permission getEditingPermission() {
}

@Override
@Nonnull
@NonNull
public ACL getRootACL() {
return acl;
}

@Override
@Nonnull
@NonNull
public Set<String> getGroups() {
final TreeSet<String> sids = new TreeSet<>(new IdStrategyComparator());
sids.addAll(groupSids);
Expand Down Expand Up @@ -157,13 +157,13 @@ public PermissionScope getPermissionScope() {
return PermissionScope.JENKINS;
}

@Nonnull
@NonNull
public String getDisplayName() {
return Messages.GlobalMatrixAuthorizationStrategy_DisplayName();
}

@Override
public AuthorizationStrategy newInstance(StaplerRequest req, @Nonnull JSONObject formData) throws FormException {
public AuthorizationStrategy newInstance(StaplerRequest req, @NonNull JSONObject formData) throws FormException {
// TODO Is there a way to pull this up into AuthorizationContainerDescriptor and share code with AuthorizationPropertyDescriptor?
GlobalMatrixAuthorizationStrategy gmas = create();
Map<String,Object> data = formData.getJSONObject("data");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import org.kohsuke.accmod.restrictions.DoNotUse;
import org.kohsuke.accmod.restrictions.NoExternalUse;

import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.Set;
import java.util.TreeSet;

Expand All @@ -53,8 +53,8 @@
*/
public class ProjectMatrixAuthorizationStrategy extends GlobalMatrixAuthorizationStrategy {
@Override
@Nonnull
public ACL getACL(@Nonnull Job<?,?> project) {
@NonNull
public ACL getACL(@NonNull Job<?,?> project) {
AuthorizationMatrixProperty amp = project.getProperty(AuthorizationMatrixProperty.class);
if (amp != null) {
return amp.getInheritanceStrategy().getEffectiveACL(amp.getACL(), project);
Expand All @@ -71,7 +71,7 @@ public static ACL inheritingACL(final ACL parent, final ACL child) {
}
return new ACL() {
@Override
public boolean hasPermission(@Nonnull Authentication a, @Nonnull Permission permission) {
public boolean hasPermission(@NonNull Authentication a, @NonNull Permission permission) {
return a.equals(SYSTEM) || child.hasPermission(a, permission) || parent.hasPermission(a, permission);
}
};
Expand All @@ -85,9 +85,9 @@ public ACL getACL(ItemGroup<?> g) {
return getRootACL();
}

@Nonnull
@NonNull
@Override
public ACL getACL(@Nonnull Node node) {
public ACL getACL(@NonNull Node node) {
AuthorizationMatrixNodeProperty property = node.getNodeProperty(AuthorizationMatrixNodeProperty.class);
if (property != null) {
return property.getInheritanceStrategy().getEffectiveACL(property.getACL(), node);
Expand All @@ -96,8 +96,8 @@ public ACL getACL(@Nonnull Node node) {
}

@Override
@Nonnull
public ACL getACL(@Nonnull AbstractItem item) {
@NonNull
public ACL getACL(@NonNull AbstractItem item) {
if (Jenkins.get().getPlugin("cloudbees-folder") != null) { // optional dependency
if (item instanceof AbstractFolder) {
com.cloudbees.hudson.plugins.folder.properties.AuthorizationMatrixProperty p = ((AbstractFolder<?>) item).getProperties().get(com.cloudbees.hudson.plugins.folder.properties.AuthorizationMatrixProperty.class);
Expand All @@ -110,7 +110,7 @@ public ACL getACL(@Nonnull AbstractItem item) {
}

@Override
@Nonnull
@NonNull
public Set<String> getGroups() {
Set<String> r = new TreeSet<>(new IdStrategyComparator());
r.addAll(super.getGroups());
Expand Down Expand Up @@ -141,7 +141,7 @@ protected GlobalMatrixAuthorizationStrategy create() {
}

@Override
@Nonnull
@NonNull
public String getDisplayName() {
return Messages.ProjectMatrixAuthorizationStrategy_DisplayName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;

import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
Expand Down Expand Up @@ -147,12 +147,12 @@ public static void remove(String nodeName) {
@Extension
public static class NodeListenerImpl extends NodeListener {
@Override
protected void onCreated(@Nonnull Node node) {
protected void onCreated(@NonNull Node node) {
record(node);
}

@Override
protected void onDeleted(@Nonnull Node node) {
protected void onDeleted(@NonNull Node node) {
if (!DISABLE) {
remove(node.getNodeName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.kohsuke.accmod.restrictions.DoNotUse;
import org.kohsuke.accmod.restrictions.NoExternalUse;

import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.NonNull;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
Expand Down Expand Up @@ -139,7 +139,7 @@ default String getTypeLabel(String type) throws NoSuchMethodException, Invocatio

// Not used directly by Stapler due to the trailing _ (this prevented method confusion around 1.415).
@Restricted(NoExternalUse.class)
default FormValidation doCheckName_(@Nonnull String value, @Nonnull AccessControlled subject, @Nonnull Permission permission) {
default FormValidation doCheckName_(@NonNull String value, @NonNull AccessControlled subject, @NonNull Permission permission) {

final String unbracketedValue = value.substring(1, value.length() - 1); // remove leading [ and trailing ]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -163,7 +163,7 @@ public PermissionScope getPermissionScope() {
}

@Override
public AuthorizationMatrixNodeProperty newInstance(StaplerRequest req, @Nonnull JSONObject formData) throws FormException {
public AuthorizationMatrixNodeProperty newInstance(StaplerRequest req, @NonNull JSONObject formData) throws FormException {
return createNewInstance(req, formData, false);
}

Expand All @@ -172,7 +172,7 @@ public boolean isApplicable(Class<? extends Node> node) {
return isApplicable();
}

@Nonnull
@NonNull
@Override
public String getDisplayName() {
return Messages.AuthorizationMatrixNodeProperty_DisplayName();
Expand All @@ -195,7 +195,7 @@ public FormValidation doCheckName(@AncestorInPath Computer computer, @QueryParam
@Restricted(NoExternalUse.class)
public static class NodeListenerImpl extends NodeListener {
@Override
protected void onCreated(@Nonnull Node node) {
protected void onCreated(@NonNull Node node) {
AuthorizationStrategy authorizationStrategy = Jenkins.get().getAuthorizationStrategy();
if (authorizationStrategy instanceof ProjectMatrixAuthorizationStrategy) {
ProjectMatrixAuthorizationStrategy strategy = (ProjectMatrixAuthorizationStrategy) authorizationStrategy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.Arrays;

/**
Expand All @@ -46,7 +46,7 @@ public InheritGlobalStrategy() {
}

@Override
protected boolean hasPermission(@Nonnull Authentication a, @Nonnull Permission permission, ACL child, @CheckForNull ACL parent, ACL root) {
protected boolean hasPermission(@NonNull Authentication a, @NonNull Permission permission, ACL child, @CheckForNull ACL parent, ACL root) {
if (a.equals(ACL.SYSTEM)) {
return true;
}
Expand Down Expand Up @@ -81,7 +81,7 @@ public boolean isApplicable(Class<?> clazz) {
}

@Override
@Nonnull
@NonNull
public String getDisplayName() {
return Messages.InheritGlobalStrategy_DisplayName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.Arrays;

/**
Expand All @@ -49,7 +49,7 @@ public InheritParentStrategy() {
}

@Override
protected boolean hasPermission(@Nonnull Authentication a, @Nonnull Permission permission, ACL child, @CheckForNull ACL parent, ACL root) {
protected boolean hasPermission(@NonNull Authentication a, @NonNull Permission permission, ACL child, @CheckForNull ACL parent, ACL root) {
if (a.equals(ACL.SYSTEM)) {
return true;
}
Expand Down Expand Up @@ -84,7 +84,7 @@ public boolean isApplicable(Class<?> clazz) {
}

@Override
@Nonnull
@NonNull
public String getDisplayName() {
return Messages.InheritParentStrategy_DisplayName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;

public abstract class InheritanceStrategy extends AbstractDescribableImpl<InheritanceStrategy> implements ExtensionPoint {
@Restricted(NoExternalUse.class)
Expand Down Expand Up @@ -72,5 +72,5 @@ public ACL getEffectiveACL(final ACL acl, final AccessControlled subject) {
return ACL.lambda((a, p) -> hasPermission(a, p, acl, getParentItemACL(subject), Jenkins.get().getAuthorizationStrategy().getRootACL()));
}

protected abstract boolean hasPermission(@Nonnull Authentication a, @Nonnull Permission permission, ACL child, @CheckForNull ACL parent, ACL root);
protected abstract boolean hasPermission(@NonNull Authentication a, @NonNull Permission permission, ACL child, @CheckForNull ACL parent, ACL root);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.Arrays;

/**
Expand All @@ -47,7 +47,7 @@ public NonInheritingStrategy() {
}

@Override
protected boolean hasPermission(@Nonnull Authentication a, @Nonnull Permission permission, ACL child, @CheckForNull ACL parent, ACL root) {
protected boolean hasPermission(@NonNull Authentication a, @NonNull Permission permission, ACL child, @CheckForNull ACL parent, ACL root) {
if (a.equals(ACL.SYSTEM)) {
return true;
}
Expand Down Expand Up @@ -92,7 +92,7 @@ public boolean isApplicable(Class<?> clazz) {
}

@Override
@Nonnull
@NonNull
public String getDisplayName() {
return Messages.NonInheritingStrategy_DisplayName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;

import javax.annotation.CheckForNull;
import edu.umd.cs.findbugs.annotations.CheckForNull;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;

import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
Expand All @@ -57,7 +57,7 @@ protected AuthorizationMatrixNodeProperty instance(Mapping mapping, Configuratio
}

@Override
@Nonnull
@NonNull
public Set<Attribute<AuthorizationMatrixNodeProperty, ?>> describe() {
return new HashSet<>(Arrays.asList(
new MultivaluedAttribute<AuthorizationMatrixNodeProperty, String>("permissions", String.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;

@Extension(optional = true, ordinal = 2)
@Restricted(NoExternalUse.class)
public class GlobalMatrixAuthorizationStrategyConfigurator extends MatrixAuthorizationStrategyConfigurator<GlobalMatrixAuthorizationStrategy> {

@Override
@Nonnull
@NonNull
public String getName() {
return "globalMatrix";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;

import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
Expand All @@ -23,15 +23,15 @@
@Restricted(NoExternalUse.class)
public abstract class MatrixAuthorizationStrategyConfigurator<T extends AuthorizationContainer> extends BaseConfigurator<T> {

@Nonnull
@NonNull
@Override
public Class<?> getImplementedAPI() {
return AuthorizationStrategy.class;
}


@Override
@Nonnull
@NonNull
public Set<Attribute<T, ?>> describe() {
return new HashSet<>(Arrays.asList(
new MultivaluedAttribute<T, String>("permissions", String.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;

@Extension(optional = true, ordinal = 2)
@Restricted(NoExternalUse.class)
public class ProjectMatrixAuthorizationStrategyConfigurator extends MatrixAuthorizationStrategyConfigurator<ProjectMatrixAuthorizationStrategy> {

@Override
@Nonnull
@NonNull
public String getName() {
return "projectMatrix";
}
Expand Down

0 comments on commit 2a0634a

Please sign in to comment.