Example usage for org.apache.commons.lang3 ClassUtils PACKAGE_SEPARATOR

List of usage examples for org.apache.commons.lang3 ClassUtils PACKAGE_SEPARATOR

Introduction

In this page you can find the example usage for org.apache.commons.lang3 ClassUtils PACKAGE_SEPARATOR.

Prototype

String PACKAGE_SEPARATOR

To view the source code for org.apache.commons.lang3 ClassUtils PACKAGE_SEPARATOR.

Click Source Link

Document

The package separator String: ".".

Usage

From source file:com.wavemaker.tools.apidocs.tools.parser.util.DataTypeUtil.java

public static String getFullyQualifiedName(Class<?> type) {
    String packageName = ClassUtils.getPackageCanonicalName(type);
    String prefix = StringUtils.isNotBlank(packageName) ? packageName + ClassUtils.PACKAGE_SEPARATOR : "";
    return prefix + ClassUtils.getShortCanonicalName(type);
}

From source file:com.neocotic.bloggaer.common.LocatorHelper.java

/**
 * Retrieves the {@code class} name of the POJO implementation.
 * //from w w  w  . j  a v a2  s  .co  m
 * @param cls
 *            the {@code class} whose target {@code class} name is to be retrieved
 * @param packageName
 *            the name of the sub-package to be appended to the package name of the target {@code class}
 * @param prefix
 *            the {@code String} to be prepended to the name of the target {@code class}
 * @param suffix
 *            the {@code String} to be appended to the name of the target {@code class}
 * @return The name of the implementation {@code class}.
 * @throws NullPointerException
 *             If {@code cls} is {@code null}.
 */
public <T extends I> String getImplementationClassName(Class<T> cls, String packageName, String prefix,
        String suffix) {
    logger.entering(new Object[] { cls, packageName, prefix, suffix });

    StringBuilder buffer = new StringBuilder();
    buffer.append(cls.getPackage().getName());
    buffer.append(ClassUtils.PACKAGE_SEPARATOR);
    if (packageName != null) {
        buffer.append(packageName);
        buffer.append(ClassUtils.PACKAGE_SEPARATOR);
    }
    if (prefix != null)
        buffer.append(prefix);
    buffer.append(cls.getSimpleName());
    if (suffix != null)
        buffer.append(suffix);
    String className = buffer.toString();

    logger.exiting(className);
    return className;
}

From source file:de.flashpixx.rrd_antlr4.TestCLanguageLabels.java

/**
 * method to build a package path// w ww . j  av  a2s.c o m
 *
 * @param p_names list of package parts
 * @return full-qualified string
 */
private static String packagepath(final String... p_names) {
    return StringUtils.join(p_names, ClassUtils.PACKAGE_SEPARATOR);
}

From source file:org.assertj.assertions.generator.util.ClassUtil.java

/**
 * Get <b>public</b> classes in given directory (recursively).
 * <p/>/*  www. j  ava 2  s  . c om*/
 * Note that <b>anonymous</b> and <b>local</b> classes are excluded from the resulting set.
 *
 * @param directory directory where to look for classes
 * @param packageName package name corresponding to directory
 * @param classLoader used classloader
 * @return
 * @throws UnsupportedEncodingException
 */
private static Set<Class<?>> getClassesInDirectory(File directory, String packageName, ClassLoader classLoader)
        throws UnsupportedEncodingException {
    Set<Class<?>> classes = newLinkedHashSet();
    // Capture all the .class files in this directory
    // Get the list of the files contained in the package
    File[] files = directory.listFiles();
    for (File currentFile : files) {
        String currentFileName = currentFile.getName();
        if (isClass(currentFileName)) {
            // CHECKSTYLE:OFF
            try {
                // removes the .class extension
                String className = packageName + '.' + StringUtils.remove(currentFileName, CLASS_SUFFIX);
                Class<?> loadedClass = loadClass(className, classLoader);
                // we are only interested in public classes that are neither anonymous nor local
                if (isClassCandidateToAssertionsGeneration(loadedClass)) {
                    classes.add(loadedClass);
                }
            } catch (Throwable e) {
                // do nothing. this class hasn't been found by the loader, and we don't care.
            }
            // CHECKSTYLE:ON
        } else if (currentFile.isDirectory()) {
            // It's another package
            String subPackageName = packageName + ClassUtils.PACKAGE_SEPARATOR + currentFileName;
            // Ask for all resources for the path
            URL resource = classLoader.getResource(subPackageName.replace('.', File.separatorChar));
            File subDirectory = new File(URLDecoder.decode(resource.getPath(), "UTF-8"));
            Set<Class<?>> classesForSubPackage = getClassesInDirectory(subDirectory, subPackageName,
                    classLoader);
            classes.addAll(classesForSubPackage);
        }
    }
    return classes;
}