Skip to content

Commit 53d1a1a

Browse files
authored
Merge pull request #46 from Clexus/main
add copy to pair
2 parents 2494fe7 + e1a69d3 commit 53d1a1a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ val paperApiName = "1.21.5-R0.1-SNAPSHOT"
1515
// = = =
1616

1717
group = "cat.nyaa"
18-
version ="9.6"
18+
version ="9.7"
1919

2020
java {
2121
// Configure the java toolchain. This allows gradle to auto-provision JDK 21 on systems that only have JDK 8 installed for example.

src/main/java/cat/nyaa/nyaacore/Pair.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.Map;
44
import java.util.Objects;
5+
import java.util.function.Function;
56

67
public class Pair<K, V> implements Map.Entry<K, V> {
78

@@ -18,6 +19,16 @@ public Pair(Map.Entry<? extends K, ? extends V> entry) {
1819
this.value = entry.getValue();
1920
}
2021

22+
public Pair<K, V> copy() {
23+
return new Pair<>(this.key, this.value);
24+
}
25+
26+
public Pair<K, V> deepCopy(Function<K, K> keyMapper, Function<V, V> valueMapper) {
27+
K keyCopy = key == null ? null : keyMapper.apply(key);
28+
V valueCopy = value == null ? null : valueMapper.apply(value);
29+
return new Pair<>(keyCopy, valueCopy);
30+
}
31+
2132
public static <Ks, Vs> Pair<Ks, Vs> of(Ks key, Vs value) {
2233
return new Pair<>(key, value);
2334
}

0 commit comments

Comments
 (0)