com.seventytwomiles.architecturerules.domain
Class Rule

java.lang.Object
  extended by com.seventytwomiles.architecturerules.domain.Rule

public class Rule
extends java.lang.Object

Represents a Rule that may not be violoated.

Author:
mikenereson

Constructor Summary
Rule()
          Constructs a new Rule.
Rule(java.lang.String id)
          Instantiates a new Rule with the given id.
Rule(java.lang.String id, java.lang.String packageName)
          Instantiates a new Rule with the given id.
 
Method Summary
 boolean addPackage(java.lang.String packageName)
          Adds a package to the Packages collection.
 boolean addViolation(java.lang.String violation)
          Add a new violation to this Rule.
 java.lang.String describe()
          Describes the properties of this rule in an xml-like format.
 java.lang.String describePackages()
           
 boolean equals(java.lang.Object object)
           
 java.lang.String getComment()
          Getter for property comment.
 java.lang.String getDescriptionOfRule()
           
 java.lang.String getId()
          Getter for property id.
 java.util.Collection getPackages()
          Getter for property packages
 java.util.Collection getViolations()
          Get all of the violations.
 int hashCode()
           
 boolean removeViolation(java.lang.String violation)
          Remove a violation from this Rule.
 void setComment(java.lang.String comment)
          Setter for property comment.
 void setId(java.lang.String id)
          Setter for property id.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rule

public Rule()

Constructs a new Rule.


Rule

public Rule(java.lang.String id)

Instantiates a new Rule with the given id.

Parameters:
id - sets the id

Rule

public Rule(java.lang.String id,
            java.lang.String packageName)

Instantiates a new Rule with the given id.

This constructor is to provide some sense of backwards compatibility with the releases in series 1 (1.0 and 1.1)

Parameters:
id - sets the id
packageName - a @packages to assert on.
Method Detail

addPackage

public boolean addPackage(java.lang.String packageName)

Adds a package to the Packages collection.

Parameters:
packageName - String
Returns:
boolean true when the package is actually added to the Collection. false would be returned if the package was already in the Collection of packages.

getComment

public java.lang.String getComment()

Getter for property comment.

Returns:
Value for property comment.

setComment

public void setComment(java.lang.String comment)

Setter for property comment.

Parameters:
comment - Value to set for property comment.

getId

public java.lang.String getId()

Getter for property id.

Returns:
Value for property id.

setId

public void setId(java.lang.String id)

Setter for property id.

Parameters:
id - Value to set for property id.

getPackages

public java.util.Collection getPackages()

Getter for property packages

Returns:
Value for property packages.

equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(Object)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

addViolation

public boolean addViolation(java.lang.String violation)

Add a new violation to this Rule.

Parameters:
violation - String a package this this Rule's package may NOT depend upon
Returns:
boolean true if the violation is added to the List of violations. false would be returned if the violation could not be added to the List.
Throws:
IllegalArchitectureRuleException - a RuntimeException when the violation could not be added because the violation is one of the packages being checked.

describe

public java.lang.String describe()

Describes the properties of this rule in an xml-like format.

Returns:
String of xml that describes this Rule.

getDescriptionOfRule

public java.lang.String getDescriptionOfRule()

describePackages

public java.lang.String describePackages()

getViolations

public java.util.Collection getViolations()

Get all of the violations.

Note: this Collection is unmodifiable, use addViolation(java.lang.String) and removeViolation(java.lang.String)

Returns:
Collection unmodifiable
Throws:
java.lang.UnsupportedOperationException - when getViolations.add(Object) or getViolations.remove(Object) is called. Use addViolation(java.lang.String) and removeViolation(java.lang.String).

removeViolation

public boolean removeViolation(java.lang.String violation)

Remove a violation from this Rule.

Parameters:
violation - String a package this this Rule's package should not test on
Returns:
boolean true if the violation is removed from the List of violations


Copyright © 2008. All Rights Reserved.