Java Code Examples for org.openide.util.Parameters#notEmpty()
The following examples show how to use
org.openide.util.Parameters#notEmpty() .
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: EntityManagerGenerationStrategySupport.java From netbeans with Apache License 2.0 | 6 votes |
/** * Gets the variable tree representing the first field of the given type in * our class. * * @param fieldTypeFqn the fully qualified name of the field's type. * @return the variable tree or null if no matching field was found. */ protected VariableTree getField(final String fieldTypeFqn){ Parameters.notEmpty("fieldTypeFqn", fieldTypeFqn); //NOI18N for (Tree member : getClassTree().getMembers()){ if (Tree.Kind.VARIABLE == member.getKind()){ VariableTree variable = (VariableTree) member; TreePath path = getWorkingCopy().getTrees().getPath(getWorkingCopy().getCompilationUnit(), variable); TypeMirror variableType = getWorkingCopy().getTrees().getTypeMirror(path); if (fieldTypeFqn.equals(variableType.toString())){ return variable; } } } return null; }
Example 2
Source File: ProjectHelper.java From jeddict with Apache License 2.0 | 6 votes |
public static FileObject getFolderForPackage(FileObject rootFile, String packageName, boolean create) { Parameters.notEmpty("packageName", packageName); Parameters.notNull("rootFile", rootFile); String relativePkgName = packageName.replace('.', '/'); FileObject folder = rootFile.getFileObject(relativePkgName); if (folder != null) { return folder; } else if (create) { try { return org.openide.filesystems.FileUtil.createFolder(rootFile, relativePkgName); } catch (IOException ex) { Exceptions.printStackTrace(ex); } } return null; }
Example 3
Source File: SourceGroups.java From netbeans with Apache License 2.0 | 6 votes |
/** * Gets the {@link SourceGroup} of the given <code>project</code> which contains the * given <code>fqClassName</code>. * * @param project the project; must not be null. * @param fqClassName the fully qualified name of the class whose * source group to get; must not be empty or null. * @return the source group containing the given <code>fqClassName</code> or <code>null</code> * if the class was not found in the source groups of the project. */ public static SourceGroup getClassSourceGroup(Project project, String fqClassName) { Parameters.notNull("project", project); //NOI18N Parameters.notEmpty("fqClassName", fqClassName); //NOI18N String classFile = fqClassName.replace('.', '/') + ".java"; // NOI18N SourceGroup[] sourceGroups = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); for (SourceGroup sourceGroup : sourceGroups) { FileObject classFO = sourceGroup.getRootFolder().getFileObject(classFile); if (classFO != null) { return sourceGroup; } } return null; }
Example 4
Source File: FileUtils.java From netbeans with Apache License 2.0 | 6 votes |
/** * Recursively unzip the given ZIP archive to the given target directory. * @param zipPath path of ZIP archive to be extracted * @param targetDirectory target directory * @param zipEntryFilter {@link ZipEntryFilter}, can be {@code null} (in such case, all entries are accepted with their original names) * @throws IOException if any error occurs */ public static void unzip(String zipPath, File targetDirectory, ZipEntryFilter zipEntryFilter) throws IOException { Parameters.notEmpty("zipPath", zipPath); // NOI18N Parameters.notNull("targetDirectory", targetDirectory); // NOI18N if (zipEntryFilter == null) { zipEntryFilter = DUMMY_ZIP_ENTRY_FILTER; } try (ZipFile zipFile = new ZipFile(zipPath)) { Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry zipEntry = entries.nextElement(); if (!zipEntryFilter.accept(zipEntry)) { continue; } File destinationFile = new File(targetDirectory, zipEntryFilter.getName(zipEntry)); ensureParentExists(destinationFile); copyZipEntry(zipFile, zipEntry, destinationFile); } } }
Example 5
Source File: RefactoringUtil.java From netbeans with Apache License 2.0 | 6 votes |
public static String getPropertyName(String accessor, TypeMirror returnType, boolean includeSetter) { Parameters.notEmpty("accessor", accessor); //NO18N int prefixLength = getPrefixLength(accessor, includeSetter); String withoutPrefix = accessor.substring(prefixLength); if (withoutPrefix.isEmpty()) { // method name is simply is/get/set return accessor; } char firstChar = withoutPrefix.charAt(0); if (!Character.isUpperCase(firstChar)) { return accessor; } //method property which is prefixed by 'is' but doesn't return boolean if (returnType != null && accessor.startsWith("is") && returnType.getKind() != TypeKind.BOOLEAN) { //NOI18N return accessor; } //check the second char, if its also uppercase, the property name must be preserved if(withoutPrefix.length() > 1 && Character.isUpperCase(withoutPrefix.charAt(1))) { return withoutPrefix; } return Character.toLowerCase(firstChar) + withoutPrefix.substring(1); }
Example 6
Source File: ProjectHelper.java From jeddict with Apache License 2.0 | 6 votes |
/** * Gets the {@link SourceGroup} of the given <code>project</code> which * contains the given <code>fqClassName</code>. * * @param project the project; must not be null. * @param fqClassName the fully qualified name of the class whose source * group to get; must not be empty or null. * @return the source group containing the given <code>fqClassName</code> or * <code>null</code> if the class was not found in the source groups of the * project. */ public static SourceGroup getClassSourceGroup(Project project, String fqClassName) { Parameters.notNull("project", project); //NOI18N Parameters.notEmpty("fqClassName", fqClassName); //NOI18N String classFile = fqClassName.replace('.', '/') + JAVA_EXT_SUFFIX; // NOI18N SourceGroup[] sourceGroups = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); for (SourceGroup sourceGroup : sourceGroups) { FileObject classFO = sourceGroup.getRootFolder().getFileObject(classFile); if (classFO != null) { return sourceGroup; } } return null; }
Example 7
Source File: PhpBaseElement.java From netbeans with Apache License 2.0 | 5 votes |
protected PhpBaseElement(@NonNull String name, @NullAllowed String fullyQualifiedName, @NullAllowed PhpType type, @NullAllowed FileObject file, int offset, @NullAllowed String description) { Parameters.notEmpty("name", name); this.name = name; this.fullyQualifiedName = fullyQualifiedName; this.type = type; this.file = file; this.offset = offset; this.description = description; }
Example 8
Source File: ResizeOption.java From netbeans with Apache License 2.0 | 5 votes |
private ResizeOption( Type type, String displayName, int width, int height, boolean showInToolbar, boolean isDefault ) { Parameters.notEmpty( "displayName", displayName ); //NOI18N Parameters.notNull( "type", type ); //NOI18N this.type = type; this.displayName = displayName; this.width = width; this.height = height; this.showInToolbar = showInToolbar; this.isDefault = isDefault; }
Example 9
Source File: FileUtil.java From netbeans with Apache License 2.0 | 5 votes |
/** Registers specified extension to be recognized as specified MIME type. * If MIME type parameter is null, it cancels previous registration. * Note that you may register a case-sensitive extension if that is * relevant (for example {@literal *.C} for C++) but if you register * a lowercase extension it will by default apply to uppercase extensions * too on Windows. * @param extension the file extension to be registered * @param mimeType the MIME type to be registered for the extension or {@code null} to deregister * @see #getMIMEType(FileObject) * @see #getMIMETypeExtensions(String) */ public static void setMIMEType(String extension, String mimeType) { Parameters.notEmpty("extension", extension); //NOI18N final Map<String, Set<String>> mimeToExtensions = new HashMap<String, Set<String>>(); FileObject userDefinedResolverFO = MIMEResolverImpl.getUserDefinedResolver(); if (userDefinedResolverFO != null) { // add all previous content mimeToExtensions.putAll(MIMEResolverImpl.getMIMEToExtensions(userDefinedResolverFO)); // exclude extension possibly registered for other MIME types for (Set<String> extensions : mimeToExtensions.values()) { extensions.remove(extension); } } if (mimeType != null) { // add specified extension to our structure Set<String> previousExtensions = mimeToExtensions.get(mimeType); if (previousExtensions != null) { previousExtensions.add(extension); } else { mimeToExtensions.put(mimeType, Collections.singleton(extension)); } } if (MIMEResolverImpl.storeUserDefinedResolver(mimeToExtensions)) { MIMESupport.resetCache(); } MIMESupport.freeCaches(); }
Example 10
Source File: RenameItem.java From netbeans with Apache License 2.0 | 5 votes |
public RenameItem(@NonNull String newFqn, @NonNull String oldFqn, Problem problem) { Parameters.notEmpty("newFqn", newFqn); //NO18N Parameters.notEmpty("oldFqn", oldFqn); //NO18N this.newFqn = newFqn; this.oldFqn = oldFqn; myProblem = problem; }
Example 11
Source File: AnnotationCompletionTag.java From netbeans with Apache License 2.0 | 5 votes |
/** * Create new annotation tag with documentation. * @param name tag name; never {@code null} * @param insertTemplate text that it inserted to the source file; never {@code null} * @param documentation documentation of the tag, HTML allowed; can be {@code null} */ public AnnotationCompletionTag(@NonNull String name, @NonNull String insertTemplate, @NullAllowed String documentation) { Parameters.notEmpty("name", name); Parameters.notEmpty("insertTemplate", insertTemplate); this.name = name; this.insertTemplate = insertTemplate; this.documentation = documentation; }
Example 12
Source File: TestRunInfo.java From netbeans with Apache License 2.0 | 5 votes |
/** * Create new information about a test. * @param type type of the test, typically an identifier of the testing provider, can be {@see #UNKNOWN_TYPE unknown} * @param name name of the test * @param className class name, can be {@code null} * @param location location, can be {@code null} */ public TestInfo(String type, String name, @NullAllowed String className, @NullAllowed String location) { Parameters.notEmpty("type", name); Parameters.notEmpty("name", name); this.type = type; this.name = name; this.className = className; this.location = location; }
Example 13
Source File: IndexResult.java From netbeans with Apache License 2.0 | 4 votes |
public String getValue (final String key) { Parameters.notEmpty("key", key); //NOI18N return this.spi.getValue (key); }
Example 14
Source File: JavaIdentifiers.java From jeddict with Apache License 2.0 | 4 votes |
private static void checkFQN(String fqn) { Parameters.notEmpty("fqn", fqn); //NOI18N if (!isValidPackageName(fqn)) { throw new IllegalArgumentException("The given fqn [" + fqn + "] does not represent a fully qualified class name"); //NOI18N } }
Example 15
Source File: TestRunInfo.java From netbeans with Apache License 2.0 | 4 votes |
/** * Set custom parameter. * @param key key of the parameter * @param value value of the parameter */ public void setParameter(String key, Object value) { Parameters.notEmpty("key", key); // NOI18N Parameters.notNull("value", value); // NOI18N parameters.put(key, value); }
Example 16
Source File: JavaIdentifiers.java From netbeans with Apache License 2.0 | 4 votes |
private static void checkFQN(String fqn){ Parameters.notEmpty("fqn", fqn); //NOI18N if (!isValidPackageName(fqn)){ throw new IllegalArgumentException("The given fqn [" + fqn + "] does not represent a fully qualified class name"); //NOI18N } }
Example 17
Source File: Trouble.java From netbeans with Apache License 2.0 | 3 votes |
/** * Constructs a new ComparisonFailure. * @param expected the expected value. * @param actual the actual value. * @param mimeType the mime type for the comparison; must not be <code>null</code> * or an empty String. */ public ComparisonFailure(String expected, String actual, String mimeType) { Parameters.notEmpty("mimeType", mimeType); this.expected = expected; this.actual = actual; this.mimeType = mimeType; }
Example 18
Source File: StringUtils.java From netbeans with Apache License 2.0 | 2 votes |
/** * Decapitalizes first character of the passed input. * <p> * Example: Foobarbaz -> foobarbaz * @param input text to be decapitalized, never null or empty * @return decapitalized input string, never null * @since 2.33 */ public static String decapitalize(String input) { Parameters.notEmpty("input", input); //NOI18N return input.substring(0, 1).toLowerCase() + input.substring(1); }
Example 19
Source File: StringUtils.java From netbeans with Apache License 2.0 | 2 votes |
/** * Capitalizes first character of the passed input. * <p> * Example: foobarbaz -> Foobarbaz * @param input text to be capitalized, never null or empty * @return capitalized input string, never null * @since 2.21 */ public static String capitalize(String input) { Parameters.notEmpty("input", input); //NOI18N return input.substring(0, 1).toUpperCase() + input.substring(1); }
Example 20
Source File: PhpModuleExtender.java From netbeans with Apache License 2.0 | 2 votes |
/** * Constructs a new exception with the specified detail failure message and cause. * @param failureMessage the detail failure message. * @param cause the cause (which is saved for later retrieval by the * {@link #getCause()} method). (A <tt>null</tt> value is permitted, * and indicates that the cause is nonexistent or unknown.) */ public ExtendingException(String failureMessage, Throwable cause) { super(failureMessage, cause); Parameters.notEmpty("failureMessage", failureMessage); }