Example usage for javax.lang.model SourceVersion isName

List of usage examples for javax.lang.model SourceVersion isName

Introduction

In this page you can find the example usage for javax.lang.model SourceVersion isName.

Prototype

public static boolean isName(CharSequence name) 

Source Link

Document

Returns whether or not name is a syntactically valid qualified name in the latest source version.

Usage

From source file:desi.juan.internal.util.MethodGeneratorUtils.java

public static String buildParamName(String name) throws IllegalNameException {
    if (!SourceVersion.isName(name)) {
        name = name + "Value";
        if (!SourceVersion.isName(name)) {
            throw new IllegalNameException(
                    name + " is not a valid java parameter name, update your RAML file so it can be parsed.");
        }/* ww  w  . j ava2s.co  m*/
    }
    return name;
}

From source file:com.jaxio.celerio.util.PackageUtil.java

public static boolean isPackageNameValid(String packageName) {
    if (!SourceVersion.isName(packageName)) {
        return false;
    }/*from  ww  w  .  j a v a 2  s  .c om*/

    if (packageName.startsWith("java")) {
        return false;
    }

    return true;
}

From source file:io.github.jeddict.jpa.modeler.widget.JavaClassWidget.java

protected void validateName(String previousName, String name) {
    if (JavaPersistenceQLKeywords.isKeyword(JavaClassWidget.this.getName())) {
        getSignalManager().fire(ERROR, ClassValidator.CLASS_NAME_WITH_JPQL_KEYWORD);
    } else {/*from  w ww. ja v a 2 s  .  co  m*/
        getSignalManager().clear(ERROR, ClassValidator.CLASS_NAME_WITH_JPQL_KEYWORD);
    }
    if (JavaClass.isAutoGenerated(JavaClassWidget.this.getName())) {
        getSignalManager().fire(WARNING, ClassValidator.CLASS_NAME_WITH_AUTO_GEN_ENITY);
    } else {
        getSignalManager().clear(WARNING, ClassValidator.CLASS_NAME_WITH_AUTO_GEN_ENITY);
    }
    if (SourceVersion.isName(name)) {
        getSignalManager().clear(ERROR, ClassValidator.INVALID_CLASS_NAME);
    } else {
        getSignalManager().fire(ERROR, ClassValidator.INVALID_CLASS_NAME);
    }
    scanDuplicateClass(previousName, name);
    scanReservedDefaultClass(previousName, name);
}

From source file:io.github.jeddict.jpa.modeler.widget.attribute.AttributeWidget.java

public void validateName(String previousName, String name) {
    if (JavaPersistenceQLKeywords.isKeyword(name)) {
        getSignalManager().fire(ERROR, ATTRIBUTE_NAME_WITH_JPQL_KEYWORD);
    } else {/*from   ww w  .j a v a 2  s . c o m*/
        getSignalManager().clear(ERROR, ATTRIBUTE_NAME_WITH_JPQL_KEYWORD);
    }
    if (SourceVersion.isName(name)) {
        getSignalManager().clear(ERROR, INVALID_ATTRIBUTE_NAME);
    } else {
        getSignalManager().fire(ERROR, INVALID_ATTRIBUTE_NAME);
    }
    this.getClassWidget().scanDuplicateAttributes(previousName, name);
}

From source file:com.github.alexfalappa.nbspringboot.projects.initializr.InitializrProjectPanelVisual1.java

boolean valid(WizardDescriptor wizardDescriptor) {
    if (!initialized) {
        wizardDescriptor.putProperty(WizardDescriptor.PROP_INFO_MESSAGE, "Contacting service...");
        return false;
    }/*w  w  w  . j a  v a2s .  c o m*/
    if (failed) {
        wizardDescriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, "Problems in contacting service!");
        return false;
    }
    if (txGroup.getText().isEmpty()) {
        //Empty group
        wizardDescriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, "Group can't be empty.");
        return false;
    }
    if (txArtifact.getText().isEmpty()) {
        //Empty artifact
        wizardDescriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, "Artifact can't be empty.");
        return false;
    }
    if (txVersion.getText().isEmpty()) {
        //Empty version
        wizardDescriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, "Version can't be empty.");
        return false;
    }
    if (txName.getText().isEmpty()) {
        //Empty name
        wizardDescriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, "Name can't be empty.");
        return false;
    }
    if (!SourceVersion.isName(txPackage.getText())) {
        //Invalid package name
        wizardDescriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE,
                "Package Name is not a valid Java package name.");
        return false;
    }
    wizardDescriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, "");
    return true;
}

From source file:io.github.jeddict.jpa.modeler.source.generator.ui.GenerateCodeDialog.java

