本文整理匯總了Java中javax.annotation.CheckForNull類的典型用法代碼示例。如果您正苦於以下問題:Java CheckForNull類的具體用法?Java CheckForNull怎麽用?Java CheckForNull使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CheckForNull類屬於javax.annotation包,在下文中一共展示了CheckForNull類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: listFiles
import javax.annotation.CheckForNull; //導入依賴的package包/類
/**
* {@inheritDoc}
* <p>
* Note that archive entries with absolute paths are ignored by this
* method and are never returned.
*/
@Override
@FsAssertion(atomic=YES, consistent=YES, isolated=YES, durable=NOT_APPLICABLE)
public @Nullable TFile[] listFiles(
final @CheckForNull FilenameFilter filter) {
if (null != innerArchive) {
final FsNode entry;
try {
entry = innerArchive.getController()
.node(getAccessPreferences(), getNodeName());
} catch (IOException ex) {
return null;
}
return filter(members(entry), filter);
} else {
return filter(list(file.list(filter)), (FilenameFilter) null);
}
}
示例2: getReportAsToken
import javax.annotation.CheckForNull; //導入依賴的package包/類
@CheckForNull
public ReportToken getReportAsToken(int reportId) {
try {
PreparedStatement statement = connection.prepareStatement(SELECT_REPORT);
statement.setInt(1, reportId);
ResultSet set = statement.executeQuery();
if (set.next()) {
return new ReportToken(reportId, set.getString("reporterid"), set.getString("reportedid"), set.getString("channelid"), set.getString("reason"), set.getString("handleid"), set.getString("handlereason"), set.getInt("status"));
} else {
return null;
}
} catch (SQLException e) {
e.printStackTrace();
return null;
}
}
示例3: TFile
import javax.annotation.CheckForNull; //導入依賴的package包/類
/**
* Constructs a new {@code TFile} instance which uses the given archive
* detector to scan its path name for prospective archive files.
*
* @param file the file object to decorate.
* If this is an instance of this class, most of its fields get
* copied.
* @param detector the archive detector to use for scanning the path name
* for prospective archive files.
* If this parameter is {@code null} and {@code file} is
* an instance of this class, then its archive detector gets used.
* If this parameter is {@code null} and {@code file} is <em>not</em>
* an instance of this class, then the current archive detector gets
* resolved by calling {@code TConfig.current().getArchiveDetector()}.
*/
@ExpertFeature(INJECTING_A_DIFFERENT_DETECTOR_FOR_THE_SAME_PATH_MAY_CORRUPT_DATA)
@SuppressWarnings("AccessingNonPublicFieldOfAnotherObject")
public TFile(final File file, final @CheckForNull TArchiveDetector detector) {
super(file.getPath());
if (file instanceof TFile) {
final TFile that = (TFile) file;
this.file = that.file;
this.detector = that.detector;
if (null == detector || this.detector.equals(detector)) {
this.enclArchive = that.getEnclArchive();
this.nodeName = that.nodeName;
this.innerArchive = that.isArchive() ? this : that.innerArchive;
this.controller = that.controller;
} else {
this.detector = detector;
scan(null);
}
} else {
this.file = file;
this.detector = null != detector ? detector : TConfig.current().getArchiveDetector();
scan(null);
}
assert invariants();
}
示例4: newEntry
import javax.annotation.CheckForNull; //導入依賴的package包/類
/**
* Returns a new {@link JarDriverEntry}, requesting that the data gets
* {@code DEFLATED} if no template is provided.
* This feature strengthens the security level of the authentication
* process and inhibits the use of an unencrypted temporary I/O entry
* (usually a temporary file) in case the sink is not copied from a file
* system entry as its input.
* <p>
* Furthermore, the method {@link JarDriverEntry#clearEncryption()} is
* called in order to prevent adding a redundant encryption layer for the
* individual ZIP entry because this would confuse users, increase the size
* of the resulting archive file and unecessarily heat the CPU.
*/
@Override
public JarDriverEntry newEntry(
final BitField<FsAccessOption> options,
final String name,
final Type type,
final @CheckForNull Entry template) {
final JarDriverEntry entry
= super.newEntry(options.set(COMPRESS), name, type, template);
// Fix for http://java.net/jira/browse/TRUEZIP-176 :
// Entry level encryption is enabled if make.getKeyManager(ENCRYPTED) is true
// OR template is an instance of ZipEntry
// AND ((ZipEntry) template).isEncrypted() is true.
// Now switch off entry level encryption because encryption is already
// provided by the RAES wrapper file format.
entry.clearEncryption();
return entry;
}
示例5: parameters
import javax.annotation.CheckForNull; //導入依賴的package包/類
private static <P extends RaesParameters> P parameters(
final Class<P> type,
@CheckForNull RaesParameters param)
throws RaesParametersException {
while (null != param) {
// Order is important here to support multiple interface implementations!
if (type.isInstance(param)) {
return type.cast(param);
} else if (param instanceof RaesParametersProvider) {
param = ((RaesParametersProvider) param).get(type);
} else {
break;
}
}
throw new RaesParametersException("No suitable RAES parameters available!");
}
示例6: retrieveMergeRequests
import javax.annotation.CheckForNull; //導入依賴的package包/類
private void retrieveMergeRequests(@CheckForNull SCMSourceCriteria criteria, @Nonnull SCMHeadObserver observer, @Nonnull TaskListener listener) throws IOException, InterruptedException {
branchesWithMergeRequestsCache = new HashMap<>();
if (source.getProject().isMergeRequestsEnabled() && source.getSourceSettings().shouldMonitorMergeRequests()) {
log(listener, Messages.GitLabSCMSource_retrievingMergeRequests());
GitLabMergeRequestFilter filter = source.getSourceSettings().createMergeRequestFilter(listener);
for (GitLabMergeRequest mr : filter.filter(api().getMergeRequests(source.getProjectId()))) {
checkInterrupt();
if (!source.isExcluded(mr.getTargetBranch())) {
observe(criteria, observer, mr, listener);
}
}
}
}
示例7: retrieve
import javax.annotation.CheckForNull; //導入依賴的package包/類
@Nonnull
private List<Action> retrieve(@Nonnull SCMRevisionImpl revision, @CheckForNull SCMHeadEvent event, @Nonnull TaskListener listener) throws IOException, InterruptedException {
List<Action> actions = new ArrayList<>();
String hash = revision.getHash();
Action linkAction = GitLabLinkAction.toCommit(source.getProject(), hash);
actions.add(linkAction);
SCMHead head = revision.getHead();
if (head instanceof GitLabSCMMergeRequestHead) {
actions.add(createHeadMetadataAction(head.getName(), ((GitLabSCMMergeRequestHead) head).getSource(), hash, linkAction.getUrlName()));
} else if (head instanceof GitLabSCMHead) {
actions.add(createHeadMetadataAction(head.getName(), (GitLabSCMHead) head, hash, linkAction.getUrlName()));
}
if (event instanceof GitLabSCMEvent) {
actions.add(new GitLabSCMCauseAction(((GitLabSCMEvent) event).getCause()));
}
return actions;
}
示例8: check
import javax.annotation.CheckForNull; //導入依賴的package包/類
/**
* Checks the parameter range.
*
* @param i The integer to check to be in the range of an unsigned short
* integer ({@value SIZE} bits).
* @param subject The subject of the exception message
* - may be {@code null}.
* This should not end with a punctuation character.
* @param error First sentence of the exception message
* - may be {@code null}.
* This should not end with a punctuation character.
* @return {@code true}
* @throws IllegalArgumentException If {@code i} is less than
* {@link #MIN_VALUE} or greater than {@link #MAX_VALUE}.
*/
public static boolean check(
final int i,
final @CheckForNull String subject,
final @CheckForNull String error) {
if (MIN_VALUE <= i && i <= MAX_VALUE) return true;
final StringBuilder message = new StringBuilder();
if (null != subject) message.append(subject).append(": ");
if (null != error) message.append(error).append(": ");
throw new IllegalArgumentException(message
.append(i)
.append(" is not within ")
.append(MIN_VALUE)
.append(" and ")
.append(MAX_VALUE)
.append(" inclusive.")
.toString());
}
示例9: getPollingEnvVars
import javax.annotation.CheckForNull; //導入依賴的package包/類
@Nonnull
public static Map<String, String> getPollingEnvVars(@Nonnull Job<?, ?> job, @CheckForNull Node node) throws EnvInjectException {
final Run<?, ?> lastBuild = job.getLastBuild();
if (lastBuild != null) {
if (EnvInjectPluginHelper.isEnvInjectPluginInstalled()) {
return getEnVars(lastBuild);
}
}
if (node == null) {
return getFallBackMasterNode(job);
}
if (node.getRootPath() == null) {
return getFallBackMasterNode(job);
}
return getDefaultEnvVarsJob(job, node);
}
示例10: output
import javax.annotation.CheckForNull; //導入依賴的package包/類
/**
* Returns an output socket for the given file.
*
* @param file the file to write.
* @param options the options for accessing the file.
* @param template a nullable template from which file attributes shall
* get copied.
* @return An output socket for the given file.
*/
static OutputSocket<?> output(
final BitField<FsAccessOption> options,
final File file,
final @CheckForNull Entry template) {
if (file instanceof TFile) {
final TFile tfile = (TFile) file;
final TFile archive = tfile.getInnerArchive();
if (null != archive)
return archive
.getController()
.output( options,
tfile.getNodeName(),
template);
}
final FsNodePath path = new FsNodePath(file);
return TConfig
.current()
.getManager()
.controller(detector(file), path.getMountPoint())
.output( options.clear(CREATE_PARENTS),
path.getNodeName(),
template);
}
示例11: parameters
import javax.annotation.CheckForNull; //導入依賴的package包/類
/**
* Searches for {@code ZipParameters} of the given type starting from
* the given parameters.
*
* @param <P> the type of the ZIP parameters to search for.
* @param type the type of the ZIP parameters to search for.
* @param param the parameters for starting the search.
* @return The parameters of the given type.
* @throws ZipParametersException if {@code param} is {@code null} or
* no suitable parameters can get found.
*/
static <P extends ZipParameters> P parameters(
final Class<P> type,
@CheckForNull ZipParameters param)
throws ZipParametersException {
while (null != param) {
// Order is important here to support multiple interface implementations!
if (type.isInstance(param)) {
return type.cast(param);
} else if (param instanceof ZipParametersProvider) {
param = ((ZipParametersProvider) param).get(type);
} else {
break;
}
}
throw new ZipParametersException("No suitable ZIP parameters available!");
}
示例12: getAddressForBan
import javax.annotation.CheckForNull; //導入依賴的package包/類
/**
* Convert a text representation to an InetAddress
* It supports IPV4 and IPV6 formats
*
* @param name the address
*
* @return the text converted to an InetAddress
*/
public static InetAddress getAddressForBan(@CheckForNull String hostname) throws InvalidInetAddressException {
if (hostname == null) {
throw new InvalidInetAddressException("null address", null);
}
String name = hostname.trim();
if (name.length() == 0) {
throw new InvalidInetAddressException("empty address", null);
}
//TODO(mmarquez): should we validate address format ??
try {
InetAddress address = InetAddress.getByName(name);
if (address.isLoopbackAddress() || address.isAnyLocalAddress()) {
throw new InvalidInetAddressException("local address: '" + name + "'", null);
}
return address;
}
catch (UnknownHostException ex) {
throw new InvalidInetAddressException("unknown host: '" + name + "'", ex);
}
}
示例13: delegateArguments
import javax.annotation.CheckForNull; //導入依賴的package包/類
@SuppressWarnings("unchecked")
static @CheckForNull Map<String, Object> delegateArguments(@CheckForNull Object delegate) {
if (delegate instanceof UninstantiatedDescribable) {
// TODO JENKINS-45101 getStepArgumentsAsString does not resolve its arguments
// thus delegate.model == null and we cannot inspect DescribableModel.soleRequiredParameter
// thus for, e.g., `junit testResults: '*.xml', keepLongStdio: true` we will get null
return new HashMap<>(((UninstantiatedDescribable) delegate).getArguments());
} else if (delegate instanceof Map) {
Map<String, Object> r = new HashMap<>();
r.putAll((Map) delegate);
r.remove(DescribableModel.CLAZZ);
return r;
} else {
return null;
}
}
示例14: newController
import javax.annotation.CheckForNull; //導入依賴的package包/類
@Override
public FsController newController(
final FsManager context,
final FsModel model,
final @CheckForNull FsController parent) {
return new MockController(model, parent, null);
}
示例15: getMasterNode
import javax.annotation.CheckForNull; //導入依賴的package包/類
@CheckForNull
private static Node getMasterNode() {
final Jenkins jenkins = Jenkins.getInstance();
if (jenkins == null) {
return null;
}
Computer computer = jenkins.toComputer();
if (computer == null) {
return null; //Master can have no executors
}
return computer.getNode();
}