com.datadog.gradle.plugin.licenses.utils.NodeListSequence.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dependency-license Show documentation
Show all versions of dependency-license Show documentation
This plugin generates the OSS licenses csv file for all dependencies.
The newest version!
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2016-Present Datadog, Inc.
*/
package com.datadog.gradle.plugin.licenses.utils
import org.w3c.dom.Node
import org.w3c.dom.NodeList
import kotlin.collections.Iterator as KIterator
internal class NodeListSequence(
private val nodeList: NodeList,
) : Sequence {
override fun iterator(): KIterator {
return Iterator(nodeList)
}
class Iterator(
private val nodeList: NodeList,
) : KIterator {
private var i = 0
override fun hasNext() = i < nodeList.length
override fun next(): Node = if (i < nodeList.length) {
nodeList.item(i++)
} else {
throw NoSuchElementException("There's no next element!")
}
}
}
internal fun NodeList.asSequence() = NodeListSequence(this)