Package com.puppycrawl.tools.checkstyle
Class PackageObjectFactory
java.lang.Object
com.puppycrawl.tools.checkstyle.PackageObjectFactory
- All Implemented Interfaces:
ModuleFactory
A factory for creating objects from package names and names.
Consider the below example for better understanding.
- module name - name of java class that represents module;
- module full name - fully qualifies name of java class that represents module;
- check module short name - name of Check without 'Check' suffix;
- check module name - name of java class that represents Check (with 'Check' suffix);
- check module full name - fully qualifies name of java class that represents Check (with 'Check' suffix).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum class to define loading options. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringException message when there is ambiguous module name in config file.static final StringBase package of checkstyle modules checks.static final StringSuffix of checks.static final StringException message when null class loader is given.static final StringException message when null package name is given.static final StringCharacter separate package names in qualified name of java class.static final StringSeparator to use in strings.static final StringException message when it is unable to create a class instance. -
Constructor Summary
ConstructorsConstructorDescriptionPackageObjectFactory(String packageName, ClassLoader moduleClassLoader) Creates a newPackageObjectFactoryinstance.PackageObjectFactory(Set<String> packageNames, ClassLoader moduleClassLoader) Creates a newPackageObjectFactoryinstance.PackageObjectFactory(Set<String> packageNames, ClassLoader moduleClassLoader, PackageObjectFactory.ModuleLoadOption moduleLoadOption) Creates a newPackageObjectFactoryinstance. -
Method Summary
Modifier and TypeMethodDescriptioncreateModule(String name) Creates a new instance of a class from a given name, or that name concatenated with "Check".static StringgetShortFromFullModuleNames(String fullName) Returns simple check name from full modules names map.
-
Field Details
-
BASE_PACKAGE
Base package of checkstyle modules checks.- See Also:
-
UNABLE_TO_INSTANTIATE_EXCEPTION_MESSAGE
Exception message when it is unable to create a class instance.- See Also:
-
AMBIGUOUS_MODULE_NAME_EXCEPTION_MESSAGE
Exception message when there is ambiguous module name in config file.- See Also:
-
CHECK_SUFFIX
Suffix of checks.- See Also:
-
PACKAGE_SEPARATOR
Character separate package names in qualified name of java class.- See Also:
-
NULL_LOADER_MESSAGE
Exception message when null class loader is given.- See Also:
-
NULL_PACKAGE_MESSAGE
Exception message when null package name is given.- See Also:
-
STRING_SEPARATOR
Separator to use in strings.- See Also:
-
-
Constructor Details
-
PackageObjectFactory
Creates a newPackageObjectFactoryinstance.- Parameters:
packageNames- the list of package names to usemoduleClassLoader- class loader used to load Checkstyle core and custom modules
-
PackageObjectFactory
public PackageObjectFactory(Set<String> packageNames, ClassLoader moduleClassLoader, PackageObjectFactory.ModuleLoadOption moduleLoadOption) Creates a newPackageObjectFactoryinstance.- Parameters:
packageNames- the list of package names to usemoduleClassLoader- class loader used to load Checkstyle core and custom modulesmoduleLoadOption- loading option- Throws:
IllegalArgumentException- if moduleClassLoader is null or packageNames contains null
-
PackageObjectFactory
Creates a newPackageObjectFactoryinstance.- Parameters:
packageName- The package name to usemoduleClassLoader- class loader used to load Checkstyle core and custom modules- Throws:
IllegalArgumentException- if moduleClassLoader is null or packageNames is null
-
-
Method Details
-
createModule
Creates a new instance of a class from a given name, or that name concatenated with "Check". If the name is a class name, creates an instance of the named class. Otherwise, creates an instance of a class name obtained by concatenating the given name to a package name from a given list of package names.- Specified by:
createModulein interfaceModuleFactory- Parameters:
name- the name of a class.- Returns:
- the
Objectcreated by loader. - Throws:
CheckstyleException- if an error occurs.
-
getShortFromFullModuleNames
Returns simple check name from full modules names map.- Parameters:
fullName- name of the class for joining.- Returns:
- simple check name.
-