https://github.com/junkdog/collections-by
https://github.com/junkdog/collections-by
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/junkdog/collections-by
- Owner: junkdog
- License: mit
- Created: 2020-06-10T10:24:25.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-07-13T09:57:32.000Z (about 1 year ago)
- Last Synced: 2025-10-21T06:26:16.755Z (9 months ago)
- Language: Kotlin
- Size: 62.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# collections-by - extensions for Sequence and Iterable
Provides overloaded functions - for `Iterable`, `Sequenece`, `List`
and `Array` - taking a predicate. Overloaded functions take an additional
`selector` parameter, in addition to predicate or object to match.
E.g.`findBy`, `removeAllBy`.
Two overloads are generated for each function and underlying collection:
- with selector and object-to-equal
- with selector and predicate
```kotlin
// same set of overloads are also generated for Sequence, Array etc
fun List.findBy(selector: (T) -> U, predicate: (U) -> Boolean): List
fun List.findBy(selector: (T) -> U, match: U): List
// usage
people.findBy(Person::surname, "Papari")
people.findBy(Person::surname) { name -> name == "Papari" }
```
## Usage
Current `$VERSION` is `0.1.0-SNAPSHOT`
### Maven
```xml
net.onedaybeard.collections-by
core
${VERSION}
```
### Gradle
```groovy
implementation "net.onedaybeard.collections-by:core:${VERSION}"
```
### Direct download
`$ java -ea -javaagent:agent-${VERSION}.jar` ...
- [Snapshot](https://oss.sonatype.org/content/repositories/snapshots/net/onedaybeard/collections-by/)
- [Release](http://repo1.maven.org/maven2/net/onedaybeard/collections-by/)