Class MetadataGeneratorUtil
java.lang.Object
com.puppycrawl.tools.checkstyle.meta.MetadataGeneratorUtil
Class which handles all the metadata generation and writing calls.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Generate metadata from the module source files available in the input argument path.private static ModuleDetails
getModuleDetails
(File file) Generate metadata for the given file.private static ModuleType
getModuleType
(String moduleName) Get module type(check/filter/filefilter) based on module name.private static List<ModulePropertyDetails>
getPropertiesDetails
(Set<String> properties, Map<String, DetailNode> javadocs, String className, Object instance) Get property details for the given property - name, description, type, default value.private static String
getPropertyDefaultValue
(String property, Field field, Object instance, String className) Get default value for the given property.private static String
getPropertyDescription
(String property, DetailNode propertyJavadoc) Get property description from property javadoc.getTargetFiles
(String path, String... moduleFolders) Get files that represent modules.private static String
getValidationType
(String propertyName, Field propertyField) Get validation type for the given property.private static void
writeMetadataFile
(ModuleDetails moduleDetails) Write metadata file for the given module.
-
Constructor Details
-
MetadataGeneratorUtil
private MetadataGeneratorUtil()Stop instances being created.
-
-
Method Details
-
generate
public static void generate(String path, String... moduleFolders) throws IOException, CheckstyleException Generate metadata from the module source files available in the input argument path.- Parameters:
path
- argumentsmoduleFolders
- folders to check- Throws:
IOException
- ioExceptionCheckstyleException
- checkstyleException
-
getModuleDetails
private static ModuleDetails getModuleDetails(File file) throws org.apache.maven.doxia.macro.MacroExecutionException Generate metadata for the given file.- Parameters:
file
- file to generate metadata for.- Returns:
- module details.
- Throws:
org.apache.maven.doxia.macro.MacroExecutionException
- macroExecutionException
-
getModuleType
Get module type(check/filter/filefilter) based on module name.- Parameters:
moduleName
- module name.- Returns:
- module type.
-
getPropertiesDetails
private static List<ModulePropertyDetails> getPropertiesDetails(Set<String> properties, Map<String, DetailNode> javadocs, String className, Object instance) throws org.apache.maven.doxia.macro.MacroExecutionExceptionGet property details for the given property - name, description, type, default value.- Parameters:
properties
- properties of the module.javadocs
- javadocs of the module.className
- the class name of the module.instance
- the instance of the module.- Returns:
- property details.
- Throws:
org.apache.maven.doxia.macro.MacroExecutionException
- if an error occurs.
-
getPropertyDefaultValue
private static String getPropertyDefaultValue(String property, Field field, Object instance, String className) throws org.apache.maven.doxia.macro.MacroExecutionException Get default value for the given property.- Parameters:
property
- property name.field
- field.instance
- instance of the module.className
- class name of the module.- Returns:
- default value.
- Throws:
org.apache.maven.doxia.macro.MacroExecutionException
- if an error occurs.
-
writeMetadataFile
Write metadata file for the given module.- Parameters:
moduleDetails
- module details.- Throws:
CheckstyleException
- if an error occurs during writing metadata file.
-
getValidationType
Get validation type for the given property.- Parameters:
propertyName
- name of property.propertyField
- field of property.- Returns:
- validation type.
-
getPropertyDescription
Get property description from property javadoc.- Parameters:
property
- property name.propertyJavadoc
- property javadoc.- Returns:
- property description.
-
getTargetFiles
Get files that represent modules.- Parameters:
moduleFolders
- folders to checkpath
- rootPath- Returns:
- files for scrapping javadoc and generation of metadata files
- Throws:
IOException
- ioException
-