Java Code Examples for org.openide.util.Parameters#notNull()

The following examples show how to use org.openide.util.Parameters#notNull() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiModuleJavadocForBinaryQueryImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public MultiModuleJavadocForBinaryQueryImpl(
        @NonNull final AntProjectHelper helper,
        @NonNull final PropertyEvaluator evaluator,
        @NonNull final MultiModule modules,
        @NonNull final String[] binaryProperties,
        @NonNull final String javadocProperty) {
    Parameters.notNull("helper", helper);                       //NOI18N
    Parameters.notNull("evaluator", evaluator);                 //NOI18N
    Parameters.notNull("modules", modules);                     //NOI18N
    Parameters.notNull("binaryProperties", binaryProperties);   //NOI18N
    Parameters.notNull("javadocProperty", javadocProperty);     //NOI18N
    this.helper = helper;
    this.evaluator = evaluator;
    this.modules = modules;
    this.binaryProperties = binaryProperties;
    this.javadocProperty = javadocProperty;
    this.cache = new ConcurrentHashMap<>();
    this.evaluator.addPropertyChangeListener(WeakListeners.propertyChange(this, this.evaluator));
    this.modules.addPropertyChangeListener(WeakListeners.propertyChange(this, this.modules));
}
 
Example 2
Source File: FixFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Creates a fix, which when invoked removes a set of modifiers from the existing ones
 * @param compilationInfo CompilationInfo to work on
 * @param treePath TreePath to a ModifiersTree.
 * @param toRemove set of Modifiers to remove
 * @param text text displayed as a fix description
 */
public static final Fix removeModifiersFix(CompilationInfo compilationInfo, TreePath treePath, Set<Modifier> toRemove, String text) {
    Parameters.notNull("compilationInfo", compilationInfo);
    Parameters.notNull("treePath", treePath);
    Parameters.notNull("toRemove", toRemove);
    Parameters.notNull("text", text);

    return changeModifiersFix(compilationInfo, treePath, Collections.<Modifier>emptySet(), toRemove, text);
}
 
Example 3
Source File: FileElementQuery.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public MethodElement create(final TypeElement type, final MethodDeclaration node) {
    Parameters.notNull("type", type); //NOI18N
    Parameters.notNull("node", node); //NOI18N
    MethodElement retval = MethodElementImpl.fromNode(type, node, this);
    addElement(retval);
    return retval;
}
 
