Tabnine Logo
InitializrConfiguration.cleanPackageName
Code IndexAdd Tabnine to your IDE (free)

How to use
cleanPackageName
method
in
io.spring.initializr.metadata.InitializrConfiguration

Best Java code snippets using io.spring.initializr.metadata.InitializrConfiguration.cleanPackageName (Showing top 12 results out of 315)

origin: spring-io/initializr

/**
 * Clean the specified package name if necessary. If the package name cannot be
 * transformed to a valid package name, the {@code defaultPackageName} is used
 * instead.
 * <p>
 * The package name cannot be cleaned if the specified {@code packageName} is
 * {@code null} or if it contains an invalid character for a class identifier.
 * @param packageName the package name
 * @param defaultPackageName the default package name
 * @return the cleaned package name
 * @see Env#getInvalidPackageNames()
 */
public String cleanPackageName(String packageName, String defaultPackageName) {
  if (!StringUtils.hasText(packageName)) {
    return defaultPackageName;
  }
  String candidate = cleanPackageName(packageName);
  if (hasInvalidChar(candidate.replace(".", ""))
      || this.env.invalidPackageNames.contains(candidate)) {
    return defaultPackageName;
  }
  else {
    return candidate;
  }
}
origin: spring-io/initializr

@Test
void generatePackageNameSimpleUnderscore() {
  assertThat(this.properties.cleanPackageName("com.my_foo", "com.example"))
      .isEqualTo("com.my_foo");
}
origin: spring-io/initializr

@Test
void generatePackageNameMultipleSpaces() {
  assertThat(this.properties.cleanPackageName("  com   foo  ", "com.example"))
      .isEqualTo("com.foo");
}
origin: spring-io/initializr

@Test
void generatePackageNameInvalidStartCharacter() {
  assertThat(this.properties.cleanPackageName("0com.foo", "com.example"))
      .isEqualTo("com.foo");
}
origin: spring-io/initializr

@Test
void generatePackageNameInvalidPackageName() {
  assertThat(this.properties.cleanPackageName("org.springframework", "com.example"))
      .isEqualTo("com.example");
}
origin: spring-io/initializr

@Test
void generatePackageNameSimple() {
  assertThat(this.properties.cleanPackageName("com.foo", "com.example"))
      .isEqualTo("com.foo");
}
origin: spring-io/initializr

@Test
void generatePackageNameMultipleDashers() {
  assertThat(this.properties.cleanPackageName("com.foo--bar", "com.example"))
      .isEqualTo("com.foobar");
}
origin: spring-io/initializr

@Test
void generatePackageNameNull() {
  assertThat(this.properties.cleanPackageName(null, "com.example"))
      .isEqualTo("com.example");
}
origin: spring-io/initializr

@Test
void generatePackageNameSimpleColon() {
  assertThat(this.properties.cleanPackageName("com:foo", "com.example"))
      .isEqualTo("com.foo");
}
origin: spring-io/initializr

@Test
void generatePackageNameVersion() {
  assertThat(this.properties.cleanPackageName("com.foo.test-1.4.5", "com.example"))
      .isEqualTo("com.foo.test145");
}
origin: spring-io/initializr

@Override
public String getContent() {
  String value = super.getContent();
  if (value != null) {
    return value;
  }
  else if (this.groupId.getContent() != null
      && this.artifactId.getContent() != null) {
    return InitializrConfiguration.cleanPackageName(
        this.groupId.getContent() + "." + this.artifactId.getContent());
  }
  return null;
}
origin: spring-io/initializr

      metadata.getConfiguration().generateApplicationName(getName()));
setPackageName(metadata.getConfiguration().cleanPackageName(getPackageName(),
    metadata.getPackageName().getContent()));
io.spring.initializr.metadataInitializrConfigurationcleanPackageName

Javadoc

Clean the specified package name if necessary. If the package name cannot be transformed to a valid package name, the defaultPackageName is used instead.

The package name cannot be cleaned if the specified packageName is null or if it contains an invalid character for a class identifier.

Popular methods of InitializrConfiguration

  • getEnv
  • <init>
  • generateApplicationName
    Generate a suitable application name based on the specified name. If no suitable application name ca
  • hasInvalidChar
  • merge
  • splitCamelCase
  • unsplitWords
  • validate

Popular in Java

  • Making http post requests using okhttp
  • setRequestProperty (URLConnection)
  • putExtra (Intent)
  • scheduleAtFixedRate (Timer)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now