11/*
2- * Copyright (c) 2022 XPATH-QS
2+ * Copyright (c) 2024 XPATH-QS
33 *
44 * Permission is hereby granted, free of charge, to any person obtaining a copy
55 * of this software and associated documentation files (the "Software"), to deal
@@ -30,10 +30,9 @@ import kotlin.reflect.KClass
3030 * returns true if provided annotation is present
3131 * in the selector's annotation list
3232 */
33- fun BaseSelector.hasAnnotation (annotation : KClass <* >)
34- = annotations.find {
33+ fun BaseSelector.hasAnnotation (annotation : KClass <* >) = annotations.any {
3534 it.annotationClass.qualifiedName?.removeSuffix(" .Container" ) == annotation.qualifiedName
36- } != null
35+ }
3736
3837/* *
3938 * returns true if provided annotation is present
@@ -58,8 +57,9 @@ fun BaseSelector.hasParentAnnotation(annotation: KClass<*>)
5857 * Require #2 - when parent [org.xpathqs.core.selector.block.Block] doesn't has provided annotation - return false
5958 * @sample [org.xpathqs.core.selector.base.BaseSelectorAnnotationsTest.r2_hasParentAnnotation]
6059 */
61- fun BaseSelector.hasAnyParentAnnotation (annotation : KClass <* >)
62- = this .parents.find { it.hasAnnotation(annotation) } != null
60+ fun BaseSelector.hasAnyParentAnnotation (annotation : KClass <* >) = this .parents.any {
61+ it.hasAnnotation(annotation)
62+ }
6363
6464/* *
6565 * @return provided annotation object
@@ -76,10 +76,11 @@ inline fun<reified T> BaseSelector.findAnnotation(): T? {
7676 } as ? T
7777}
7878
79+ @Suppress(" UNCHECKED_CAST" )
7980inline fun <reified T > BaseSelector.findAnnotations (): Collection <T > {
8081 return annotations.filter {
8182 it.annotationClass.qualifiedName?.removeSuffix(" .Container" ) == T ::class .qualifiedName
82- } as Collection <T >
83+ } as List <T >
8384}
8485/* *
8586 * @return provided annotation object of parent [org.xpathqs.core.selector.block.Block]
0 commit comments