当前位置: 首页>>代码示例>>Java>>正文


Java CheckForNull类代码示例

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


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


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