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

com.deque.axe.android.wrappers.AxeEventStream.kt Maven / Gradle / Ivy

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

import com.deque.axe.android.AxeEvent
import com.deque.axe.android.constants.AxeEventType
import java.util.*

class AxeEventStream : LinkedList() {
    @AxeEventType
    private val applicableEvents: MutableSet = HashSet()

    /**
     * Add a new event to the stream.
     * @param axeEvent An event.
     * @return true if the event was added successfully.
     */
    fun addEvent(axeEvent: AxeEvent): Boolean {
        if (axeEvent.isViewChangeEvent) {
            clear()
        }
        if (applicableEvents.isNotEmpty()
            && !applicableEvents.contains(axeEvent.eventType)
        ) {
            return false
        }
        if (this.size == MAX_SIZE) {
            removeAt(0)
        }
        this.add(axeEvent)
        return true
    }

    fun addApplicableEventType(@AxeEventType axeEventType: Int): AxeEventStream {
        applicableEvents.add(axeEventType)
        return this
    }

    companion object {
        private const val MAX_SIZE = 100
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy