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

ru.yandex.qatools.allure.plugins.DefaultAttachmentsIndex.groovy Maven / Gradle / Ivy

There is a newer version: 1.5.4
Show newest version
package ru.yandex.qatools.allure.plugins

import groovy.transform.CompileStatic
import ru.yandex.qatools.allure.AttachmentInfo

import static java.util.Collections.unmodifiableList

/**
 * The default implementation of {@link AttachmentsIndex}.
 * There is two different indexes: by id and by source.
 *
 * @author Dmitry Baev [email protected]
 *         Date: 10.07.15
 */
@CompileStatic
class DefaultAttachmentsIndex implements AttachmentsIndex {

    private final Map byUid = [:]

    private final Map bySource = [:]

    /**
     * Creates an instance of index.
     */
    public DefaultAttachmentsIndex(List infoList) {
        for (def info : infoList) {
            byUid[info.uid] = info
            bySource[info.source] = info
        }
    }

    /**
     * @inheritDoc
     */
    @Override
    AttachmentInfo find(String uid) {
        byUid[uid]
    }

    /**
     * @inheritDoc
     */
    @Override
    AttachmentInfo findBySource(String source) {
        bySource[source]
    }

    /**
     * @inheritDoc
     */
    @Override
    List findAll() {
        unmodifiableList(byUid.values() as List)
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy