Class AbstractRequireFiles
java.lang.Object
org.apache.maven.plugins.enforcer.AbstractStandardEnforcerRule
org.apache.maven.plugins.enforcer.AbstractRequireFiles
- All Implemented Interfaces:
EnforcerRule,EnforcerRule2
- Direct Known Subclasses:
RequireFilesDontExist,RequireFilesExist,RequireFilesSize
Contains the common code to compare an array of files against a requirement.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanif null file handles should be allowed.private File[]Array of files to check. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) abstract booleanCheck one file.voidexecute(EnforcerRuleHelper helper) This is the interface into the rule.If the rule is to be cached, this id is used as part of the key.(package private) abstract StringGets the error msg.File[]getFiles()private static intCalculates a hash code for the specified array asArrays.hashCode()would do.booleanbooleanThis method tells the enforcer if the rule results may be cached.booleanisResultValid(EnforcerRule cachedRule) If the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to allow double checking of the results.voidsetAllowNulls(boolean allowNulls) voidMethods inherited from class org.apache.maven.plugins.enforcer.AbstractStandardEnforcerRule
getLevel, getMessage, setLevel, setMessage
-
Field Details
-
files
Array of files to check. -
allowNulls
private boolean allowNullsif null file handles should be allowed. If they are allowed, it means treat it as a success.
-
-
Constructor Details
-
AbstractRequireFiles
public AbstractRequireFiles()
-
-
Method Details
-
checkFile
Check one file.- Parameters:
file- the file- Returns:
trueif successful
-
getErrorMsg
Gets the error msg.- Returns:
- the error msg
-
execute
Description copied from interface:EnforcerRuleThis is the interface into the rule. This method should throw an exception containing a reason message if the rule fails the check. The plugin will then decide based on the fail flag if it should stop or just log the message as a warning.- Parameters:
helper- The helper provides access to the log, MavenSession and has helpers to get common components. It is also able to lookup components by class name.- Throws:
EnforcerRuleException- the enforcer rule exception
-
getCacheId
Description copied from interface:EnforcerRuleIf the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters that allow multiple results of the same rule to be cached.- Returns:
- id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique within a given rule implementation as the full key will be [classname]-[id]
-
hashCode
Calculates a hash code for the specified array asArrays.hashCode()would do. Unfortunately, the mentioned method is only available for Java 1.5 and later.- Parameters:
items- The array for which to compute the hash code, may benull.- Returns:
- The hash code for the array.
-
isCacheable
public boolean isCacheable()Description copied from interface:EnforcerRuleThis method tells the enforcer if the rule results may be cached. If the result is true, the results will be remembered for future executions in the same build (ie children). Subsequent iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be uncached further down the tree if needed.- Returns:
trueif rule is cacheable
-
isResultValid
Description copied from interface:EnforcerRuleIf the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to allow double checking of the results. Most of the time this can be done by generating unique ids, but sometimes the results of objects returned by the helper need to be queried. You may for example, store certain objects in your rule and then query them later.- Parameters:
cachedRule- the last cached instance of the rule. This is to be used by the rule to potentially determine if the results are still valid (ie if the configuration has been overridden)- Returns:
trueif the stored results are valid for the same id.
-
getFiles
-
setFiles
-
isAllowNulls
public boolean isAllowNulls() -
setAllowNulls
public void setAllowNulls(boolean allowNulls)
-