Example 4
Source File: ClassPathProviderImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Sets module path properties.
 * @param modulePathProperties  the names of properties containing the module path, by default {@link ProjectProperties#JAVAC_MODULEPATH}
 * @return {@link Builder}
 * @since 1.77
 */
@NonNull
public Builder setModulepathProperties(@NonNull final String[] modulePathProperties) {
    Parameters.notNull("modulePathProperties", modulePathProperties);
    this.modulePath = Arrays.copyOf(modulePathProperties, modulePathProperties.length);
    return this;
}
 
Example 5
Source File: PlatformProvidersListener.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Fire an event in property of the given platform provider.
 * @param project project which properties has changed, can be {@code null} if the property is not project specific
 * @param platformProvider platform provider which properties has changed
 * @param event information about property change
 */
public void firePropertyChanged(@NullAllowed Project project, @NonNull PlatformProvider platformProvider, @NonNull PropertyChangeEvent event) {
    Parameters.notNull("platformProvider", platformProvider); // NOI18N
    Parameters.notNull("event", event); // NOI18N
    for (PlatformProvidersListener listener : listeners) {
        listener.propertyChanged(project, platformProvider, event);
    }
}
 
Example 6
Source File: ModuleClassPaths.java    From netbeans with Apache License 2.0 5 votes vote down vote up
PlatformModulePath(
        @NonNull final PropertyEvaluator eval,
        @NonNull final String platformType) {
    Parameters.notNull("evel", eval);   //NOI18N
    Parameters.notNull("platformType", platformType);   //NOI18N
    this.eval = eval;
    this.platformType = platformType;
    this.eval.addPropertyChangeListener(WeakListeners.propertyChange(this, this.eval));
    final JavaPlatformManager jpm = JavaPlatformManager.getDefault();
    jpm.addPropertyChangeListener(WeakListeners.propertyChange(this, jpm));
}
 
Example 7
Source File: ErrorDescriptionFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Acquires read lock on the provided document to assure consistency
 */
public static @NonNull ErrorDescription createErrorDescription(@NonNull Severity severity, @NonNull String description, @NonNull Document doc, @NonNull Position start, @NonNull Position end) {
    Parameters.notNull("severity", severity);
    Parameters.notNull("description", description);
    Parameters.notNull("doc", doc);
    Parameters.notNull("start", start);
    Parameters.notNull("end", end);
    
    return createErrorDescription(severity, description, new StaticFixList(), doc, start, end);
}
 
Example 8
Source File: DropGlassPane.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Stores the original glass pane on given tree.
 * @param source the active container
 * @param pane the original glass
 * @param visible was glass pane visible
 */
static void setOriginalPane(JComponent source, Component pane, boolean visible) {
    if (oldPane != null) {
        throw new IllegalStateException("Original pane already present");
    }
    Parameters.notNull("source", source);
    Parameters.notNull("pane", pane);
    oldPane = pane;
    originalSource = source;
    wasVisible = visible;
}
 
Example 9
Source File: ClusteredIndexables.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void attach(
    @NonNull final String mode,
    @NonNull final ClusteredIndexables ci) {
    Parameters.notNull("mode", mode);   //NOI18N
    Parameters.notNull("ci", ci);       //NOI18N
    if (TransientUpdateSupport.isTransientUpdate()) {
        return;
    }
    if (DELETE.equals(mode)) {
        ensureNotReBound(this.deleteIndexables, ci);
        if (!ci.equals(this.deleteIndexables)) {
            this.deleteIndexables = ci;
            attachDeleteStackTrace = Pair.<Long,StackTraceElement[]>of(
                    System.nanoTime(),Thread.currentThread().getStackTrace());
            detachDeleteStackTrace = null;
        }
    } else if (INDEX.equals(mode)) {
        ensureNotReBound(this.indexIndexables, ci);
        if (!ci.equals(this.indexIndexables)) {
            this.indexIndexables = ci;
            attachIndexStackTrace = Pair.<Long,StackTraceElement[]>of(
                    System.nanoTime(),Thread.currentThread().getStackTrace());
            detachIndexStackTrace = null;
        }
    } else {
        throw new IllegalArgumentException(mode);
    }
}
 
Example 10
Source File: BrandingSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void setBrandingSource(@NonNull URL brandingSource) {
    Parameters.notNull("brandingSource", brandingSource);
    if (!Utilities.compareObjects(brandingSource, this.brandingSource)) {
        modified = true;
    }
    this.brandingSource = brandingSource;
}
 
Example 11
Source File: SourceModificationEvent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Composite(
        @NonNull final SourceModificationEvent read,
        @NonNull SourceModificationEvent write) {
    super(read.getSource(), true);
    Parameters.notNull("read", read);   //NOI18N
    Parameters.notNull("write", write);   //NOI18N
    this.read = read;
    this.write = write;
}
 
Example 12
Source File: TaskProcessor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
CancelStrategy(
    final @NonNull Parser.CancelReason cancelReason,
    final @NullAllowed Request cancelReplace,
    final boolean callDeprecatedParserCancel) {
    Parameters.notNull("cancelReason", cancelReason);   //NOI18N
    this.cancelReason = cancelReason;
    this.cancelReplace = cancelReplace;
    this.callDeprecatedParserCancel = callDeprecatedParserCancel;
}
 
Example 13
Source File: ProjectConvertorFactoryTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
TestPI(@NonNull final FileObject projectDir) {
    Parameters.notNull("projectDir", projectDir);
    this.projectDir = projectDir;
}
 
Example 14
Source File: ProjectProblemsProviders.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void removePropertyChangeListener(@NonNull final PropertyChangeListener listener) {
    Parameters.notNull("listener", listener);   //NOI18N
    problemsProviderSupport.removePropertyChangeListener(listener);
}
 
Example 15
Source File: WhiteListQuery.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private WhiteList(
    @NonNull final WhiteListImplementation impl) {
    Parameters.notNull("impl", impl);   //NOI18N
    this.impl = impl;
}
 
Example 16
Source File: BaseParserResult.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public final void setErrors(@NonNull final List<? extends FilterableError> errors) {
    Parameters.notNull("errors", errors);   //NOI18N
    this.errors = errors;
}
 
Example 17
Source File: JFXProjectGenerator.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Create a new empty JavaFX project.
 * @param dir the top-level directory (need not yet exist but if it does it must be empty)
 * @param name the name for the project
 * @param librariesDefinition project relative or absolute OS path to libraries definition; can be null
 * @return the helper object permitting it to be further customized
 * @throws IOException in case something went wrong
 */
public static AntProjectHelper createProject(final File dir, final String name, final String mainClass,
        final String fxmlName, final String manifestFile, final String librariesDefinition,
        final String platformName, final String preloader, final WizardType type) throws IOException {
    Parameters.notNull("dir", dir); //NOI18N
    Parameters.notNull("name", name);   //NOI18N
    
    final FileObject dirFO = FileUtil.createFolder(dir);
    // if manifestFile is null => it's TYPE_LIB
    final AntProjectHelper[] h = new AntProjectHelper[1];
    final FileObject[] srcFolder = new FileObject[1];
    dirFO.getFileSystem().runAtomicAction(new FileSystem.AtomicAction() {
        @Override
        public void run() throws IOException {
            h[0] = createProject(dirFO, name, "src", "test", mainClass, manifestFile, //NOI18N
                    librariesDefinition, platformName, preloader, type);
            final Project p = ProjectManager.getDefault().findProject(dirFO);
            JFXProjectUtils.createJfxExtension(p, dirFO, type);
            ProjectManager.getDefault().saveProject(p);
            if(type != WizardType.SWING) {
                JFXGeneratedFilesHelper.generateBuildScriptFromStylesheet(h[0],
                    GeneratedFilesHelper.BUILD_XML_PATH,
                    JFXProjectGenerator.class.getResource("resources/build.xsl")); //NOI18N
            }
            final ReferenceHelper refHelper = getReferenceHelper(p);
            try {
                ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
                    @Override
                    public Void run() throws Exception {
                        copyRequiredLibraries(h[0], refHelper);
                        return null;
                    }
                });
            } catch (MutexException ex) {
                Exceptions.printStackTrace(ex.getException());
            }
            srcFolder[0] = dirFO.createFolder("src"); // NOI18N
        }
    });
    if (srcFolder[0] != null) {
        createFiles(mainClass, fxmlName, srcFolder[0], type);
    }
    return h[0];
}
 
Example 18
Source File: RenameRefactoring.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Setter for property newName
 * @param newName New value of property newName
 */
public void setNewName(@NonNull String newName) {
    Parameters.notNull("newName", newName); // NOI18N
    this.newName = newName;
}
 
Example 19
Source File: FoldOperation.java    From netbeans with Apache License 2.0 3 votes vote down vote up
/**
 * Adds a fold to the hierarchy.
 * The description and the guarded start/end is taken from the 'template' FoldTemplate. As the fold template display
 * is the most common override, the override string can be passed in 'displayOverride' (and will be used instead
 * of template and instead of type's template).
 * <p/>
 * The collapsed state can be prescribed, but can {@code null} can be passed to indicate the infrastructure should
 * assign collapsed state based on e.g. user preferences. The exact assignment algorithm is left unspecified. Callers
 * are recommended not to assign collapsed/expanded state explicitly.
 * <p/>
 * Usually, it's OK to pass null for collapsed, template and possibly extraInfo.
 * <p/>
 * Events produced by this add- call will be fired when the 'transaction' is committed. However fold hierarch will
 * be changed immediately.
 * 
 * @param type type of the fold, cannot be {@code null}
 * @param startOffset starting offset
 * @param endOffset end offset
 * @param collapsed the initial collapsed state; if {@code null}, the state will be assigned automatically.
 * @param template the FoldTemplate to use instead of default template of the type. {@code null}, if the type's template should be used.
 * @param extraInfo arbitrary extra information specific for the fold being created.
 *  It's not touched or used by the folding infrastructure in any way.
 *  <code>null<code> can be passed if there is no extra information.
 *  <br>
 *  The extra info of the existing fold can be obtained by
 *  {@link #getExtraInfo(org.netbeans.api.editor.fold.Fold)}.
 * @param transaction the transaction that manages events, cannot be null.
 * @return the created Fold instance
 * @throws BadLocationException 
 * @since 1.35
 */
public Fold addToHierarchy(
        FoldType type, 
        int startOffset, int endOffset,
        Boolean collapsed,
        FoldTemplate template, String displayOverride, 
        Object extraInfo, FoldHierarchyTransaction transaction) 
        throws BadLocationException {
    Parameters.notNull("type", type);
    Parameters.notNull("transaction", transaction);

    boolean c;
    if (collapsed == null) {
        c = impl.getInitialState(type);
    } else {
        c = collapsed;
    }
    if (template == null) {
        template = type.getTemplate();
    }
    if (displayOverride == null) {
        displayOverride = template.getDescription();
    }
    Fold fold = impl.createFold(type, displayOverride, 
            c, startOffset, endOffset, template.getGuardedStart(),
            template.getGuardedEnd(), extraInfo);
    impl.addToHierarchy(fold, transaction.getImpl());
    return fold;
}
 
Example 20
Source File: AnnotationParser.java    From netbeans with Apache License 2.0 3 votes vote down vote up
/**
 * States that the parsed annotation contains an annotation element. The value
 * of the element will be available in the parse result as the result
 * of the invocation of the <code>AnnotationValueHandler</code> passed in the
 * <code>handler</code> parameter.
 *
 * @param  name the element name.
 * @param  annotationType a {@link TypeMirror} specifying the annotation type.
 * @param  handler an {@link AnnotationValueHandler} which will be invoked to compute
 *         and return a value that represents the element.
 * @param  defaultProvider a {@link DefaultProvider} for the default value or null.
 */
public void expectAnnotation(String name, TypeMirror annotationType, AnnotationValueHandler handler, DefaultProvider defaultProvider) {
    Parameters.notNull("name", name); // NOI18N
    Parameters.notNull("annotationType", annotationType); // NOI18N
    Parameters.notNull("handler", handler); // NOI18N
    addProvider(name, new AnnotationValueProvider(annotationType, handler, defaultProvider));
}