Java Code Examples for com.puppycrawl.tools.checkstyle.api.Configuration#getName()

The following examples show how to use com.puppycrawl.tools.checkstyle.api.Configuration#getName() . 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: ClassFileSetCheck.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Instantiates, configures and registers a Check that is specified
 * in the provided configuration.
 * @see com.puppycrawl.tools.checkstyle.api.AutomaticBean
 */
public void setupChild(Configuration aChildConf)
    throws CheckstyleException
{
    // TODO: improve the error handing
    final String name = aChildConf.getName();
    final Object module = mModuleFactory.createModule(name);
    if (!(module instanceof AbstractCheckVisitor)) {
        throw new CheckstyleException(
            "ClassFileSet is not allowed as a parent of " + name);
    }
    final AbstractCheckVisitor c = (AbstractCheckVisitor) module;
    c.contextualize(mChildContext);
    c.configure(aChildConf);
    c.init();

    registerCheck(c);
}
 
Example 2
Source File: ClassFileSetCheck.java    From contribution with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Instantiates, configures and registers a Check that is specified
 * in the provided configuration.
 * @see com.puppycrawl.tools.checkstyle.api.AutomaticBean
 */
public void setupChild(Configuration aChildConf)
    throws CheckstyleException
{
    // TODO: improve the error handing
    final String name = aChildConf.getName();
    final Object module = mModuleFactory.createModule(name);
    if (!(module instanceof AbstractCheckVisitor)) {
        throw new CheckstyleException(
            "ClassFileSet is not allowed as a parent of " + name);
    }
    final AbstractCheckVisitor c = (AbstractCheckVisitor) module;
    c.contextualize(mChildContext);
    c.configure(aChildConf);
    c.init();

    registerCheck(c);
}
 
Example 3
Source File: SpringConfigurationLoader.java    From spring-javaformat with Apache License 2.0 5 votes vote down vote up
private FileSetCheck load(Configuration configuration) {
	Object module = createModule(configuration);
	if (!(module instanceof FileSetCheck)) {
		throw new IllegalStateException(configuration.getName() + " is not allowed");
	}
	return (FileSetCheck) module;
}
 
Example 4
Source File: SpringConfigurationLoader.java    From spring-javaformat with Apache License 2.0 5 votes vote down vote up
private Object createModule(Configuration configuration) {
	String name = configuration.getName();
	try {
		Object module = this.moduleFactory.createModule(name);
		if (module instanceof AutomaticBean) {
			initialize(configuration, (AutomaticBean) module);
		}
		return module;
	}
	catch (CheckstyleException ex) {
		throw new IllegalStateException("cannot initialize module " + name + " - " + ex.getMessage(), ex);
	}
}
 
Example 5
Source File: SpringChecks.java    From spring-javaformat with Apache License 2.0 4 votes vote down vote up
@Override
public void setupChild(Configuration configuration) throws CheckstyleException {
	throw new CheckstyleException("SpringChecks is not allowed as a parent of " + configuration.getName());
}