本文整理汇总了Java中com.android.annotations.Nullable类的典型用法代码示例。如果您正苦于以下问题:Java Nullable类的具体用法?Java Nullable怎么用?Java Nullable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Nullable类属于com.android.annotations包,在下文中一共展示了Nullable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitMethod
import com.android.annotations.Nullable; //导入依赖的package包/类
@Override
public void visitMethod(@NonNull JavaContext context, @Nullable JavaElementVisitor visitor,
@NonNull PsiMethodCallExpression node, @NonNull PsiMethod method) {
boolean isLayoutInflaterCall = isLayoutInflaterCall(context, node, method);
boolean isViewInflateCall = isInViewCall(context, node, method);
String name = method.getName();
boolean fromMethod = LAYOUTINFLATER_FROM.equals(name);
boolean viewInflateMethod = VIEW_INFLATE.equals(name);
if (isLayoutInflaterCall && fromMethod) {
context.report(ISSUE_LAYOUTINFLATER, node, context.getLocation(node),
"error use system LayoutInflater,should use LayoutInflaterWrapper.");
return;
}
if (viewInflateMethod && isViewInflateCall) {
context.report(ISSUE_VIEW_INFLATE, node, context.getLocation(node),
"error use View.inflate(),should use LayoutInflaterWrapper.inflate.");
return;
}
}
示例2: getCacheFileName
import com.android.annotations.Nullable; //导入依赖的package包/类
@VisibleForTesting
@NonNull
static String getCacheFileName(@NonNull String xmlFileName, @Nullable String platformVersion) {
if (LintUtils.endsWith(xmlFileName, DOT_XML)) {
xmlFileName = xmlFileName.substring(0, xmlFileName.length() - DOT_XML.length());
}
StringBuilder sb = new StringBuilder(100);
sb.append(xmlFileName);
// Incorporate version number in the filename to avoid upgrade filename
// conflicts on Windows (such as issue #26663)
sb.append('-').append(BINARY_FORMAT_VERSION);
if (platformVersion != null) {
sb.append('-').append(platformVersion);
}
sb.append(".bin");
return sb.toString();
}
示例3: getPropertyNoPreview
import com.android.annotations.Nullable; //导入依赖的package包/类
/**
* Utility method to parse the {@link PkgProps#PKG_REVISION} property as a no-preview
* revision (major.minor.micro integers but no preview part.)
*
* @param props The properties to parse.
* @return A {@link NoPreviewRevision} or
* null if there is no such property or it couldn't be parsed.
* @param propKey The name of the property. Must not be null.
*/
@Nullable
public static NoPreviewRevision getPropertyNoPreview(
@Nullable Properties props,
@NonNull String propKey) {
String revStr = getProperty(props, propKey, null);
NoPreviewRevision rev = null;
if (revStr != null) {
try {
rev = NoPreviewRevision.parseRevision(revStr);
} catch (NumberFormatException ignore) {}
}
return rev;
}
示例4: getDevice
import com.android.annotations.Nullable; //导入依赖的package包/类
@Nullable
public Device getDevice(@NonNull String id, @NonNull String manufacturer) {
initDevicesLists();
Device d = getDeviceImpl(mUserDevices, id, manufacturer);
if (d != null) {
return d;
}
d = getDeviceImpl(mSysImgDevices, id, manufacturer);
if (d != null) {
return d;
}
d = getDeviceImpl(mDefaultDevices, id, manufacturer);
if (d != null) {
return d;
}
d = getDeviceImpl(mVendorDevices, id, manufacturer);
return d;
}
示例5: hasHardwarePropHashChanged
import com.android.annotations.Nullable; //导入依赖的package包/类
/**
* Checks whether the the hardware props have changed.
* If the hash is the same, returns null for success.
* If the hash is not the same or there's not enough information to indicate it's
* the same (e.g. if in the future we change the digest method), simply return the
* new hash, indicating it would be best to update it.
*
* @param d The device.
* @param hashV2 The previous saved AvdManager.AVD_INI_DEVICE_HASH_V2 property.
* @return Null if the same, otherwise returns the new and different hash.
*/
@Nullable
public static String hasHardwarePropHashChanged(@NonNull Device d, @NonNull String hashV2) {
Map<String, String> props = getHardwareProperties(d);
String newHash = props.get(AvdManager.AVD_INI_DEVICE_HASH_V2);
// Implementation detail: don't just return the hash and let the caller decide whether
// the hash is the same. That's because the hash contains the digest method so if in
// the future we decide to change it, we could potentially recompute the hash here
// using an older digest method here and still determine its validity, whereas the
// caller cannot determine that.
if (newHash != null && newHash.equals(hashV2)) {
return null;
}
return newHash;
}
示例6: getStyleFromMap
import com.android.annotations.Nullable; //导入依赖的package包/类
/**
* Search for the style in the given map and log an error if the obtained resource is not
* {@link StyleResourceValue}.
*
* @return The {@link ResourceValue} found in the map.
*/
@Nullable
private ResourceValue getStyleFromMap(@NonNull Map<String, ResourceValue> styleMap,
@NonNull String styleName) {
ResourceValue res;
res = styleMap.get(styleName);
if (res != null) {
if (!(res instanceof StyleResourceValue) && mLogger != null) {
mLogger.error(null, String.format(
"Style %1$s is not of type STYLE (instead %2$s)",
styleName, res.getResourceType().toString()),
null);
}
}
return res;
}
示例7: resolveDependencies
import com.android.annotations.Nullable; //导入依赖的package包/类
public Set<AndroidDependency> resolveDependencies(
@NonNull VariantDependencies variantDeps,
@Nullable String testedProjectPath) {
// set of Android Libraries to explode. This only concerns remote libraries, as modules
// are now used through their staging folders rather than their bundled AARs.
// Therefore there is no dependency on these exploded tasks since remote AARs are
// downloaded during the dependency resolution process.
// because they are not immutable (them or the children could be skipped()), we use
// an identity set.
Set<AndroidDependency> libsToExplode = Sets.newIdentityHashSet();
resolveDependencies(
variantDeps,
testedProjectPath,
libsToExplode);
return libsToExplode;
}
示例8: addImage
import com.android.annotations.Nullable; //导入依赖的package包/类
public HtmlBuilder addImage(URL url, @Nullable String altText) {
String link = "";
try {
link = url.toURI().toURL().toExternalForm();
}
catch (Throwable t) {
// pass
}
mStringBuilder.append("<img src='");
mStringBuilder.append(link);
mStringBuilder.append("'");
if (altText != null) {
mStringBuilder.append(" alt=\"");
mStringBuilder.append(altText);
mStringBuilder.append("\"");
}
mStringBuilder.append(" />");
return this;
}
示例9: parse
import com.android.annotations.Nullable; //导入依赖的package包/类
/**
* Parses the XML content from the given input stream.
*
* @param input the input stream containing the XML to be parsed
* @return the corresponding document
* @throws ParserConfigurationException if a SAX parser is not available
* @throws SAXException if the document contains a parsing error
* @throws IOException if something is seriously wrong. This should not
* happen since the input source is known to be constructed from
* a string.
*/
@Nullable
public Document parse(@NonNull InputStream input)
throws ParserConfigurationException, SAXException, IOException {
// Read in all the data
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
while (true) {
int r = input.read(buf);
if (r == -1) {
break;
}
out.write(buf, 0, r);
}
input.close();
return parse(out.toByteArray());
}
示例10: getMinSdkVersion
import com.android.annotations.Nullable; //导入依赖的package包/类
/**
* Returns the value of the minSdkVersion attribute.
* <p/>
* If the attribute is set with an int value, the method returns an Integer object.
* <p/>
* If the attribute is set with a codename, it returns the codename as a String object.
* <p/>
* If the attribute is not set, it returns null.
*
* @param manifestFile the manifest file to read the attribute from.
* @return the attribute value.
* @throws XPathExpressionException
* @throws StreamException If any error happens when reading the manifest.
*/
@Nullable
public static Object getMinSdkVersion(IAbstractFile manifestFile)
throws XPathExpressionException, StreamException {
String result = getStringValue(manifestFile,
"/" + NODE_MANIFEST +
"/" + NODE_USES_SDK +
"/@" + AndroidXPathFactory.DEFAULT_NS_PREFIX +
":" + ATTRIBUTE_MIN_SDK_VERSION);
try {
return Integer.valueOf(result);
} catch (NumberFormatException e) {
return !result.isEmpty() ? result : null;
}
}
示例11: AvdInfo
import com.android.annotations.Nullable; //导入依赖的package包/类
/**
* Creates a new <em>invalid</em> AVD info. Values are immutable.
* <p/>
* Such an AVD is not complete and cannot be used.
* The error string must be non-null.
*
* @param name The name of the AVD (for display or reference)
* @param iniFile The path to the config.ini file
* @param folderPath The path to the data directory
* @param targetHash the target hash
* @param target The target. Can be null, if the target was not resolved.
* @param tag The tag id/display.
* @param abiType Name of the abi.
* @param properties The property map. If null, an empty map will be created.
* @param status The {@link AvdStatus} of this AVD. Cannot be null.
*/
public AvdInfo(@NonNull String name,
@NonNull File iniFile,
@NonNull String folderPath,
@NonNull String targetHash,
@Nullable IAndroidTarget target,
@NonNull IdDisplay tag,
@NonNull String abiType,
@Nullable Map<String, String> properties,
@NonNull AvdStatus status) {
mName = name;
mIniFile = iniFile;
mFolderPath = folderPath;
mTargetHash = targetHash;
mTarget = target;
mTag = tag;
mAbiType = abiType;
mProperties = properties == null ? Collections.<String, String>emptyMap()
: Collections.unmodifiableMap(properties);
mStatus = status;
}
示例12: getMatchingFile
import com.android.annotations.Nullable; //导入依赖的package包/类
/**
* Returns the {@link ResourceFile} matching the given name,
* {@link ResourceFolderType} and configuration.
* <p/>
* This only works with files generating one resource named after the file
* (for instance, layouts, bitmap based drawable, xml, anims).
*
* @param name the resource name or file name
* @param type the folder type search for
* @param config the folder configuration to match for
* @return the matching file or <code>null</code> if no match was found.
*/
@Nullable
public ResourceFile getMatchingFile(
@NonNull String name,
@NonNull ResourceFolderType type,
@NonNull FolderConfiguration config) {
List<ResourceType> types = FolderTypeRelationship.getRelatedResourceTypes(type);
for (ResourceType t : types) {
if (t == ResourceType.ID) {
continue;
}
ResourceFile match = getMatchingFile(name, t, config);
if (match != null) {
return match;
}
}
return null;
}
示例13: extractXmlFilename
import com.android.annotations.Nullable; //导入依赖的package包/类
/**
* Extracts the origin {@link File} that {@link #parseDocument(File, IMergerLog,
* ManifestMerger)} added to the XML document or the string added by
*
* @param xmlNode Any node from a document returned by {@link #parseDocument(File, IMergerLog,
* ManifestMerger)}.
* @return The {@link File} object used to create the document or null.
*/
@Nullable
static String extractXmlFilename(@Nullable Node xmlNode) {
if (xmlNode != null && xmlNode.getNodeType() != Node.DOCUMENT_NODE) {
xmlNode = xmlNode.getOwnerDocument();
}
if (xmlNode != null) {
Object data = xmlNode.getUserData(DATA_ORIGIN_FILE);
if (data instanceof File) {
return ((File) data).getPath();
}
data = xmlNode.getUserData(DATA_FILE_NAME);
if (data instanceof String) {
return (String) data;
}
}
return null;
}
示例14: extractMatcher
import com.android.annotations.Nullable; //导入依赖的package包/类
/**
* Extract non-isDisplayed part or null
*/
@Nullable
private MethodInvocation extractMatcher(JavaContext context, MethodInvocation node) {
// Only 2 items in allOf()?
StrictListAccessor<Expression, MethodInvocation> args = node.astArguments();
if (args == null || args.size() != 2) {
return null;
}
// has isDisplayed()
boolean foundIsDisplayed = false;
MethodInvocation other = null;
for (Expression next : args) {
if (next instanceof MethodInvocation) {
MethodInvocation invocation = (MethodInvocation) next;
if (isNode(context, invocation, MethodDefinitions.IS_DISPLAYED)) {
foundIsDisplayed = true;
} else {
other = invocation;
}
}
}
if (!foundIsDisplayed || other == null) {
return null;
}
return other;
}
示例15: getConfiguredValue
import com.android.annotations.Nullable; //导入依赖的package包/类
@Nullable
public ResourceValue getConfiguredValue(
@NonNull ResourceType type,
@NonNull String name,
@NonNull FolderConfiguration referenceConfig) {
// get the resource item for the given type
ListMultimap<String, ResourceItem> items = getMap(type, false);
if (items == null) {
return null;
}
List<ResourceItem> keyItems = items.get(name);
if (keyItems == null) {
return null;
}
// look for the best match for the given configuration
// the match has to be of type ResourceFile since that's what the input list contains
ResourceItem match = (ResourceItem) referenceConfig.findMatchingConfigurable(keyItems);
return match != null ? match.getResourceValue(mFramework) : null;
}