private boolean hasError() {
    if (!Technology.NONE_LABEL.equals(getBusinessLayer().getTechnology().label())) {
        if ((isMonolith() && !isSupportedProject(targetProjectInfo))
                || (isMicroservice()// w w  w  .j a va  2s .com
                        && (!isSupportedProject(gatewayProjectInfo) || !isSupportedProject(targetProjectInfo)))
                || (isGateway() && !isSupportedProject(gatewayProjectInfo))) {
            NotifyDescriptor d = new NotifyDescriptor.Message(
                    "Please select the [Maven > Web Application] project for full-stack app",
                    NotifyDescriptor.INFORMATION_MESSAGE);
            d.setTitle("Invalid project type");
            DialogDisplayer.getDefault().notify(d);
            return true;
        }
    }
    if (isMicroservice() && targetProjectInfo.getProject() == gatewayProjectInfo.getProject()) {
        NotifyDescriptor d = new NotifyDescriptor.Message("Target and Gateway project can't be same",
                NotifyDescriptor.INFORMATION_MESSAGE);
        d.setTitle("Same destination");
        DialogDisplayer.getDefault().notify(d);
        return true;
    }

    if (isGateway() && !SourceVersion.isName(getGatewayPackage())) {
        NotifyDescriptor d = new NotifyDescriptor.Message("Please select the Gateway Project Package.",
                NotifyDescriptor.INFORMATION_MESSAGE);
        d.setTitle("Gateway Project Package");
        DialogDisplayer.getDefault().notify(d);
        gatewayProjectPackageCombo.requestFocus();
        return true;
    }

    if ((isMonolith() || isMicroservice()) && !SourceVersion.isName(getTargetPackage())) {
        NotifyDescriptor d = new NotifyDescriptor.Message("Please select the Project Package.",
                NotifyDescriptor.INFORMATION_MESSAGE);
        d.setTitle("Project Package");
        DialogDisplayer.getDefault().notify(d);
        targetProjectPackageCombo.requestFocus();
        return true;
    }

    if (!SourceVersion.isName(getEntityPackage())) {
        NotifyDescriptor d = new NotifyDescriptor.Message("Please select the Entity Package.",
                NotifyDescriptor.INFORMATION_MESSAGE);
        d.setTitle("Entity Package");
        DialogDisplayer.getDefault().notify(d);
        return true;
    }
    for (Component component : configPane.getComponents()) {
        if (component instanceof LayerConfigPanel) {
            LayerConfigPanel panel = (LayerConfigPanel) component;
            if (panel.hasError()) {
                configPane.setSelectedComponent(component);
                return true;
            } else {
                panel.store();
                PreferenceUtils.set(targetProjectInfo.getProject(), panel.getConfigData());
            }
        }
    }
    return false;
}

From source file:org.bonitasoft.engine.bdm.CodeGenerator.java

public JDefinedClass addClass(final String fullyqualifiedName) throws JClassAlreadyExistsException {
    if (fullyqualifiedName == null || fullyqualifiedName.isEmpty()) {
        throw new IllegalArgumentException("Classname cannot cannot be null or empty");
    }/*from www. j a va 2s.com*/
    if (!SourceVersion.isName(fullyqualifiedName)) {
        throw new IllegalArgumentException(
                "Classname " + fullyqualifiedName + " is not a valid qualified name");
    }
    return model._class(fullyqualifiedName);
}

From source file:org.kie.workbench.common.services.datamodeller.validation.ValidationUtils.java

public static Boolean isJavaIdentifier(String s) {
    if (StringUtils.isBlank(s))
        return false;
    if (!SourceVersion.isName(s))
        return false;
    for (int i = 0; i < s.length(); i++) {
        if (!CharUtils.isAsciiPrintable(s.charAt(i)))
            return false;
    }//from w w w. j ava 2s.  c o m
    return true;
}

From source file:org.kie.workbench.common.stunner.bpmn.backend.forms.conditions.parser.ParsingUtils.java

public static String parseJavaName(final String token, final int startIndex, final char[] stopCharacters)
        throws ParseException {
    if (startIndex < 0 || startIndex >= token.length()) {
        throw new IndexOutOfBoundsException("startIndex: " + startIndex + " exceeds token bounds: " + token);
    }//  www. java  2s .  co  m
    final StringBuilder javaName = new StringBuilder();
    char currentChar;
    int currentIndex = startIndex;
    while (currentIndex < token.length()) {
        currentChar = token.charAt(currentIndex);
        if (ArrayUtils.contains(stopCharacters, currentChar)) {
            break;
        } else {
            javaName.append(currentChar);
        }
        currentIndex++;
    }

    if (javaName.length() == 0) {
        throw new ParseException("Expected java name was not found at position: " + startIndex, startIndex);
    } else if (!SourceVersion.isName(javaName)) {
        throw new ParseException("Invalid java name was found at position: " + startIndex, startIndex);
    }
    return javaName.toString();
}

From source file:org.netbeans.jcode.ejb.facade.SessionBeanPanel.java

@Override
public boolean hasError() {
    warningLabel.setText("");
    if (!isValidPackageName(getPackage())) {
        warningLabel.setText(//from  w ww .jav a 2  s  . c o  m
                NbBundle.getMessage(SessionBeanPanel.class, "SessionBeanPanel.invalidPackage.message"));
        return true;
    }
    String prefix = getPrefix();
    String suffix = getSuffix();

    if (StringUtils.isNotBlank(prefix) && !SourceVersion.isName(prefix)) {
        warningLabel
                .setText(NbBundle.getMessage(SessionBeanPanel.class, "SessionBeanPanel.invalidPrefix.message"));
        return true;
    }
    if (StringUtils.isNotBlank(suffix) && !SourceVersion.isName(prefix + '_' + suffix)) {
        warningLabel
                .setText(NbBundle.getMessage(SessionBeanPanel.class, "SessionBeanPanel.invalidSuffix.message"));
        return true;
    }
    return false;
}