Skip to content

Latest commit

 

History

History
47 lines (34 loc) · 1.31 KB

README.md

File metadata and controls

47 lines (34 loc) · 1.31 KB

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
// same set of overloads are also generated for Sequence, Array etc
fun <T, U> List<T>.findBy(selector: (T) -> U, predicate: (U) -> Boolean): List<T>
fun <T, U> List<T>.findBy(selector: (T) -> U, match: U): List<T>

// usage
people.findBy(Person::surname, "Papari")
people.findBy(Person::surname) { name -> name == "Papari" }

Usage

Current $VERSION is 0.1.0-SNAPSHOT

Maven

<dependency>
    <groupId>net.onedaybeard.collections-by</groupId>
    <artifactId>core</artifactId>
    <version>${VERSION}</version>
</dependency>

Gradle

implementation "net.onedaybeard.collections-by:core:${VERSION}"

Direct download

$ java -ea -javaagent:agent-${VERSION}.jar ...