diff --git a/.github/workflows/build-and-publish.yaml b/.github/workflows/build-and-publish.yaml index 2674794..12a35af 100644 --- a/.github/workflows/build-and-publish.yaml +++ b/.github/workflows/build-and-publish.yaml @@ -8,7 +8,7 @@ on: jobs: build-and-publish: name: Java Gradle - uses: bakdata/ci-templates/.github/workflows/java-gradle-library.yaml@1.40.6 + uses: bakdata/ci-templates/.github/workflows/java-gradle-library.yaml@1.41.0 with: java-version: 17 secrets: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6a30c40..b883cbc 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -16,7 +16,7 @@ on: jobs: java-gradle-release: name: Java Gradle - uses: bakdata/ci-templates/.github/workflows/java-gradle-release.yaml@1.40.6 + uses: bakdata/ci-templates/.github/workflows/java-gradle-release.yaml@1.41.0 with: java-version: 17 release-type: "${{ inputs.release-type }}" diff --git a/build.gradle.kts b/build.gradle.kts index 6f2deb8..c3d3b1d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { `java-library` id("net.researchgate.release") version "3.0.2" id("com.bakdata.sonar") version "1.1.17" - id("com.bakdata.sonatype") version "1.1.14" + id("com.bakdata.sonatype") version "1.2.1" id("org.hildan.github.changelog") version "2.2.0" id("io.freefair.lombok") version "8.4" } diff --git a/src/main/java/com/bakdata/util/seq2/Seq2.java b/src/main/java/com/bakdata/util/seq2/Seq2.java index 090a0ef..80b2b05 100644 --- a/src/main/java/com/bakdata/util/seq2/Seq2.java +++ b/src/main/java/com/bakdata/util/seq2/Seq2.java @@ -1064,6 +1064,15 @@ default PairSeq selectKey(final Function keyMa return this.mapToPair(keyMapper, Function.identity()); } + /** + * Map a {@code Seq2} to a {@code PairSeq} + * + * @see Seq#map(Function) + */ + default PairSeq selectValue(final Function valueMapper) { + return this.mapToPair(Function.identity(), valueMapper); + } + @Override default Seq2 sequential() { return seq(this.toSeq().sequential()); diff --git a/src/test/java/com/bakdata/util/seq2/Seq2Test.java b/src/test/java/com/bakdata/util/seq2/Seq2Test.java index fe2f2e3..ea10fce 100644 --- a/src/test/java/com/bakdata/util/seq2/Seq2Test.java +++ b/src/test/java/com/bakdata/util/seq2/Seq2Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c), 2023 bakdata GmbH + * Copyright (c), 2024 bakdata GmbH * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -67,6 +67,14 @@ void shouldSelectKey() { .containsExactlyInAnyOrder(new Tuple2<>(2, 1), new Tuple2<>(3, 2)); } + @Test + void shouldSelectValue() { + assertThat((Stream>) Seq2.seq(List.of(1, 2)) + .selectValue(i -> i + 1)) + .hasSize(2) + .containsExactlyInAnyOrder(new Tuple2<>(1, 2), new Tuple2<>(2, 3)); + } + @Test void shouldFlatMapToOptionalPair() { assertThat((Stream>) Seq2.seq(List.of(1, 2))