本文整理汇总了Java中edu.umd.cs.findbugs.annotations.CheckForNull类的典型用法代码示例。如果您正苦于以下问题:Java CheckForNull类的具体用法?Java CheckForNull怎么用?Java CheckForNull使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CheckForNull类属于edu.umd.cs.findbugs.annotations包,在下文中一共展示了CheckForNull类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GiteaServer
import edu.umd.cs.findbugs.annotations.CheckForNull; //导入依赖的package包/类
/**
* @param displayName Optional name to use to describe the end-point.
* @param serverUrl The URL of this Bitbucket Server
* @param manageHooks {@code true} if and only if Jenkins is supposed to auto-manage hooks for this end-point.
* @param credentialsId The {@link StandardUsernamePasswordCredentials#getId()} of the credentials to use for
* auto-management of hooks.
*/
@DataBoundConstructor
public GiteaServer(@CheckForNull String displayName, @NonNull String serverUrl, boolean manageHooks,
@CheckForNull String credentialsId) {
this.manageHooks = manageHooks && StringUtils.isNotBlank(credentialsId);
this.credentialsId = manageHooks ? credentialsId : null;
this.serverUrl = GiteaServers.normalizeServerUrl(serverUrl);
this.displayName = StringUtils.isBlank(displayName)
? SCMName.fromUrl(this.serverUrl, COMMON_PREFIX_HOSTNAMES)
: displayName;
}
示例2: setServers
import edu.umd.cs.findbugs.annotations.CheckForNull; //导入依赖的package包/类
/**
* Sets the list of endpoints.
*
* @param servers the list of endpoints.
*/
public synchronized void setServers(@CheckForNull List<? extends GiteaServer> servers) {
Jenkins.getActiveInstance().checkPermission(Jenkins.ADMINISTER);
List<GiteaServer> eps = new ArrayList<>(Util.fixNull(servers));
// remove duplicates and empty urls
Set<String> serverUrls = new HashSet<String>();
for (ListIterator<GiteaServer> iterator = eps.listIterator(); iterator.hasNext(); ) {
GiteaServer endpoint = iterator.next();
String serverUrl = endpoint.getServerUrl();
if (StringUtils.isBlank(serverUrl) || serverUrls.contains(serverUrl)) {
iterator.remove();
continue;
}
serverUrls.add(serverUrl);
}
this.servers = eps;
save();
}
示例3: GiteaSCMFileSystem
import edu.umd.cs.findbugs.annotations.CheckForNull; //导入依赖的package包/类
protected GiteaSCMFileSystem(GiteaConnection connection, GiteaRepository repo, String ref,
@CheckForNull SCMRevision rev) throws IOException {
super(rev);
this.connection = connection;
this.repo = repo;
if (rev != null) {
if (rev.getHead() instanceof PullRequestSCMHead) {
this.ref = ((PullRequestSCMRevision) rev).getOrigin().getHash();
} else if (rev instanceof BranchSCMRevision) {
this.ref = ((BranchSCMRevision) rev).getHash();
} else {
this.ref = ref;
}
} else {
this.ref = ref;
}
}
示例4: checkForDuplicates
import edu.umd.cs.findbugs.annotations.CheckForNull; //导入依赖的package包/类
@CheckForNull
private static FormValidation checkForDuplicates(String value, ModelObject context, ModelObject object) {
for (CredentialsStore store : CredentialsProvider.lookupStores(object)) {
if (!store.hasPermission(CredentialsProvider.VIEW)) {
continue;
}
ModelObject storeContext = store.getContext();
for (Domain domain : store.getDomains()) {
if (CredentialsMatchers.firstOrNull(store.getCredentials(domain), CredentialsMatchers.withId(value))
!= null) {
if (storeContext == context) {
return FormValidation.error("This ID is already in use");
} else {
return FormValidation.warning("The ID ‘%s’ is already in use in %s", value,
storeContext instanceof Item
? ((Item) storeContext).getFullDisplayName()
: storeContext.getDisplayName());
}
}
}
}
return null;
}
示例5: getLinkUri
import edu.umd.cs.findbugs.annotations.CheckForNull; //导入依赖的package包/类
/**
* Gets href value as URI if present otherwise <tt>null</tt>
*
* @param link NetworkLink (never null)
* @return NetworkLink link as URI or <tt>null</tt> if not present
*/
@CheckForNull
public static URI getLinkUri(NetworkLink link) {
TaggedMap links = link.getLink();
if (links != null) {
String href = trimToNull(links, HREF);
if (href != null) {
try {
return new URI(href);
} catch (URISyntaxException e) {
log.warn("Invalid link URI: {}", href, e);
}
}
}
return null;
}
示例6: check
import edu.umd.cs.findbugs.annotations.CheckForNull; //导入依赖的package包/类
@Override
public GitHubPRCause check(GitHubPRTrigger gitHubPRTrigger, GHPullRequest remotePR,
@CheckForNull GitHubPRPullRequest localPR, TaskListener listener) throws IOException {
if (remotePR.getState() == CLOSED) {
return null; // already closed, nothing to check
}
GitHubPRCause cause = null;
String causeMessage = "PR opened";
if (isNull(localPR)) { // new
final PrintStream logger = listener.getLogger();
logger.println(DISPLAY_NAME + ": state has changed (PR was opened)");
cause = new GitHubPRCause(remotePR, causeMessage, false);
}
return cause;
}
示例7: getCredentials
import edu.umd.cs.findbugs.annotations.CheckForNull; //导入依赖的package包/类
/**
* Get the {@link StandardCredentials}.
*
* @return the credentials matching the {@link #credentialsId} or {@code null} is {@code #credentialsId} is blank
* @throws AbortException if no {@link StandardCredentials} matching {@link #credentialsId} is found
*/
@CheckForNull
private StandardCredentials getCredentials() throws AbortException {
if (StringUtils.isBlank(credentialsId)) {
return null;
}
StandardCredentials result = CredentialsMatchers.firstOrNull(
CredentialsProvider.lookupCredentials(StandardCredentials.class,
Jenkins.getInstance(), ACL.SYSTEM, Collections.<DomainRequirement>emptyList()),
CredentialsMatchers.withId(credentialsId)
);
if (result == null) {
throw new AbortException("No credentials found for id \"" + credentialsId + "\"");
}
return result;
}
示例8: getDeploySourceDescriptors
import edu.umd.cs.findbugs.annotations.CheckForNull; //导入依赖的package包/类
/**
* Returns the {@link DeploySourceDescriptor}s that are valid for the specific context.
*
* @param origins the valid origins.
* @param jobType the project type.
* @return the {@link DeploySourceDescriptor}s that are valid for the specific context.
*/
@SuppressWarnings("unused") // used by stapler
@NonNull
public List<DeploySourceDescriptor> getDeploySourceDescriptors(@CheckForNull Set<DeploySourceOrigin> origins,
@CheckForNull Class<? extends AbstractProject>
jobType) {
List<DeploySourceDescriptor> result = new ArrayList<DeploySourceDescriptor>();
if (origins != null) {
for (Descriptor<DeploySource> d : Hudson.getInstance().getDescriptorList(DeploySource.class)) {
if (d instanceof DeploySourceDescriptor) {
DeploySourceDescriptor descriptor = (DeploySourceDescriptor) d;
for (DeploySourceOrigin source : origins) {
if (descriptor.isSupported(source) && descriptor.isApplicable(jobType)) {
if ((isFileTarget() && descriptor.isFileSource())
|| (isDirectoryTarget() && descriptor.isDirectorySource())) {
result.add(descriptor);
}
break;
}
}
}
}
}
return result;
}
示例9: cors
import edu.umd.cs.findbugs.annotations.CheckForNull; //导入依赖的package包/类
public HttpResponse cors(@CheckForNull String accessKey, final HttpResponse resp) {
final MetricsAccessKey key = getAccessKey(accessKey);
return key == null ? resp : new HttpResponse() {
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node)
throws IOException, ServletException {
String origin = req.getHeader("Origin");
if (StringUtils.isNotBlank(origin) && key.isOriginAllowed(origin)) {
rsp.addHeader("Access-Control-Allow-Origin", origin);
rsp.addHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE");
rsp.addHeader("Access-Control-Allow-Headers", "Accept, Authorization");
if ("OPTIONS".equals(req.getMethod())) {
rsp.setStatus(200);
return;
}
}
resp.generateResponse(req, rsp, node);
}
};
}
示例10: delegatePathValidationToTarget
import edu.umd.cs.findbugs.annotations.CheckForNull; //导入依赖的package包/类
/**
* Delegates the final path validation to the {@link DeployTarget}.
*
* @param targetDescriptorId the class name of the {@link DeployTarget} to delegate to.
* @param path the path we believe to be OK.
* @return the results of validation.
*/
protected FormValidation delegatePathValidationToTarget(@CheckForNull String pathName,
@CheckForNull String targetDescriptorId,
@CheckForNull FilePath path)
throws IOException, InterruptedException {
final Jenkins jenkins = Jenkins.getInstance();
if (jenkins != null && path != null) {
Descriptor o = jenkins.getDescriptorByName(targetDescriptorId);
if (o instanceof DeployTargetDescriptor) {
final DeployTargetDescriptor d = (DeployTargetDescriptor) o;
if (d.clazz.getName().equals(targetDescriptorId)) {
return d.validateFilePath(pathName, path);
}
}
}
return FormValidation.ok();
}
示例11: getApplicationFile
import edu.umd.cs.findbugs.annotations.CheckForNull; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
@CheckForNull
public File getApplicationFile(@NonNull Run run) {
File result = null;
if (run.getArtifactsDir().isDirectory()) {
FileSet fileSet = new FileSet();
fileSet.setProject(new Project());
fileSet.setDir(run.getArtifactsDir());
fileSet.setIncludes(getFilePattern());
try {
String[] files = fileSet.getDirectoryScanner().getIncludedFiles();
if (files.length > 0) {
result = new File(run.getArtifactsDir(), files[0]);
}
} catch (BuildException e) {
LOGGER.log(Level.FINE, Messages.WildcardPathDeploySource_CouldNotListFromBuildArtifacts(
getFilePattern(), run), e);
}
}
return result;
}
示例12: notifySuccess
import edu.umd.cs.findbugs.annotations.CheckForNull; //导入依赖的package包/类
/**
* Notifies all the listeners of a successful deployment.
*
* @param host the host that the deployment was for (or {@code null} if the information is not available).
* @param target the target of the deployment (or {@code null} if the information is not available).
* @param event the deployment details.
*/
@SuppressWarnings("unchecked")
public static <S extends DeployHost<S, T>, T extends DeployTarget<T>> void notifySuccess(
@CheckForNull DeployHost<S, T> host,
@CheckForNull DeployTarget<T> target,
@NonNull DeployEvent event) {
final Jenkins jenkins = Jenkins.getInstance();
if (jenkins != null) {
for (DeployListener listener : jenkins.getExtensionList(DeployListener.class)) {
try {
listener.onSuccess(host, target, event);
} catch (Throwable t) {
LOGGER.log(Level.WARNING, "Uncaught exception from " + listener.getClass(), t);
}
}
}
}
示例13: notifyFailure
import edu.umd.cs.findbugs.annotations.CheckForNull; //导入依赖的package包/类
/**
* Notifies all the listeners of a failed deployment.
*
* @param host the host that the deployment was for (or {@code null} if the information is not available).
* @param target the target of the deployment (or {@code null} if the information is not available).
* @param event the deployment details.
*/
public static <S extends DeployHost<S, T>, T extends DeployTarget<T>> void notifyFailure(
@CheckForNull DeployHost<S, T> host,
@CheckForNull DeployTarget<T> target,
@NonNull DeployEvent event) {
final Jenkins jenkins = Jenkins.getInstance();
if (jenkins != null) {
for (DeployListener listener : jenkins.getExtensionList(DeployListener.class)) {
try {
listener.onFailure(host, target, event);
} catch (Throwable t) {
LOGGER.log(Level.WARNING, "Uncaught exception from " + listener.getClass(), t);
}
}
}
}
示例14: accept
import edu.umd.cs.findbugs.annotations.CheckForNull; //导入依赖的package包/类
@Override
protected boolean accept(Path p, @CheckForNull Boolean isDir) {
try {
// throws IAE if invalid
HColumnDescriptor.isLegalFamilyName(Bytes.toBytes(p.getName()));
} catch (IllegalArgumentException iae) {
// path name is an invalid family name and thus is excluded.
return false;
}
try {
return isDirectory(fs, isDir, p);
} catch (IOException ioe) {
// Maybe the file was moved or the fs was disconnected.
LOG.warn("Skipping file " + p +" due to IOException", ioe);
return false;
}
}
示例15: build
import edu.umd.cs.findbugs.annotations.CheckForNull; //导入依赖的package包/类
@Override
public SCMFileSystem build(@NonNull Item owner, @NonNull SCM scm, @CheckForNull SCMRevision rev) throws IOException, InterruptedException {
if (scm == null || !(scm instanceof PerforceScm)) {
return null;
}
PerforceScm p4scm = (PerforceScm) scm;
if (rev != null && !(rev instanceof P4Revision)) {
return null;
}
P4Revision p4rev = (P4Revision) rev;
try {
return new P4SCMFileSystem(owner, p4scm, p4rev);
} catch (Exception e) {
throw new IOException(e);
}
}