com.deque.axe.android.AxeConf.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of axe-devtools-android-core Show documentation
Show all versions of axe-devtools-android-core Show documentation
The Axe Devtools Android Core Library
package com.deque.axe.android
import com.deque.axe.android.conf.IssueFilterConf
import com.deque.axe.android.conf.RuleConf
import com.deque.axe.android.constants.AxeImpact
import com.deque.axe.android.constants.AxeStandard
import com.deque.axe.android.constants.Constants
import com.deque.axe.android.rules.hierarchy.ActiveViewName
import com.deque.axe.android.rules.hierarchy.CheckBoxName
import com.deque.axe.android.rules.hierarchy.ColorContrast
import com.deque.axe.android.rules.hierarchy.EditTextName
import com.deque.axe.android.rules.hierarchy.EditTextValue
import com.deque.axe.android.rules.hierarchy.ImageViewName
import com.deque.axe.android.rules.hierarchy.SwitchName
import com.deque.axe.android.rules.hierarchy.TouchSizeWcag
class AxeConf constructor(
/**
* A Set of AxeTypes to include in this AxeRun.
*/
@JvmField @AxeStandard val standards: MutableSet,
/**
* A set of AxeRules that will be included Regardless of any other setting.
*/
@JvmField val ruleIds: MutableSet,
@JvmField @Deprecated( "Use RuleConf.ignored field instead") val rules: MutableMap = HashMap(),
@JvmField val issueFilterConf: IssueFilterConf = IssueFilterConf(),
@JvmField @Transient val customRules: MutableSet> = mutableSetOf()
) {
companion object {
/**
* The default standards to apply to every new Axe Instance.
*/
@AxeStandard
private val DEFAULT_STANDARDS: MutableSet = HashSet()
init {
DEFAULT_STANDARDS.add(AxeStandard.BEST_PRACTICE)
DEFAULT_STANDARDS.add(AxeStandard.PLATFORM)
DEFAULT_STANDARDS.add(AxeStandard.WCAG_20)
DEFAULT_STANDARDS.add(AxeStandard.WCAG_21)
}
}
constructor() : this(
standards = DEFAULT_STANDARDS,
ruleIds = HashSet(),
rules = HashMap(),
issueFilterConf = IssueFilterConf(),
customRules = HashSet()
)
fun ruleInstances(): Set {
val ruleInstances: MutableSet = HashSet()
try {
for (axeRuleClass in Constants.AXE_RULE_CLASSES) {
val axeRule = axeRuleClass.newInstance()
ruleInstances.add(axeRule)
ruleIds.add(axeRule.javaClass.simpleName)
rules[axeRuleClass.simpleName] = RuleConf(
axeRule.impact,
axeRule.standard,
axeRule.summary,
axeRule.experimental
)
}
for (axeRuleClass in customRules) {
val customRuleInstance = axeRuleClass.newInstance()
ruleInstances.add(customRuleInstance)
ruleIds.add(axeRuleClass.simpleName)
rules[axeRuleClass.simpleName] = RuleConf(
customRuleInstance.impact,
customRuleInstance.standard,
customRuleInstance.summary,
customRuleInstance.experimental
)
}
} catch (e: Exception) {
throw RuntimeException(e)
}
return ruleInstances
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as AxeConf
if (standards != other.standards) return false
if (ruleIds != other.ruleIds) return false
if (rules != other.rules) return false
if (issueFilterConf != other.issueFilterConf) return false
if (customRules != other.customRules) return false
return true
}
override fun hashCode(): Int {
var result = standards.hashCode()
result = 31 * result + ruleIds.hashCode()
result = 31 * result + rules.hashCode()
result = 31 * result + issueFilterConf.hashCode()
result = 31 * result + customRules.hashCode()
return result
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy