
com.ybo.trackingplugin.tasks.utils.TextExtractor.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of traceplugin Show documentation
Show all versions of traceplugin Show documentation
gradle plugin allowing to add automatic logs (or other process) at the start of each traced method
package com.ybo.trackingplugin.tasks.utils
import com.ybo.trackingplugin.tasks.utils.impl.patterns.PatternName
/**
* object than has some patterns to search in text, and extract their manifestation in the text
* as objects.
*It delivers them as a sorted list.
*/
class TextExtractor(
private val patternProducer: PatternProducer,
private val patternSearcher: PatternSearcher,
private val resultSorter: ResultSorter = NoSortSorter(),
) {
fun extract(
text: String,
): List {
return patternProducer
.produce()
.let { producedPatterns ->
patternSearcher.search(text, producedPatterns)
}.flatMap { group ->
group.results
}.let {
resultSorter.sort(it)
}
}
private class NoSortSorter : ResultSorter {
override fun sort(list: List): List {
return list
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy