Package org.apache.rat.config.parameters
Class Description
java.lang.Object
org.apache.rat.config.parameters.Description
A description of a component.
-
Constructor Summary
ConstructorsConstructorDescriptionDescription
(ComponentType type, String name, String desc, boolean isCollection, Class<?> childClass, Collection<Description> children, boolean required) Constructor.Description
(ConfigComponent configComponent, boolean isCollection, Class<?> childClass, Collection<Description> children) Constructor -
Method Summary
Modifier and TypeMethodDescriptionchildrenOfType
(ComponentType type) Get all the children of a specific typefilterChildren
(Predicate<Description> filter) Gets a filtered collection of the child descriptions.Gets a map of the parameters that the object contains.Class
<?> Get the class of the objects for the getter/setter methods.Gets the common name for the matcher.Gets the description of descriptive text for the component.getParamValue
(Object object) Retrieve the value of the described parameter from the specified object.Returns the getter for the component in the specified class.getType()
Gets the type of the component.boolean
Get the isCollection flag.boolean
Get the canBeChild flag.methodName
(String prefix) Generate a method name for this description.void
setChild
(IHeaderMatcher.Builder builder, String name, String value) Sets the child value in the builder.void
setChildren
(IHeaderMatcher.Builder builder, Map<String, String> attributes) Sets the children of values in the builder.Returns the setter for the component in the specified class.toString()
-
Constructor Details
-
Description
public Description(ComponentType type, String name, String desc, boolean isCollection, Class<?> childClass, Collection<Description> children, boolean required) Constructor.- Parameters:
type
- the type of the component.name
- the name of the component.desc
- the description of the component.isCollection
- true if the getter/setter expects a collectionchildClass
- the class for expected for the getter/setter.children
- the collection of descriptions for all the components that are children of the described component.required
- Iftrue
the component is required.
-
Description
public Description(ConfigComponent configComponent, boolean isCollection, Class<?> childClass, Collection<Description> children) Constructor- Parameters:
configComponent
- the configuration component.isCollection
- the collection flag.childClass
- the type of object that the method getter/setter expects.children
- the collection of descriptions for all the components that are children the described component.
-
-
Method Details
-
isRequired
public boolean isRequired()Get the canBeChild flag.- Returns:
true
if this item can be a child of the containing item.
-
getType
Gets the type of the component.- Returns:
- the component type.
-
isCollection
public boolean isCollection()Get the isCollection flag.- Returns:
- true if this is a collection.
-
getChildType
Get the class of the objects for the getter/setter methods.- Returns:
- the getter/setter param class.
-
getCommonName
Gets the common name for the matcher. (e.g. 'text', 'spdx', etc.) May not be null.- Returns:
- The common name for the item being inspected.
-
getDescription
Gets the description of descriptive text for the component. May be an empty string or null.- Returns:
- the descriptive text;
-
getParamValue
Retrieve the value of the described parameter from the specified object. If the parameter is a collection returnnull
.- Parameters:
object
- the object that contains the value.- Returns:
- the string value.
-
getChildren
Gets a map of the parameters that the object contains. For example Copyright has 'start', 'stop', and 'owner' parameters. Some IHeaderMatchers have simple text values (e.g. 'regex' or 'text' types) these should list an unnamed parameter (empty string) with the text value.- Returns:
- the map of parameters to the objects that represent them.
-
childrenOfType
Get all the children of a specific type- Parameters:
type
- the type to return- Returns:
- the collection of children of the specified type.
-
filterChildren
Gets a filtered collection of the child descriptions.- Parameters:
filter
- the filter to apply to the child descriptions.- Returns:
- the collection of children that matches the filter.
-
methodName
Generate a method name for this description.- Parameters:
prefix
- the start of the method name (e.g. "set", "get" )- Returns:
- the method name.
-
getter
Returns the getter for the component in the specified class.- Parameters:
clazz
- the Class to get the getter from.- Returns:
- the getter Method.
- Throws:
NoSuchMethodException
- if the class does not have the getter.SecurityException
- if the getter can not be accessed.
-
setter
Returns the setter for the component in the specified class. Notes:- License can not be set in components. They are top level components.
- Matcher expects an "add" method that accepts an IHeaderMatcher.Builder.
- Parameter expects a
set(String)
method. - Unlabeled expects a
set(String)
method. - BuilderParam expects a
set
method that takes achildClass
argument.
- Parameters:
clazz
- the Class to get the getter from, generally a Builder class.- Returns:
- the getter Method.
- Throws:
NoSuchMethodException
- if the class does not have the getter.SecurityException
- if the getter can not be accessed.
-
setChildren
Sets the children of values in the builder. Sets the parameters to the values specified in the map. Only children that accept string arguments should be specified.- Parameters:
builder
- The Matcher builder to set the values in.attributes
- a Map of parameter names to values.
-
setChild
Sets the child value in the builder.- Parameters:
builder
- The Matcher builder to set the values in.name
- the name of the child to setvalue
- the value of the parameter.
-
toString
-