All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.deque.axe.android.AxeResult.kt Maven / Gradle / Ivy

There is a newer version: 5.5.2
Show newest version
package com.deque.axe.android

import com.deque.axe.android.constants.AxeStatus
import java.util.LinkedList

open class AxeResult @JvmOverloads constructor(
    @JvmField val axeConf: AxeConf?,
    @JvmField val axeContext: AxeContext?,
    @JvmField val axeRuleResults: MutableList? = LinkedList(),
    @JvmField var scanName: String? = "",
    @JvmField var tags: Set? = setOf()
) {
    fun add(axeRuleResult: AxeRuleResult) {
        if (axeRuleResult.status != AxeStatus.INAPPLICABLE) {
            axeRuleResults?.add(axeRuleResult)
        }
    }

    /**
     * Query the list of Rule Results for a particular subset of results.
     * @param filter The matcher to filter on.
     * @return The list of results that match the filter.
     */
    fun query(filter: AxeRuleResult.Matcher): List {

        // Micro optimization. Init with size / 2. Results will always be larger than the filtered set.
        val results = ArrayList(
            axeRuleResults?.let { it.size / 2 } ?: 0
        )
        axeRuleResults?.let {
            for (ruleResult in axeRuleResults) {
                if (filter.matches(ruleResult)) {
                    results.add(ruleResult)
                }
            }
        }
        return results
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy