public class RequireOS extends AbstractStandardEnforcerRule
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
arch
The OS architecture desired.
|
private boolean |
display
Display detected OS information.
|
private java.lang.String |
family
The OS family type desired
Possible values: dos mac netware os/2 tandem unix windows win9x z/os os/400 |
private java.lang.String |
name
The OS name desired.
|
private java.lang.String |
version
The OS version desired.
|
Constructor and Description |
---|
RequireOS()
Instantiates a new RequireOS.
|
Modifier and Type | Method and Description |
---|---|
boolean |
allParamsEmpty()
Helper method to check that at least one of family, name, version or arch is set.
|
private org.apache.maven.model.Activation |
createActivation()
Creates an Activation object that contains the ActivationOS information.
|
private org.apache.maven.model.ActivationOS |
createOsBean()
Creates an ActivationOS object containing family, name, version and arch.
|
private org.apache.maven.model.Profile |
createProfile()
Creates a Profile object that contains the activation information.
|
void |
displayOSInfo(org.apache.maven.plugin.logging.Log log,
boolean info)
Log the current OS information.
|
void |
execute(EnforcerRuleHelper helper)
This is the interface into the rule.
|
java.lang.String |
getArch()
Gets the arch.
|
java.lang.String |
getCacheId()
If the rule is to be cached, this id is used as part of the key.
|
java.lang.String |
getFamily()
Gets the family.
|
java.lang.String |
getName()
Gets the name.
|
java.lang.String |
getVersion()
Gets the version.
|
boolean |
isAllowed()
Helper method to determine if the current OS is allowed based on the injected values for family, name, version
and arch.
|
boolean |
isCacheable()
This method tells the enforcer if the rule results may be cached.
|
boolean |
isDisplay() |
boolean |
isResultValid(EnforcerRule theCachedRule)
Checks if cached result is valid.
|
boolean |
isValidFamily(java.lang.String theFamily)
Helper method to check if the given family is in the following list:
dos
mac
netware
os/2
tandem
unix
windows
win9x
z/os
os/400
Note: '!' is allowed at the beginning of the string and still considered valid.
|
void |
setArch(java.lang.String theArch)
Sets the arch.
|
void |
setDisplay(boolean display) |
void |
setFamily(java.lang.String theFamily)
Sets the family.
|
void |
setName(java.lang.String theName)
Sets the name.
|
void |
setVersion(java.lang.String theVersion)
Sets the version.
|
getLevel, getMessage, setLevel, setMessage
private java.lang.String family
#setFamily(String)}
,
#getFamily()}
private java.lang.String name
#setName(String)}
,
#getName()}
private java.lang.String version
#setVersion(String)}
,
#getVersion()}
private java.lang.String arch
#setArch(String)}
,
#getArch()}
private boolean display
#setDisplay(boolean)}
,
#isDisplay()}
public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException
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.EnforcerRuleException
- the enforcer rule exceptionpublic void displayOSInfo(org.apache.maven.plugin.logging.Log log, boolean info)
log
- the loginfo
- the infopublic boolean isAllowed()
public boolean allParamsEmpty()
private org.apache.maven.model.Profile createProfile()
private org.apache.maven.model.Activation createActivation()
private org.apache.maven.model.ActivationOS createOsBean()
public boolean isValidFamily(java.lang.String theFamily)
theFamily
- the family to check.public java.lang.String getArch()
public void setArch(java.lang.String theArch)
theArch
- the arch to setpublic java.lang.String getFamily()
public void setFamily(java.lang.String theFamily)
theFamily
- the family to setpublic java.lang.String getName()
public void setName(java.lang.String theName)
theName
- the name to setpublic java.lang.String getVersion()
public void setVersion(java.lang.String theVersion)
theVersion
- the version to setpublic final void setDisplay(boolean display)
display
- The value for the display.public final boolean isDisplay()
public java.lang.String getCacheId()
public boolean isCacheable()
true
if rule is cacheablepublic boolean isResultValid(EnforcerRule theCachedRule)
theCachedRule
- 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)true
if the stored results are valid for the same id.