Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EOL JSR 305 #190

Merged
merged 1 commit into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
import java.util.WeakHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import jenkins.model.Jenkins;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
Expand All @@ -65,7 +65,7 @@ public class FilePathUtils {
* @param f a file, possibly remote
* @return a node name ({@code ""} for the controller), if known, else null
*/
public static @CheckForNull String getNodeNameOrNull(@Nonnull FilePath f) {
public static @CheckForNull String getNodeNameOrNull(@NonNull FilePath f) {
return Listener.getChannelName(f.getChannel());
}

Expand All @@ -75,7 +75,7 @@ public class FilePathUtils {
* @return a node name ({@code ""} for the controller), if known
* @throws IllegalStateException if the association to a node is unknown
*/
public static @Nonnull String getNodeName(@Nonnull FilePath f) throws IllegalStateException {
public static @NonNull String getNodeName(@NonNull FilePath f) throws IllegalStateException {
String name = getNodeNameOrNull(f);
if (name != null) {
return name;
Expand All @@ -90,7 +90,7 @@ public class FilePathUtils {
* @param path a path as returned by {@link FilePath#getRemote}
* @return a corresponding file handle, if a node with that name is online, else null
*/
public static @CheckForNull FilePath find(@Nonnull String node, @Nonnull String path) {
public static @CheckForNull FilePath find(@NonNull String node, @NonNull String path) {
Jenkins j = Jenkins.getInstanceOrNull();
if (j == null) {
return null;
Expand All @@ -113,7 +113,7 @@ private FilePathUtils() {}

private static final Map<VirtualChannel,String> channelNames = Collections.synchronizedMap(new WeakHashMap<>());

static String getChannelName(@Nonnull VirtualChannel channel) {
static String getChannelName(@NonNull VirtualChannel channel) {
String channelName = channelNames.get(channel);

if (channelName == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.apache.commons.collections.CollectionUtils;
import org.jenkinsci.plugins.structs.describable.DescribableModel;
import org.jenkinsci.plugins.structs.describable.UninstantiatedDescribable;
Expand Down Expand Up @@ -131,7 +131,7 @@ public String getUrlName() {
* supplied in the executed pipeline step if that value is filtered for size or security.
* @return The arguments for the {@link Step} as with {@link StepDescriptor#defineArguments(Step)}
*/
@Nonnull
@NonNull
public Map<String,Object> getArguments() {
Map<String,Object> args = getArgumentsInternal();
if (args.isEmpty()) {
Expand All @@ -147,8 +147,8 @@ public Map<String,Object> getArguments() {
*
* @param n FlowNode to fetch Step arguments for (including placeholders for masked values).
*/
@Nonnull
public static Map<String,Object> getArguments(@Nonnull FlowNode n) {
@NonNull
public static Map<String,Object> getArguments(@NonNull FlowNode n) {
ArgumentsAction aa = n.getPersistentAction(ArgumentsAction.class);
return aa != null ? aa.getArguments() : Collections.emptyMap();
}
Expand All @@ -158,7 +158,7 @@ public static Map<String,Object> getArguments(@Nonnull FlowNode n) {
* This means the arguments with all {@link NotStoredReason} or null values removed
* @return Map of all completely stored arguments
*/
@Nonnull
@NonNull
public Map<String, Object> getFilteredArguments() {
Map<String, Object> internalArgs = this.getArgumentsInternal();
if (internalArgs.size() == 0) {
Expand All @@ -180,8 +180,8 @@ public Map<String, Object> getFilteredArguments() {
* @param n FlowNode to get arguments for
* @return Map of all completely stored arguments
*/
@Nonnull
public static Map<String, Object> getFilteredArguments(@Nonnull FlowNode n) {
@NonNull
public static Map<String, Object> getFilteredArguments(@NonNull FlowNode n) {
ArgumentsAction act = n.getPersistentAction(ArgumentsAction.class);
return act != null ? act.getFilteredArguments() : Collections.emptyMap();
}
Expand All @@ -190,7 +190,7 @@ public static Map<String, Object> getFilteredArguments(@Nonnull FlowNode n) {
* See {@link StepDescriptor#argumentsToString(Map)} for the rules
*/
@CheckForNull
public static String getStepArgumentsAsString(@Nonnull FlowNode n) {
public static String getStepArgumentsAsString(@NonNull FlowNode n) {
if (n instanceof StepNode) {
StepDescriptor descriptor = ((StepNode) n).getDescriptor();
if (descriptor != null) { // Null if plugin providing descriptor was uninstalled
Expand All @@ -205,7 +205,7 @@ public static String getStepArgumentsAsString(@Nonnull FlowNode n) {
* Return a fast view of internal arguments, without creating immutable wrappers
* @return Internal arguments
*/
@Nonnull
@NonNull
protected abstract Map<String, Object> getArgumentsInternal();

/**
Expand All @@ -215,7 +215,7 @@ public static String getStepArgumentsAsString(@Nonnull FlowNode n) {
* @return Argument value or null if not present/not stored.
*/
@CheckForNull
public Object getArgumentValue(@Nonnull String argumentName) {
public Object getArgumentValue(@NonNull String argumentName) {
Object val = getArgumentValueOrReason(argumentName);
return (val instanceof NotStoredReason) ? null : val;
}
Expand All @@ -226,7 +226,7 @@ public Object getArgumentValue(@Nonnull String argumentName) {
* @return Argument value, null if nonexistent/null, or NotStoredReason if it existed by was masked out.
*/
@CheckForNull
public Object getArgumentValueOrReason(@Nonnull String argumentName) {
public Object getArgumentValueOrReason(@NonNull String argumentName) {
Object ob = getArgumentsInternal().get(argumentName);
if (ob instanceof Map) {
return Collections.unmodifiableMap((Map)ob);
Expand All @@ -246,7 +246,7 @@ public Object getArgumentValueOrReason(@Nonnull String argumentName) {
* @param namedArgs Set of argument name and argument value pairs, as from {@link StepDescriptor#defineArguments(Step)}
* @return True if no argument has a {@link NotStoredReason} placeholder value, else false
*/
static boolean checkArgumentsLackPlaceholders(@Nonnull Map<String,Object> namedArgs) {
static boolean checkArgumentsLackPlaceholders(@NonNull Map<String,Object> namedArgs) {
for(Object ob : namedArgs.values()) {
if (ob instanceof NotStoredReason) {
return false;
Expand Down Expand Up @@ -279,8 +279,8 @@ public boolean isUnmodifiedArguments() {
* You could use {@link UninstantiatedDescribable#getModel} (where available) and {@link DescribableModel#getType} to access live classes.
* Where information is missing, this will just return the best it can.
*/
@Nonnull
public static Map<String, ?> getResolvedArguments(@Nonnull FlowNode n) {
@NonNull
public static Map<String, ?> getResolvedArguments(@NonNull FlowNode n) {
ArgumentsAction aa = n.getPersistentAction(ArgumentsAction.class);
if (aa == null) {
return Collections.emptyMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
import groovy.lang.MissingMethodException;
import groovy.lang.MissingPropertyException;
import hudson.remoting.ProxyException;
import javax.annotation.CheckForNull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import org.codehaus.groovy.control.MultipleCompilationErrorsException;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.NonNull;
import jenkins.model.Jenkins;
import org.apache.commons.io.output.NullOutputStream;

Expand All @@ -42,9 +42,9 @@
*/
public class ErrorAction implements PersistentAction {

private final @Nonnull Throwable error;
private final @NonNull Throwable error;

public ErrorAction(@Nonnull Throwable error) {
public ErrorAction(@NonNull Throwable error) {
if (isUnserializableException(error)) {
error = new ProxyException(error);
} else if (error != null) {
Expand Down Expand Up @@ -93,7 +93,7 @@ private boolean isUnserializableException(@CheckForNull Throwable error) {
return false;
}

public @Nonnull Throwable getError() {
public @NonNull Throwable getError() {
return error;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import hudson.model.Queue;
import org.jenkinsci.plugins.workflow.graph.FlowNode;

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

/**
* Records information for a {@code node} block.
Expand Down Expand Up @@ -57,8 +57,8 @@ public enum QueueState {
* @param node A non-null {@link FlowNode}
* @return The current queue state of the flownode.
*/
@Nonnull
public static QueueState getNodeState(@Nonnull FlowNode node) {
@NonNull
public static QueueState getNodeState(@NonNull FlowNode node) {
WorkspaceAction workspaceAction = node.getPersistentAction(WorkspaceAction.class);
if (workspaceAction != null) {
return QueueState.LAUNCHED;
Expand Down Expand Up @@ -88,7 +88,7 @@ public static QueueState getNodeState(@Nonnull FlowNode node) {
}

@CheckForNull
public static Queue.Item getQueueItem(@Nonnull FlowNode node) {
public static Queue.Item getQueueItem(@NonNull FlowNode node) {
QueueItemAction action = node.getPersistentAction(QueueItemAction.class);
return action != null ? action.itemInQueue() : null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

import org.jenkinsci.plugins.workflow.graph.FlowNode;

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.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
Expand Down Expand Up @@ -86,7 +86,7 @@ public String getTagValue(@CheckForNull String tag) {
* Get the tag-value mappings
* @return Unmodifiable view of tag-value mappings
*/
@Nonnull
@NonNull
public Map<String,String> getTags() {
return Collections.unmodifiableMap(tags);
}
Expand All @@ -97,8 +97,8 @@ public Map<String,String> getTags() {
* Get the set of tag-value mappings for a node
* @return Unmodifiable view of tag-value mappings
*/
@Nonnull
public static Map<String,String> getTags(@Nonnull FlowNode node) {
@NonNull
public static Map<String,String> getTags(@NonNull FlowNode node) {
TagsAction tagAction = node.getAction(TagsAction.class);
return (tagAction == null) ? Collections.emptyMap() : tagAction.getTags();
}
Expand All @@ -110,7 +110,7 @@ public static Map<String,String> getTags(@Nonnull FlowNode node) {
* @return Tag value or null if not set
*/
@CheckForNull
public static String getTagValue(@Nonnull FlowNode node, @CheckForNull String tag) {
public static String getTagValue(@NonNull FlowNode node, @CheckForNull String tag) {
if (tag == null || tag.isEmpty()) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
package org.jenkinsci.plugins.workflow.actions;

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

/**
* Thread name action.
Expand All @@ -32,6 +32,6 @@
*/
public interface ThreadNameAction extends PersistentAction {

@Nonnull
@NonNull
String getThreadName();
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.jenkinsci.plugins.workflow.actions;

import hudson.model.Result;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.jenkinsci.plugins.workflow.graph.FlowNode;

/**
Expand All @@ -13,10 +13,10 @@
* Visualizations should treat FlowNodes with this action as if the FlowNode's result was {@link #result}.
*/
public class WarningAction implements PersistentAction {
private @Nonnull Result result;
private @NonNull Result result;
private @CheckForNull String message;

public WarningAction(@Nonnull Result result) {
public WarningAction(@NonNull Result result) {
this.result = result;
}

Expand All @@ -29,7 +29,7 @@ public WarningAction withMessage(String message) {
return message;
}

public @Nonnull Result getResult() {
public @NonNull Result getResult() {
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import hudson.model.Node;
import hudson.model.labels.LabelAtom;
import java.util.Set;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import jenkins.model.Jenkins;
import org.jenkinsci.plugins.workflow.FilePathUtils;

Expand All @@ -39,18 +39,18 @@
public abstract class WorkspaceAction implements PersistentAction {

/** The {@link Node#getNodeName} of the workspace. */
public abstract @Nonnull String getNode();
public abstract @NonNull String getNode();

/** The {@link FilePath#getRemote} of the workspace. */
public abstract @Nonnull String getPath();
public abstract @NonNull String getPath();

/**
* The {@link Node#getAssignedLabels} of the node owning the workspace.
* {@link Node#getSelfLabel} should be exempted, so this set may be empty in the typical case.
* (Could be reconstructed in most cases via {@link Jenkins#getNode} on {@link #getNode},
* but not for an agent which has since been removed, common with clouds.)
*/
public abstract @Nonnull Set<LabelAtom> getLabels();
public abstract @NonNull Set<LabelAtom> getLabels();

/** Reconstructs the live workspace, if possible. */
public final @CheckForNull FilePath getWorkspace() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import hudson.ExtensionPoint;
import hudson.model.Item;

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

/**
* Provides a way to indirectly register durability settings to apply to pipelines.
Expand All @@ -16,9 +16,9 @@ public interface DurabilityHintProvider extends ExtensionPoint {
int ordinal();

@CheckForNull
FlowDurabilityHint suggestFor(@Nonnull Item x);
FlowDurabilityHint suggestFor(@NonNull Item x);

static @Nonnull FlowDurabilityHint suggestedFor(@Nonnull Item x) {
static @NonNull FlowDurabilityHint suggestedFor(@NonNull Item x) {
int ordinal = Integer.MAX_VALUE;
FlowDurabilityHint hint = GlobalDefaultFlowDurabilityLevel.getDefaultDurabilityHint();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
package org.jenkinsci.plugins.workflow.flow;

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

/**
* Provides hints about just how hard we should try to protect our workflow from failures of the controller.
Expand All @@ -47,7 +47,7 @@ public enum FlowDurabilityHint {

private final String tooltip;

FlowDurabilityHint (boolean useAtomicWrite, boolean persistWithEveryStep, @Nonnull String description, String tooltip) {
FlowDurabilityHint (boolean useAtomicWrite, boolean persistWithEveryStep, @NonNull String description, String tooltip) {
this.atomicWrite = useAtomicWrite;
this.persistWithEveryStep = persistWithEveryStep;
this.description = description;
Expand Down
Loading