org.sonar.api.rules
Class Rule

java.lang.Object
  extended by org.sonar.api.rules.Rule

public class Rule
extends Object


Field Summary
static RulePriority DEFAULT_PRIORITY
          The default priority given to a rule if not explicitly set
static String STATUS_BETA
           
static String STATUS_DEPRECATED
           
static String STATUS_READY
           
static String STATUS_REMOVED
          For internal use only.
 
Constructor Summary
Rule()
          Deprecated. since 2.3. Use the factory method create()
Rule(String pluginName, String key)
          Deprecated. since 2.3. Use the factory method create()
 
Method Summary
static Rule create()
           
static Rule create(String repositoryKey, String key)
          Create with all required fields
static Rule create(String repositoryKey, String key, String name)
          Create with all required fields
 RuleParam createParameter()
           
 RuleParam createParameter(String key)
           
 boolean equals(Object obj)
           
 Cardinality getCardinality()
           
 Integer getCategoryId()
          Deprecated. since 2.5. See http://jira.codehaus.org/browse/SONAR-2007
 Integer getCharacteristicId()
          For internal use only.
 String getConfigKey()
           
 Date getCreatedAt()
           
 Integer getDefaultCharacteristicId()
          For internal use only.
 String getDescription()
           
 Integer getId()
           
 String getKey()
           
 String getLanguage()
           
 String getName()
           
 RuleParam getParam(String key)
           
 List<RuleParam> getParams()
           
 Rule getParent()
           
 String getPluginName()
          Deprecated. since 2.5 use getRepositoryKey() instead
 RulePriority getPriority()
          Deprecated. since 2.5 use getSeverity() instead. See http://jira.codehaus.org/browse/SONAR-1829
 String getRepositoryKey()
           
 RulePriority getSeverity()
           
 String getStatus()
           
 String[] getTags()
          For definition of rule only
 Date getUpdatedAt()
           
 int hashCode()
           
 Boolean isEnabled()
           
 RuleKey ruleKey()
           
 Rule setCardinality(Cardinality c)
           
 Rule setCharacteristicId(Integer characteristicId)
          For internal use only.
 Rule setConfigKey(String configKey)
          Sets the configuration key
 Rule setCreatedAt(Date d)
           
 Rule setDefaultCharacteristicId(Integer defaultCharacteristicId)
          For internal use only.
 Rule setDescription(String description)
          Sets the rule description
 Rule setEnabled(Boolean enabled)
          Deprecated. in 3.6. Replaced by setStatus(String status).
 void setId(Integer id)
          Deprecated. since 2.3. visibility should be decreased to protected or package
 Rule setKey(String key)
          Sets the rule key
 Rule setLanguage(String language)
          For internal use only.
 Rule setName(String name)
          Sets the rule name
 Rule setParams(List<RuleParam> params)
          Sets the rule parameters
 Rule setParent(Rule parent)
           
 Rule setPluginName(String pluginName)
          Deprecated. since 2.5 use setRepositoryKey(String) instead
 Rule setPriority(RulePriority priority)
          Deprecated. since 2.5 use setSeverity(RulePriority) instead. See http://jira.codehaus.org/browse/SONAR-1829
 Rule setRepositoryKey(String s)
           
 Rule setSeverity(RulePriority severity)
           
 Rule setStatus(String status)
           
 void setTags(String[] tags)
          For definition of rule only
 Rule setUniqueKey(String repositoryKey, String key)
           
 Rule setUpdatedAt(Date updatedAt)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

STATUS_BETA

public static final String STATUS_BETA
Since:
3.6
See Also:
Constant Field Values

STATUS_DEPRECATED

public static final String STATUS_DEPRECATED
Since:
3.6
See Also:
Constant Field Values

STATUS_READY

public static final String STATUS_READY
Since:
3.6
See Also:
Constant Field Values

STATUS_REMOVED

public static final String STATUS_REMOVED
For internal use only.

Since:
3.6
See Also:
Constant Field Values

DEFAULT_PRIORITY

public static final RulePriority DEFAULT_PRIORITY
The default priority given to a rule if not explicitly set

Constructor Detail

Rule

@Deprecated
public Rule()
Deprecated. since 2.3. Use the factory method create()


Rule

@Deprecated
public Rule(String pluginName,
                       String key)
Deprecated. since 2.3. Use the factory method create()

