de.matthias_burbach.deputy.core.rule
Class RuleSet

java.lang.Object
  extended byde.matthias_burbach.deputy.core.rule.RuleSet

public class RuleSet
extends java.lang.Object

Holds all the rules to be used in the dependency recursion of a project.

Author:
Matthias Burbach

Field Summary
static java.lang.String DEFAULT_RULE_LATEST_RELEASE
          The default rule 'LATEST RELEASE'.
static java.lang.String DEFAULT_RULE_LATEST_RELEASE_NO_SCAN
          The default rule 'LATEST RELEASE (no scan)'.
static java.lang.String DEFAULT_RULE_PRESENT_RELEASE
          The default rule 'PRESENT RELEASE'.
static java.lang.String DEFAULT_RULE_SNAPSHOT
          The default rule 'SNAPSHOT'.
 
Constructor Summary
RuleSet()
           
 
Method Summary
 void add(Rule rule)
          Adds a rule to this rule set.
 void add(RuleSet ruleSet)
          Adds all rules of the rule set to this rule set.
 void addChangeListener(RuleSetChangeListener listener)
           
 java.util.List getAllRules()
           
 java.lang.String getDefaultRule()
           
 DeprecationRule getDeprecationRule(java.lang.String artifactId, java.lang.String version)
           
 java.util.List getDeprecationRules()
           
 java.lang.String getEnforcedVersion(java.lang.String artifactId)
           
 EnforcementRule getEnforcementRule(java.lang.String artifactId)
           
 java.util.List getEnforcementRules()
           
 int getNumberOfDerivedRules()
           
 int getNumberOfSnapshotEnforcements()
           
 java.util.List getRemovalRules()
           
 ReplacementRule getReplacementRule(java.lang.String artifactId, java.lang.String version)
           
 java.util.List getReplacementRules()
           
 RetentionRule getRetentionRule(java.lang.String artifactId, java.lang.String version)
           
 java.util.List getRetentionRules()
           
 Rule getRuleForKey(Rule rule)
           
 boolean hasRuleForKey(Rule rule)
           
 boolean hasSameRule(Rule rule)
           
 boolean isDeprecated(java.lang.String artifactId, java.lang.String version)
           
 boolean isRemoved(java.lang.String artifactId, java.lang.String version)
           
 boolean isRetained(java.lang.String artifactId, java.lang.String version)
          Checks whether there is a retention rule that governs to retain the version of the artifact when encountered during the process of applying the rules.
 void remove(Rule rule)
          Removes a rule from this rule set.
 void removeAllDerivedEnforcementRules()
          Removes all rules of type EnforcementRule if their property 'derived' is true.
 void removeAllDerivedRules()
          Removes all rules of type Rule if their property 'derived' is true.
 void removeAllSnapshotEnforcements()
          Removes all SNAPSHOT enforcement rules at once.
 void removeChangeListener(RuleSetChangeListener listener)
           
 void setDefaultRule(java.lang.String defaultRule)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_RULE_LATEST_RELEASE

public static final java.lang.String DEFAULT_RULE_LATEST_RELEASE
The default rule 'LATEST RELEASE'.

See Also:
Constant Field Values

DEFAULT_RULE_SNAPSHOT

public static final java.lang.String DEFAULT_RULE_SNAPSHOT
The default rule 'SNAPSHOT'.

See Also:
Constant Field Values

DEFAULT_RULE_LATEST_RELEASE_NO_SCAN

public static final java.lang.String DEFAULT_RULE_LATEST_RELEASE_NO_SCAN
The default rule 'LATEST RELEASE (no scan)'.

The latest release will only be searched for in the scope of the dependency graph. No repository will be scanned for later releases even if it is configured to be 'scannable'.

See Also:
Constant Field Values

DEFAULT_RULE_PRESENT_RELEASE

public static final java.lang.String DEFAULT_RULE_PRESENT_RELEASE
The default rule 'PRESENT RELEASE'.

This rule is particularly useful if you want to minimize the number of changes that occur when applying the rules. Whenever a default choice must be performed, it will be the version that existed in the POM just before applying the rules. If the artifact was not present in the POM so far or if it was a SNAPSHOT the latest release will be chosen as default.

See Also:
Constant Field Values
Constructor Detail

RuleSet

public RuleSet()
Method Detail

add

public void add(Rule rule)
Adds a rule to this rule set.

Parameters:
rule - The rule to add.

remove

public void remove(Rule rule)
Removes a rule from this rule set.

Parameters:
rule - The rule to remove.

getNumberOfSnapshotEnforcements

public int getNumberOfSnapshotEnforcements()
Returns:
The number of rules enforcing a SNAPSHOT version of some artifact.

getNumberOfDerivedRules

public int getNumberOfDerivedRules()
Returns:
The number of derived rules.

removeAllSnapshotEnforcements

public void removeAllSnapshotEnforcements()
Removes all SNAPSHOT enforcement rules at once.


add

public void add(RuleSet ruleSet)
Adds all rules of the rule set to this rule set.

Parameters:
ruleSet - The rule set whose rules to add.

getEnforcementRules

public java.util.List getEnforcementRules()
Returns:
The list of rules of type EnforcementRule.

getDeprecationRules

public java.util.List getDeprecationRules()
Returns:
The list of rules of type DeprecationRule.

getReplacementRules

public java.util.List getReplacementRules()
Returns:
The list of rules of type ReplacementRule.

getRemovalRules

public java.util.List getRemovalRules()
Returns:
The list of rules of type RemovalRule.

getRetentionRules

public java.util.List getRetentionRules()
Returns:
The list of rules of type RetentionRule.

getAllRules

public java.util.List getAllRules()
Returns:
The list of all rules of base type Rule.

getEnforcedVersion

public java.lang.String getEnforcedVersion(java.lang.String artifactId)
Parameters:
artifactId - The id of the artifact to get the version to enforce for
Returns:
The version to be enforced for the artifact accoding to this rule set.

getEnforcementRule

public EnforcementRule getEnforcementRule(java.lang.String artifactId)
Parameters:
artifactId - The id of the artifact to get an enforcement rule for.
Returns:
An enforcement rule or null.

getDeprecationRule

public DeprecationRule getDeprecationRule(java.lang.String artifactId,
                                          java.lang.String version)
Parameters:
artifactId - The id of the artifact to get a deprecation rule for.
version - The version of the artifact to get a deprecation rule for.
Returns:
A deprecation rule or null.

isDeprecated

public boolean isDeprecated(java.lang.String artifactId,
                            java.lang.String version)
Parameters:
artifactId - The id of the artifact to check for.
version - The version of the artifact to check for.
Returns:
true if the version of this artifact is deprecated

getReplacementRule

public ReplacementRule getReplacementRule(java.lang.String artifactId,
                                          java.lang.String version)
Parameters:
artifactId - The id of the artifact to get a replacement rule for.
version - The version of the artifact to get a replacement rule for. Can be null.
Returns:
A replacement rule or null.

getRetentionRule

public RetentionRule getRetentionRule(java.lang.String artifactId,
                                      java.lang.String version)
Parameters:
artifactId - The id of the artifact to get a retention rule for.
version - The version of the artifact to get a retention rule for. Can be null.
Returns:
A retention rule or null.

isRemoved

public boolean isRemoved(java.lang.String artifactId,
                         java.lang.String version)
Parameters:
artifactId - The id of the artifact to check for.
version - The version of the artifact to check for.
Returns:
true if the version of this artifact is removed

getDefaultRule

public java.lang.String getDefaultRule()
Returns:
The default rule of this rule set. See DEFAULT_RULE_* constants.

setDefaultRule

public void setDefaultRule(java.lang.String defaultRule)
Parameters:
defaultRule - The default rule to set. See DEFAULT_RULE_* constants.

addChangeListener

public void addChangeListener(RuleSetChangeListener listener)
Parameters:
listener - The change listener to add.

removeChangeListener

public void removeChangeListener(RuleSetChangeListener listener)
Parameters:
listener - The change listener to remove.

hasRuleForKey

public boolean hasRuleForKey(Rule rule)
Parameters:
rule - The rule to check for.
Returns:
true if this rule set has a rule under the same key.

hasSameRule

public boolean hasSameRule(Rule rule)
Parameters:
rule - The rule to check for.
Returns:
true if this rule set has exactly this object instance of the rule passed in.

getRuleForKey

public Rule getRuleForKey(Rule rule)
Parameters:
rule - The rule instance to find under the same key.
Returns:
The rule instance found or null.

removeAllDerivedRules

public void removeAllDerivedRules()
Removes all rules of type Rule if their property 'derived' is true.


removeAllDerivedEnforcementRules

public void removeAllDerivedEnforcementRules()
Removes all rules of type EnforcementRule if their property 'derived' is true.


isRetained

public boolean isRetained(java.lang.String artifactId,
                          java.lang.String version)
Checks whether there is a retention rule that governs to retain the version of the artifact when encountered during the process of applying the rules.

Parameters:
artifactId - The artifact id of the project to check.
version - The version of the project to check.
Returns:
true if and only if there is a retention rule in this rule set that matches the artifact id (and the version).


Copyright © 2005-2007 . All Rights Reserved.