• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CheckForNull类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.netbeans.api.annotations.common.CheckForNull的典型用法代码示例。如果您正苦于以下问题:Java CheckForNull类的具体用法?Java CheckForNull怎么用?Java CheckForNull使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CheckForNull类属于org.netbeans.api.annotations.common包,在下文中一共展示了CheckForNull类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: findMainElement

import org.netbeans.api.annotations.common.CheckForNull; //导入依赖的package包/类
@CheckForNull
static ElementHandle<TypeElement> findMainElement(
        @NonNull final CompilationController cc,
        @NonNull final String fileName) {
    final List<? extends TypeElement> topLevels = cc.getTopLevelElements();
    if (topLevels.isEmpty()) {
        return null;
    }
    TypeElement candidate = topLevels.get(0);
    for (int i = 1; i< topLevels.size(); i++) {
        if (fileName.contentEquals(topLevels.get(i).getSimpleName())) {
            candidate = topLevels.get(i);
            break;
        }
    }
    return ElementHandle.create(candidate);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:Resolvers.java


示例2: createKey

import org.netbeans.api.annotations.common.CheckForNull; //导入依赖的package包/类
@CheckForNull
Key createKey(@NonNull final URL rootURL) {
    final URL fileURL = FileUtil.getArchiveFile(rootURL);
    if (fileURL == null) {
        //Not an archive
        return null;
    }
    final FileObject fileFo = URLMapper.findFileObject(fileURL);
    if (fileFo == null) {
        return null;
    }
    return new Key(
        fileFo.toURI(),
        fileFo.lastModified().getTime(),
        fileFo.getSize());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ProfileSupport.java


示例3: parseFQNType

import org.netbeans.api.annotations.common.CheckForNull; //导入依赖的package包/类
public static @CheckForNull TypeMirror parseFQNType(@NonNull CompilationInfo info, @NonNull String spec) {
    if (spec.length() == 0) {
        return null;
    }
    
    TypeElement jlObject = info.getElements().getTypeElement("java.lang.Object");
    
    //XXX:
    TypeElement scope;

    if (info.getTopLevelElements().isEmpty()) {
        scope = jlObject;
    } else {
        scope = info.getTopLevelElements().iterator().next();
    }
    //XXX end
    
    return info.getTreeUtilities().parseType(spec, /*XXX: jlObject*/scope);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:Hacks.java


示例4: findDeclaringSource

import org.netbeans.api.annotations.common.CheckForNull; //导入依赖的package包/类
/**
 * Locate the declaration of an object declared as a newvalue or methodvalue attribute.
 * @param instanceAttribute the result of {@link FileObject#getAttribute} on a {@code literal:*} key
 * @return the source file containing the corresponding declaration, or null if not found
 */
private @CheckForNull FileObject findDeclaringSource(@NullAllowed Object instanceAttribute) {
    if (!(instanceAttribute instanceof String)) {
        return null;
    }
    // XXX this will not find classes in a sister module; maybe look in ClassPath.EXECUTE, then use SFBQ to find it?
    ClassPath src = ClassPath.getClassPath(layer.getLayerFile(), ClassPath.SOURCE); // should work even for Maven src/main/resources/.../layer.xml
    if (src == null) {
        return null;
    }
    String attr = (String) instanceAttribute;
    if (attr.startsWith("new:")) {
        return src.findResource(attr.substring(4).replaceFirst("[$][^.]+$", "").replace('.', '/') + ".java");
    } else if (attr.startsWith("method:")) {
        return src.findResource(attr.substring(7, attr.lastIndexOf('.')).replaceFirst("[$][^.]+$", "").replace('.', '/') + ".java");
    } else {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:Hinter.java


示例5: getOptions

import org.netbeans.api.annotations.common.CheckForNull; //导入依赖的package包/类
@CheckForNull
@Override
public Result getOptions(@NonNull final FileObject file) {
    final FileObject owner = Optional.ofNullable(ClassPath.getClassPath(file, ClassPath.SOURCE))
            .map((cp) -> cp.findOwnerRoot(file))
            .orElse(file);
    ResultImpl res;
    Reference<ResultImpl> resRef = cache.get(owner);
    if (resRef == null || (res = resRef.get()) == null) {
        res = new ResultImpl(owner, lookup);
        if (res.isEmpty()) {
            return null;
        }
        synchronized (cache) {
            ResultImpl prev;
            final Reference<ResultImpl> prevRef = cache.get(owner);
            if (prevRef == null || (prev = prevRef.get()) == null) {
                cache.put(owner, new WeakReference<>(res));
            } else {
                res = prev;
            }
        }
    }
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:CompilerOptionsQueryMerger.java


示例6: silentStartFold

import org.netbeans.api.annotations.common.CheckForNull; //导入依赖的package包/类
/**
 * Similar to {@link #startFold(boolean)}, but no exception is thrown if the
 * fold is already finished, as well as if an unfinished nested fold exists.
 * If an unfinished nested fold exists, it will be finished before creation
 * of the new one.
 *
 * @param expanded True to expand the new fold, false to collapse it, parent
 * folds will not be collapsed/expanded.
 * @return The new fold handle, or null if it cannot be created.
 *
 *  @since openide.io/1.42
 */
public @CheckForNull FoldHandle silentStartFold(boolean expanded) {
    if (!finished) {
        if (currentChild != null && !currentChild.finished) {
            currentChild.silentFinish();
        }
        try {
            return startFold(expanded);
        } catch (IllegalStateException ex) {
            LOG.log(Level.FINE, "Cannot start fold", ex);           //NOI18N
            return null;
        }
    } else {
        LOG.log(Level.FINE, "silentStartFold - already finished");  //NOI18N
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:FoldHandle.java


示例7: getSourceLevel

import org.netbeans.api.annotations.common.CheckForNull; //导入依赖的package包/类
/**
 * Get the source level.
 * @return a source level of the Java file, e.g. "1.3", "1.4", "1.5"
 * or null if the source level is unknown. Even it is allowed for a SPI implementation to return
 *     a source level synonym e.g. "5" for "1.5" the returned value is always normalized.
 */
public @CheckForNull String getSourceLevel() {
    if (delegate.hasFirst()) {
        final String nns = delegate.first().getSourceLevel();
        try {
            return normalize(nns);
        } catch (IllegalArgumentException e) {
            LOGGER.log(
                    Level.WARNING,
                    "#83994: Ignoring bogus source level {0} from {2}",  //NOI18N
                    new Object[] {
                        nns,
                        delegate.first()
                    });
            return null;
        }
    } else {
        return SourceLevelQuery.getSourceLevel(delegate.second());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:SourceLevelQuery.java


示例8: bundlevalue

import org.netbeans.api.annotations.common.CheckForNull; //导入依赖的package包/类
/**
 * Converts a (possibly) localized string attribute in a layer into a value suitable for {@link org.openide.filesystems.annotations.LayerBuilder.File#bundlevalue(String,String)}.
 * @param attribute the result of {@link FileObject#getAttribute} on a {@code literal:*} key
 * @param declaration the declaring element (used to calculate package)
 * @return a string referring to the same (possibly) localized value (may be null)
 */
public @CheckForNull String bundlevalue(@NullAllowed Object attribute, Element declaration) {
    if (attribute instanceof String) {
        String val = (String) attribute;
        if (val.startsWith("bundle:")) {
            PackageElement pkg = findPackage(declaration);
            if (pkg != null) {
                String expected = "bundle:" + pkg.getQualifiedName() + ".Bundle#";
                if (val.startsWith(expected)) {
                    return val.substring(expected.length() - 1); // keep '#'
                }
            }
            return val.substring(7);
        }
        return val;
    } else {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:Hinter.java


示例9: getRoot

import org.netbeans.api.annotations.common.CheckForNull; //导入依赖的package包/类
@CheckForNull
public FileObject getRoot() {
    synchronized (this) {
        if (cachedRoot != null) {
            return cachedRoot;
        }
    }
    final URL root = toURL(rootURI);
    final FileObject _tmp = root == null ?
            null :
            URLMapper.findFileObject(root);
    synchronized (this) {
        if (cachedRoot == null) {
            cachedRoot = _tmp;
        }
    }
    return _tmp;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:JavaTypeProvider.java


示例10: element

import org.netbeans.api.annotations.common.CheckForNull; //导入依赖的package包/类
@CheckForNull
private static Element element(
        @NonNull final TreePath path,
        @NonNull final CompilationInfo  ci) {
    Element e = ci.getTrees().getElement(path);
    if (e == null) {
        return e;
    }
    switch (e.getKind()) {
        case PACKAGE:
        case CLASS:
        case INTERFACE:
        case ENUM:
        case ANNOTATION_TYPE:
        case METHOD:
        case CONSTRUCTOR:
        case INSTANCE_INIT:
        case STATIC_INIT:
        case FIELD:
        case ENUM_CONSTANT:
        case TYPE_PARAMETER:
            return e;
        default:
            return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:AttachSourcePanel.java


示例11: create

import org.netbeans.api.annotations.common.CheckForNull; //导入依赖的package包/类
@CheckForNull
public static BasicSourceFileObject create (
        @NonNull final FileObject file,
        @NonNull final FileObject root) {
    try {
        return new BasicSourceFileObject (
            new Handle(file, root),
            null,
            null,
            false);
    } catch (IOException ioe) {
        if (LOG.isLoggable(Level.SEVERE))
            LOG.log(Level.SEVERE, ioe.getMessage(), ioe);
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:BasicSourceFileObject.java


示例12: runInternal

import org.netbeans.api.annotations.common.CheckForNull; //导入依赖的package包/类
@CheckForNull
private Future<Integer> runInternal(ExecutionDescriptor executionDescriptor, ExecutionDescriptor.InputProcessorFactory2 outProcessorFactory) {
    Parameters.notNull("executionDescriptor", executionDescriptor); // NOI18N
    final String error = ExternalExecutableValidator.validateCommand(executable, executableName);
    if (error != null) {
        if (warnUser) {
            ExternalExecutableUserWarning euw = Lookup.getDefault().lookup(ExternalExecutableUserWarning.class);
            if (euw == null) {
                LOGGER.info("No implementation of "+ExternalExecutableUserWarning.class);
            } else {
                euw.displayError(error, optionsPath);
            }
        }
        return null;
    }
    ProcessBuilder processBuilder = getProcessBuilder();
    executionDescriptor = getExecutionDescriptor(executionDescriptor, outProcessorFactory);
    return ExecutionService.newService(processBuilder, executionDescriptor, getDisplayName()).run();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ExternalExecutable.java


示例13: getModuleName

import org.netbeans.api.annotations.common.CheckForNull; //导入依赖的package包/类
@CheckForNull
private static String getModuleName(
        @NonNull final URI uri,
        final boolean archive) {
    final Path p = Paths.get(uri);
    if (p == null) {
        return null;
    }
    final String nameExt = p.getFileName().toString();
    final int dot = nameExt.lastIndexOf('.');   //NOI18N
    if (dot < 0 || !archive) {
        return nameExt;
    } else if (dot == 0) {
        return null;
    } else {
        return nameExt.substring(0, dot);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:MultiModuleSourceForBinaryQueryImpl.java


示例14: findTestSources

import org.netbeans.api.annotations.common.CheckForNull; //导入依赖的package包/类
@CheckForNull TestSources findTestSources(@NonNull Lookup context, boolean allowFolders) {
    TYPE: for (String testType : project.supportedTestTypes()) {
        FileObject testSrcDir = project.getTestSourceDirectory(testType);
        if (testSrcDir != null) {
            FileObject[] files = ActionUtils.findSelectedFiles(context, testSrcDir, null, true);
            if (files != null) {
                for (FileObject file : files) {
                    if (!(file.hasExt("java") || allowFolders && file.isFolder())) {
                        break TYPE;
                    }
                }
                return new TestSources(files, testType, testSrcDir, null);
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ModuleActions.java


示例15: getReader

import org.netbeans.api.annotations.common.CheckForNull; //导入依赖的package包/类
@CheckForNull
private synchronized IndexReader getReader() throws IOException {
    if (cachedReader == null) {
        try {
            cachedReader = IndexReader.open(getDirectory(),true);
        } catch (FileNotFoundException fnf) {
            //pass - returns null
        }
    }
    return cachedReader;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:MemoryIndex.java


示例16: createNameMatcher

import org.netbeans.api.annotations.common.CheckForNull; //导入依赖的package包/类
@CheckForNull
private static NameMatcher createNameMatcher (
        @NullAllowed final SearchType searchType,
        @NullAllowed final String searchText,
        @NullAllowed final Map<String,Object> options) {
    return (searchText != null && searchType != null) ?
        NameMatcherFactory.createNameMatcher(
                searchText,
                searchType,
                options == null ? Collections.<String,Object>emptyMap() : options) :
        null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:AbstractModelFilter.java


示例17: reduce

import org.netbeans.api.annotations.common.CheckForNull; //导入依赖的package包/类
@CheckForNull
static <T> T reduce(
    @NullAllowed final T initialValue,
    @NonNull final BinaryOperator<T> f,
    @NonNull final Callable<T>... actions) throws ExecutionException, InterruptedException {
    T result = initialValue;
    if (supportsConcurrent()) {
        LOG.log(
            Level.FINE,
            "Using concurrent reduce, {0} workers",    //NOI18N
            PROC_COUNT);
        final Iterable<Future<T>> coResults = RP.invokeAll(Arrays.asList(actions));
        for (Future<T> coResult : coResults) {
            result = f.apply(result, coResult.get());
        }
    } else {
        LOG.log(
            Level.FINE,
            "Using sequential reduce");    //NOI18N
        for (Callable<? extends T> action : actions) {
            try {
                result = f.apply(result, action.call());
            } catch (Exception ex) {
                throw new ExecutionException(ex);
            }
        }
    }
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:JavaIndexerWorker.java


示例18: createModuleSrcFileManager

import org.netbeans.api.annotations.common.CheckForNull; //导入依赖的package包/类
@CheckForNull
private ModuleSourceFileManager createModuleSrcFileManager() {
    if (emitted[SRC_MODULES] == null) {
        final boolean hasModules = !this.srcCached.entries().isEmpty() && this.moduleSrcCached != ClassPath.EMPTY;
        emitted[SRC_MODULES] = hasModules ?
                new ModuleSourceFileManager(
                        srcCached,
                        moduleSrcCached,
                        ignoreExcludes) :
                null;
    }
    return (ModuleSourceFileManager) emitted[SRC_MODULES];
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:ProxyFileManager.java


示例19: findCacheFolderForRoot

import org.netbeans.api.annotations.common.CheckForNull; //导入依赖的package包/类
@Override
@CheckForNull
protected FileObject findCacheFolderForRoot(
        @NonNull final URL root,
        @NonNull final Set<CacheFolderProvider.Kind> kinds,
        @NonNull final CacheFolderProvider.Mode mode) throws IOException {
    final String rootName = root.toExternalForm();
    final FileObject _cacheFolder = getCacheFolder();
    String slice;
    synchronized (this) {
        loadSegments(_cacheFolder);
        slice = invertedSegments.get (rootName);
        if (slice == null) {
            if (mode == Mode.EXISTENT) {
                return null;
            }
            slice = SLICE_PREFIX + (++index);
            while (segments.getProperty(slice) != null) {
                slice = SLICE_PREFIX + (++index);
            }
            segments.put (slice,rootName);
            invertedSegments.put(rootName, slice);
            saver.schedule(SLIDING_WINDOW);
        }
    }
    assert slice != null;
    if (mode == Mode.EXISTENT) {
        return cacheFolder.getFileObject(slice);
    } else {
        return FileUtil.createFolder(_cacheFolder, slice);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:DefaultCacheFolderProvider.java


示例20: getTarget

import org.netbeans.api.annotations.common.CheckForNull; //导入依赖的package包/类
/**
 * Returns the target folder for source root.
 * @param srcRoot the source root to return target folder for
 * @return the target folder
 */
@CheckForNull
public static File getTarget(@NonNull URL srcRoot) {
    BinaryForSourceQuery.Result binaryRoots = BinaryForSourceQuery.findBinaryRoots(srcRoot);

    File result = null;

    for (URL u : binaryRoots.getRoots()) {
        assert u != null : "Null in BinaryForSourceQuery.Result.roots: " + binaryRoots; //NOI18N
        if (u == null) {
            continue;
        }
        File f = FileUtil.archiveOrDirForURL(u);

        try {
            if (FileUtil.isArchiveFile(BaseUtilities.toURI(f).toURL())) {
                continue;
            }

            if (f != null && result != null) {
                Logger.getLogger(CompileOnSaveAction.class.getName()).log(
                        Level.WARNING,
                        "More than one binary directory for root: {0}",
                        srcRoot.toExternalForm());
                return null;
            }

            result = f;
        } catch (MalformedURLException ex) {
            Exceptions.printStackTrace(ex);
        }
    }

    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:CompileOnSaveAction.java



注:本文中的org.netbeans.api.annotations.common.CheckForNull类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ItemTool类代码示例发布时间:2022-05-22
下一篇:
Java OpenOfficeDocumentConverter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap