Package com.puppycrawl.tools.checkstyle
Class DefaultConfiguration
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.DefaultConfiguration
-
- All Implemented Interfaces:
Configuration
,java.io.Serializable
public final class DefaultConfiguration extends java.lang.Object implements Configuration
Default implementation of the Configuration interface.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<Configuration>
children
The list of child Configurations.private static Configuration[]
EMPTY_CONFIGURATION_ARRAY
Constant for optimization.private java.util.Map<java.lang.String,java.lang.String>
messages
The map containing custom messages.private java.lang.String
name
The name of this configuration.private java.util.Map<java.lang.String,java.lang.String>
propertyMap
The map from property names to property values.private static long
serialVersionUID
A unique serial version identifier.private ThreadModeSettings
threadModeSettings
The thread mode configuration.
-
Constructor Summary
Constructors Constructor Description DefaultConfiguration(java.lang.String name)
Instantiates a DefaultConfiguration.DefaultConfiguration(java.lang.String name, ThreadModeSettings threadModeSettings)
Instantiates a DefaultConfiguration.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addAttribute(java.lang.String attributeName, java.lang.String value)
Deprecated.This shall be removed in future releases.void
addChild(Configuration configuration)
Makes a configuration a child of this configuration.void
addMessage(java.lang.String key, java.lang.String value)
Adds a custom message to this configuration.void
addProperty(java.lang.String propertyName, java.lang.String value)
Adds n property to this configuration.java.lang.String
getAttribute(java.lang.String attributeName)
The attribute value for an attribute name.java.lang.String[]
getAttributeNames()
The set of attribute names.Configuration[]
getChildren()
The set of child configurations.java.util.Map<java.lang.String,java.lang.String>
getMessages()
Returns an unmodifiable map instance containing the custom messages for this configuration.java.lang.String
getName()
The name of this configuration.java.lang.String
getProperty(java.lang.String propertyName)
The property value for property name.java.lang.String[]
getPropertyNames()
The set of property names.ThreadModeSettings
getThreadModeSettings()
Gets the thread mode configuration.void
removeChild(Configuration configuration)
Removes a child of this configuration.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
A unique serial version identifier.- See Also:
- Constant Field Values
-
EMPTY_CONFIGURATION_ARRAY
private static final Configuration[] EMPTY_CONFIGURATION_ARRAY
Constant for optimization.
-
name
private final java.lang.String name
The name of this configuration.
-
children
private final java.util.List<Configuration> children
The list of child Configurations.
-
propertyMap
private final java.util.Map<java.lang.String,java.lang.String> propertyMap
The map from property names to property values.
-
messages
private final java.util.Map<java.lang.String,java.lang.String> messages
The map containing custom messages.
-
threadModeSettings
private final ThreadModeSettings threadModeSettings
The thread mode configuration.
-
-
Constructor Detail
-
DefaultConfiguration
public DefaultConfiguration(java.lang.String name)
Instantiates a DefaultConfiguration.- Parameters:
name
- the name for this DefaultConfiguration.
-
DefaultConfiguration
public DefaultConfiguration(java.lang.String name, ThreadModeSettings threadModeSettings)
Instantiates a DefaultConfiguration.- Parameters:
name
- the name for this DefaultConfiguration.threadModeSettings
- the thread mode configuration.
-
-
Method Detail
-
getAttributeNames
public java.lang.String[] getAttributeNames()
Description copied from interface:Configuration
The set of attribute names.- Specified by:
getAttributeNames
in interfaceConfiguration
- Returns:
- The set of attribute names, never null.
-
getAttribute
public java.lang.String getAttribute(java.lang.String attributeName) throws CheckstyleException
Description copied from interface:Configuration
The attribute value for an attribute name.- Specified by:
getAttribute
in interfaceConfiguration
- Parameters:
attributeName
- the attribute name- Returns:
- the value that is associated with name
- Throws:
CheckstyleException
- if name is not a valid attribute name
-
getPropertyNames
public java.lang.String[] getPropertyNames()
Description copied from interface:Configuration
The set of property names.- Specified by:
getPropertyNames
in interfaceConfiguration
- Returns:
- The set of property names, never null.
-
getProperty
public java.lang.String getProperty(java.lang.String propertyName) throws CheckstyleException
Description copied from interface:Configuration
The property value for property name.- Specified by:
getProperty
in interfaceConfiguration
- Parameters:
propertyName
- the property name- Returns:
- the value that is associated with name
- Throws:
CheckstyleException
- if name is not a valid property name
-
getChildren
public Configuration[] getChildren()
Description copied from interface:Configuration
The set of child configurations.- Specified by:
getChildren
in interfaceConfiguration
- Returns:
- The set of child configurations, never null.
-
getName
public java.lang.String getName()
Description copied from interface:Configuration
The name of this configuration.- Specified by:
getName
in interfaceConfiguration
- Returns:
- The name of this configuration.
-
addChild
public void addChild(Configuration configuration)
Makes a configuration a child of this configuration.- Parameters:
configuration
- the child configuration.
-
removeChild
public void removeChild(Configuration configuration)
Removes a child of this configuration.- Parameters:
configuration
- the child configuration to remove.
-
addAttribute
@Deprecated(since="8.45") public void addAttribute(java.lang.String attributeName, java.lang.String value)
Deprecated.This shall be removed in future releases. Please useaddProperty(String propertyName, String value)
instead.Adds n property to this configuration.- Parameters:
attributeName
- the name of the property.value
- the value of the property.
-
addProperty
public void addProperty(java.lang.String propertyName, java.lang.String value)
Adds n property to this configuration.- Parameters:
propertyName
- the name of the property.value
- the value of the property.
-
addMessage
public void addMessage(java.lang.String key, java.lang.String value)
Adds a custom message to this configuration.- Parameters:
key
- the message keyvalue
- the custom message pattern
-
getMessages
public java.util.Map<java.lang.String,java.lang.String> getMessages()
Returns an unmodifiable map instance containing the custom messages for this configuration.- Specified by:
getMessages
in interfaceConfiguration
- Returns:
- unmodifiable map containing custom messages
-
getThreadModeSettings
public ThreadModeSettings getThreadModeSettings()
Gets the thread mode configuration.- Returns:
- the thread mode configuration.
-
-