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

The following examples show how to use org.openide.util.Parameters#notWhitespace() . 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: JsonFile.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Adds new field to be watched.
 * @param propertyName property name to be fired, e.g. {@code PROP_AUTHOR}
 * @param fieldHierarchy hierarchy of fields, e.g. {@code meta, author} for <tt>content['meta']['author']</tt>
 * @return self
 */
public WatchedFields add(@NonNull String propertyName, @NonNull String... fieldHierarchy) {
    if (data == null) {
        throw new IllegalStateException("Listening to all changes already");
    }
    if (frozen) {
        throw new IllegalStateException("Cannot add no more fields");
    }
    Parameters.notWhitespace("propertyName", propertyName); // NOI18N
    Parameters.notNull("fieldHierarchy", fieldHierarchy); // NOI18N
    int length = fieldHierarchy.length;
    if (length == 0) {
        throw new IllegalArgumentException("No field given");
    }
    String[] field = new String[length];
    System.arraycopy(fieldHierarchy, 0, field, 0, length);
    data.add(Pair.of(propertyName, field));
    return this;
}
 
Example 2
Source File: _RetoucheUtil.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static String convertToJavaIdentifier(String name, String defaultValue) {
    Parameters.notWhitespace("name", name);
    Parameters.notWhitespace("defaultValue", defaultValue);
    String str = name;
    while (str.length() > 0 && !Character.isJavaIdentifierStart(str.charAt(0))) {
        str = str.substring(1);
    }
    StringBuilder result = new StringBuilder();
    if (str.length() > 0) {
        char firstChar = str.charAt(0);
        firstChar = Character.toLowerCase(firstChar);
        result.append(firstChar);
        for (int i = 1; i < str.length(); i++) {
            char character = str.charAt(i);
            if (Character.isJavaIdentifierPart(character)) {
                result.append(character);
            }
        }
    } else {
        result.append(defaultValue);
    }
    return result.toString();
}
 
Example 3
Source File: TestSessionImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "# {0} - provider name",
    "# {1} - suite name",
    "TestSessionImpl.suite.name=[{0}] {1}",
})
@Override
public TestSuite addTestSuite(String name, FileObject location) {
    Parameters.notWhitespace("name", name); // NOI18N
    checkFrozen();
    String suiteName = Bundle.TestSessionImpl_suite_name(testingProvider.getDisplayName(), name);
    org.netbeans.modules.gsf.testrunner.api.TestSuite testSuite = new org.netbeans.modules.gsf.testrunner.api.TestSuite(suiteName);
    testSession.addSuite(testSuite);
    report = testSession.getReport(0);
    manager.displaySuiteRunning(testSession, testSuite);
    return new TestSuiteImpl(this, testSuite, location);
}
 
Example 4
Source File: TestSuiteImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public TestCase addTestCase(String name, String type) {
    checkFrozen();
    checkFinished();
    Parameters.notWhitespace("name", name); // NOI18N
    Parameters.notWhitespace("type", type); // NOI18N
    TestSession session = testSession.getTestSession();
    Testcase testCase = new Testcase(name, type, session);
    if (location != null) {
        testCase.setLocation(FileUtil.toFile(location).getAbsolutePath());
    }
    session.addTestCase(testCase);
    updateReport(0, false);
    return new TestCaseImpl(this, testCase);
}
 
Example 5
Source File: FindJSPServletHelper.java    From netbeans with Apache License 2.0 4 votes vote down vote up
static public String getServletResourcePath(String moduleContextPath, String jspResourcePath) {
    Parameters.notWhitespace("jspResourcePath", jspResourcePath);
    String s = getServletPackageName(jspResourcePath) + '/' +
        getServletClassName(jspResourcePath) + ".java";// NOI18N
    return s;
}
 
Example 6
Source File: FindJSPServletHelper.java    From netbeans with Apache License 2.0 4 votes vote down vote up
static public String getServletResourcePath(String moduleContextPath, String jspResourcePath) {
    Parameters.notWhitespace("jspResourcePath", jspResourcePath);
    String s = getServletPackageName(jspResourcePath) + '/' +
        getServletClassName(jspResourcePath) + ".java";// NOI18N
    return s;
}
 
Example 7
Source File: TestCaseImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void setClassName(String className) {
    Parameters.notWhitespace("className", className); // NOI18N
    testSuite.checkFrozen();
    testCase.setClassName(className);
}
 
Example 8
Source File: NameKind.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static Exact exact(String query) {
    Parameters.notWhitespace("String query: can't be null or empty", query); //NOI18N
    return new Exact(query);
}
 
Example 9
Source File: MethodModel.java    From netbeans with Apache License 2.0 3 votes vote down vote up
/**
 * Creates new instance of method model. None of the parameters can be null.
 * 
 * @param name name of the method, must be valid Java identifier
 * @param returnType name of return type as written in source code,
 * for non-primitive types fully-qualfied name must be used,
 * must contain at least one non-whitespace character
 * @param body string representation of body, can be null
 * @param parameters list of method parameters, can be empty
 * @param exceptions list of exceptions represented by fully-qualified names of exceptions, can be empty
 * @param modifiers list of modifiers of method, can be empty
 * @throws NullPointerException if any of the parameters is <code>null</code>.
 * @throws IllegalArgumentException if the paramter returnType does not contain at least one non-whitespace character
 * or the parameter name is not a valid Java identifier
 * @return immutable model of method
 */
public static MethodModel create(String name, String returnType, String body, List<Variable> parameters, List<String> exceptions, Set<Modifier> modifiers) {
    Parameters.javaIdentifier("name", name);
    Parameters.notWhitespace("returnType", returnType);
    Parameters.notNull("parameters", parameters);
    Parameters.notNull("exceptions", exceptions);
    Parameters.notNull("modifiers", modifiers);
    return new MethodModel(name, returnType, body, parameters, exceptions, modifiers, Collections.<Annotation>emptyList());
}
 
Example 10
Source File: MethodModel.java    From netbeans with Apache License 2.0 3 votes vote down vote up
/**
 * Creates new instance of method model. None of the parameters can be null.
 *
 * @param name name of the method, must be valid Java identifier
 * @param returnType name of return type as written in source code,
 * for non-primitive types fully-qualfied name must be used,
 * must contain at least one non-whitespace character
 * @param body string representation of body, can be null
 * @param parameters list of method parameters, can be empty
 * @param exceptions list of exceptions represented by fully-qualified names of exceptions, can be empty
 * @param modifiers list of modifiers of method, can be empty
 * @param annotations list of {@code Annotations} represented by fully-qualified names of annotations, can be empty
 * @throws NullPointerException if any of the parameters is <code>null</code>.
 * @throws IllegalArgumentException if the paramter returnType does not contain at least one non-whitespace character
 * or the parameter name is not a valid Java identifier
 * @return immutable model of method
 */
public static MethodModel create(String name, String returnType, String body, List<Variable> parameters, List<String> exceptions, Set<Modifier> modifiers,  List<Annotation> annotations) {
    Parameters.javaIdentifier("name", name);
    Parameters.notWhitespace("returnType", returnType);
    Parameters.notNull("parameters", parameters);
    Parameters.notNull("exceptions", exceptions);
    Parameters.notNull("modifiers", modifiers);
    Parameters.notNull("annotations", annotations);
    return new MethodModel(name, returnType, body, parameters, exceptions, modifiers, annotations);
}
 
Example 11
Source File: FoldType.java    From netbeans with Apache License 2.0 3 votes vote down vote up
/**
 * Derives a FoldType which acts as a child of this instance.
 * The FoldType will be treated as a special case of this instance. If A is the returned
 * instance and B is this instance, then A.isKindOf(B) will return true.
 * <p/>
 * 
 * @param code new code for the FoldType
 * @param label human-readable label that describes the FoldType. If {@code null}, the original label will be used.
 * @param template human-readable label that describes the FoldType. If {@code null}, the original template will be used.
 * @return an instance of child FoldType
 * @since 1.35
 */
public FoldType derive(String code, String label, FoldTemplate template) {
    Parameters.notWhitespace("code", code);
    if (template == null) {
        template = this.template;
    }
    return new FoldType(code, label, template, this);
}
 
Example 12
Source File: MethodModel.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 * Creates new instance of a model of class variable or method parameter
 * without final modifier. Same as calling {@link #create(String, String, boolean)}
 * with 3rd argument set to false
 * 
 * @param type name of type as written in source code
 * for non-primitive types fully-qualfied name must be used,
 * must contain at least one non-whitespace character
 * @param name name of the paramter or variable, must be valid Java identifier
 * @throws NullPointerException if any of the parameters is <code>null</code>.
 * @throws IllegalArgumentException if the paramter type does not contain at least one non-whitespace character
 * or the parameter name is not a valid Java identifier
 * @return immutable model of variable or method parameter
 */
public static Variable create(String type, String name) {
    Parameters.notWhitespace("type", type);
    Parameters.javaIdentifier("name", name);
    return new MethodModel.Variable(type, name, false);
}
 
Example 13
Source File: MethodModel.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 * Creates new instance of a model of class variable or method parameter
 * 
 * @param type name of type as written in source code
 * for non-primitive types fully-qualfied name must be used,
 * must contain at least one non-whitespace character
 * @param name name of the paramter or variable, must be valid Java identifier
 * @param finalModifier specifies if variable is final (if it has final modifier)
 * @throws NullPointerException if any of the parameters is <code>null</code>.
 * @throws IllegalArgumentException if the paramter type does not contain at least one non-whitespace character
 * or the parameter name is not a valid Java identifier
 * @return immutable model of variable or method parameter
 */
public static Variable create(String type, String name, boolean finalModifier) {
    Parameters.notWhitespace("type", type);
    Parameters.javaIdentifier("name", name);
    return new MethodModel.Variable(type, name, finalModifier);
}
 
Example 14
Source File: FoldType.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 * Creates an instance of FoldType.
 * The code, label and template parameters will be assigned to the FoldType's properties.
 * 
 * @param code code used to form, e.g. persistent keys for info related to the FoldType. Cannot be {@code null}.
 * @param label human-readable label that identifies the FoldType. Must not be {@code null}.
 * @param template describes how the fold is presented. If {@code null}, {@link FoldTemplate#DEFAULT} will be used.
 * @return FoldType instance
 * @since 1.35
 */
public static FoldType create(String code, String label, FoldTemplate template) {
    Parameters.notWhitespace("code", code);
    Parameters.notWhitespace("label", label);
    return new FoldType(code, label, template, null);
}