Skip to content

Commit

Permalink
Update BaseFinder & Bump version to 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
KyuubiRan committed May 21, 2024
1 parent e4a2243 commit 1f40c82
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 6 deletions.
8 changes: 8 additions & 0 deletions EzXHelper/api/EzXHelper.api
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,14 @@ public abstract class com/github/kyuubiran/ezxhelper/finders/base/BaseFinder : c
public final fun plusAssign (Ljava/lang/Iterable;)V
public final fun plusAssign (Lkotlin/sequences/Sequence;)V
public final fun plusAssign ([Ljava/lang/Object;)V
public final fun requireCount (I)Ljava/lang/Object;
public final fun requireCount (Lkotlin/jvm/functions/Function1;I)Ljava/lang/Object;
public final fun requireCount (Lkotlin/jvm/functions/Function1;Lkotlin/ranges/IntRange;)Ljava/lang/Object;
public final fun requireCount (Lkotlin/ranges/IntRange;)Ljava/lang/Object;
public final fun requireCountOrNull (I)Ljava/lang/Object;
public final fun requireCountOrNull (Lkotlin/jvm/functions/Function1;I)Ljava/lang/Object;
public final fun requireCountOrNull (Lkotlin/jvm/functions/Function1;Lkotlin/ranges/IntRange;)Ljava/lang/Object;
public final fun requireCountOrNull (Lkotlin/ranges/IntRange;)Ljava/lang/Object;
public final fun requireSingle ()Ljava/lang/Object;
public final fun requireSingle (Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public final fun requireSingleOrNull ()Ljava/lang/Object;
Expand Down
2 changes: 1 addition & 1 deletion EzXHelper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
id 'signing'
}

def versionName = "2.1.2"
def versionName = "2.2.0"

android {
compileSdkVersion = 34
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,54 @@ abstract class BaseFinder<T, Self>(protected var sequence: Sequence<T>) : INamed
return if (o == null) null else this as Self
}

@Throws(IllegalStateException::class)
fun requireCount(count: Int) = applyThis {
if (sequence.count() != count) {
throw IllegalStateException("The count of sequence is not $count")
}
}

@Suppress("UNCHECKED_CAST")
fun requireCountOrNull(count: Int): Self? {
return if (sequence.count() == count) this as Self else null
}

@Throws(IllegalStateException::class)
fun requireCount(condition: T.() -> Boolean, count: Int) = applyThis {
if (sequence.count(condition) != count) {
throw IllegalStateException("The count of sequence is not $count")
}
}

@Suppress("UNCHECKED_CAST")
fun requireCountOrNull(condition: T.() -> Boolean, count: Int): Self? {
return if (sequence.count(condition) == count) this as Self else null
}

@Throws(IllegalStateException::class)
fun requireCount(range: IntRange) = applyThis {
if (sequence.count() !in range) {
throw IllegalStateException("The count of sequence is not in $range")
}
}

@Suppress("UNCHECKED_CAST")
fun requireCountOrNull(range: IntRange): Self? {
return if (sequence.count() in range) this as Self else null
}

@Throws(IllegalStateException::class)
fun requireCount(condition: T.() -> Boolean, range: IntRange) = applyThis {
if (sequence.count(condition) !in range) {
throw IllegalStateException("The count of sequence is not in $range")
}
}

@Suppress("UNCHECKED_CAST")
fun requireCountOrNull(condition: T.() -> Boolean, range: IntRange): Self? {
return if (sequence.count(condition) in range) this as Self else null
}

/**
* Get the single element or throw an exception if there is no such element or more than one element.
*/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
加入Telegram群组来获取帮助: [![Telegram](https://img.shields.io/badge/Join-Telegram-blue)](https://t.me/EzXHelper)

一个使Xposed模块开发变的更轻松的工具库,2.x版本已支持Java!
2.x版本已经发布!最新版为`2.1.2` 旧版本请看`1.x`分支
2.x版本已经发布!最新版为`2.2.0` 旧版本请看`1.x`分支

### 使用本库的项目

Expand Down
2 changes: 1 addition & 1 deletion README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Join Telegram group to get
help: [![Telegram](https://img.shields.io/badge/Join-Telegram-blue)](https://t.me/EzXHelper)

A library to make Xposed modules development easier, 2.x version supports Java!
2.x is released now! The latest version is `2.1.2`. Old version please look the `1.x` branch.
2.x is released now! The latest version is `2.2.0`. Old version please look the `1.x` branch.

### Projects that use this library

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '8.3.0' apply false
id 'com.android.library' version '8.3.0' apply false
id 'com.android.application' version '8.4.0' apply false
id 'com.android.library' version '8.4.0' apply false
id 'org.jetbrains.kotlin.android' version '1.9.22' apply false
id 'org.jetbrains.dokka' version '1.9.10' apply false
id 'org.jetbrains.kotlinx.binary-compatibility-validator' version '0.13.2'
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 1f40c82

Please sign in to comment.