Creates rule with minimum set of info

Parameters:
pluginName - the plugin name indicates which plugin the rule belongs to
key - the key should be unique within a plugin, but it is even more careful for the time being that it is unique across the application
Method Detail

getId

public Integer getId()

setId

@Deprecated
public void setId(Integer id)
Deprecated. since 2.3. visibility should be decreased to protected or package


getName

@CheckForNull
public String getName()

setName

public Rule setName(@Nullable
                    String name)
Sets the rule name


getKey

public String getKey()

setKey

public Rule setKey(String key)
Sets the rule key


getPluginName

@Deprecated
public String getPluginName()
Deprecated. since 2.5 use getRepositoryKey() instead


setPluginName

@Deprecated
public Rule setPluginName(String pluginName)
Deprecated. since 2.5 use setRepositoryKey(String) instead


getConfigKey

public String getConfigKey()

setConfigKey

public Rule setConfigKey(String configKey)
Sets the configuration key


getDescription

public String getDescription()

setDescription

public Rule setDescription(String description)
Sets the rule description


setEnabled

@Deprecated
public Rule setEnabled(Boolean enabled)
Deprecated. in 3.6. Replaced by setStatus(String status).


isEnabled

public Boolean isEnabled()

getParams

public List<RuleParam> getParams()

getParam

public RuleParam getParam(String key)

setParams

public Rule setParams(List<RuleParam> params)
Sets the rule parameters


createParameter

public RuleParam createParameter()

createParameter

public RuleParam createParameter(String key)

getCategoryId

@Deprecated
public Integer getCategoryId()
Deprecated. since 2.5. See http://jira.codehaus.org/browse/SONAR-2007


getSeverity

public RulePriority getSeverity()
Since:
2.5

setSeverity

public Rule setSeverity(RulePriority severity)
Parameters:
severity - severity to set, if null, uses the default priority.
Since:
2.5

getPriority

@Deprecated
public RulePriority getPriority()
Deprecated. since 2.5 use getSeverity() instead. See http://jira.codehaus.org/browse/SONAR-1829


setPriority

@Deprecated
public Rule setPriority(RulePriority priority)
Deprecated. since 2.5 use setSeverity(RulePriority) instead. See http://jira.codehaus.org/browse/SONAR-1829

Sets the rule priority. If null, uses the default priority


getRepositoryKey

public String getRepositoryKey()

setRepositoryKey

public Rule setRepositoryKey(String s)

setUniqueKey

public Rule setUniqueKey(String repositoryKey,
                         String key)

getCardinality

public Cardinality getCardinality()

setCardinality

public Rule setCardinality(Cardinality c)

getParent

public Rule getParent()

setParent

public Rule setParent(Rule parent)

getStatus

public String getStatus()
Since:
3.6

setStatus

public Rule setStatus(String status)
Since:
3.6

getCreatedAt

public Date getCreatedAt()
Since:
3.6

setCreatedAt

public Rule setCreatedAt(Date d)
Since:
3.6

getUpdatedAt

public Date getUpdatedAt()
Since:
3.6

setUpdatedAt

public Rule setUpdatedAt(Date updatedAt)
Since:
3.6

getLanguage

public String getLanguage()
Since:
3.6

setLanguage

public Rule setLanguage(String language)
For internal use only.

Since:
3.6

getTags

public String[] getTags()
For definition of rule only


setTags

public void setTags(String[] tags)
For definition of rule only


getCharacteristicId

@CheckForNull
public Integer getCharacteristicId()
For internal use only.

Since:
4.3

setCharacteristicId

public Rule setCharacteristicId(@Nullable
                                Integer characteristicId)
For internal use only.

Since:
4.3

getDefaultCharacteristicId

@CheckForNull
public Integer getDefaultCharacteristicId()
For internal use only.

Since:
4.3

setDefaultCharacteristicId

public Rule setDefaultCharacteristicId(@Nullable
                                       Integer defaultCharacteristicId)
For internal use only.

Since:
4.3

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

create

public static Rule create()

create

public static Rule create(String repositoryKey,
                          String key,
                          String name)
Create with all required fields


create

public static Rule create(String repositoryKey,
                          String key)
Create with all required fields

Since:
2.10

ruleKey

public RuleKey ruleKey()
Since:
3.6


Copyright © 2009-2014 SonarSource. All Rights Reserved.