Clover icon

sunshower-base

  1. Project Clover database Fri Apr 6 2018 03:41:27 UTC
  2. Package io.sunshower.lang.tuple

File Pair.java

 

Coverage histogram

../../../../img/srcFileCovDistChart0.png
50% of files have more coverage

Code metrics

16
19
9
1
58
44
18
0.95
2.11
9
2

Classes

Class Line # Actions
Pair 6 19 18
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    package io.sunshower.lang.tuple;
2   
3    import java.util.function.Function;
4    import java.util.stream.Stream;
5   
 
6    public final class Pair<K, V> {
7   
8    public final K fst;
9    public final V snd;
10   
 
11  0 toggle public Pair(K fst, V snd) {
12  0 this.fst = fst;
13  0 this.snd = snd;
14    }
15   
 
16  0 toggle public K fst() {
17  0 return fst;
18    }
19   
 
20  0 toggle public V snd() {
21  0 return snd;
22    }
23   
 
24  0 toggle public static <K, V> Pair<K, V> of(K k, V v) {
25  0 return new Pair<>(k, v);
26    }
27   
 
28  0 toggle public static <K, V> Stream<Pair<K, V>> bindFst(K k, V v) {
29  0 return k == null ? Stream.empty() : Stream.of(of(k, v));
30    }
31   
 
32  0 toggle public <T, U> Pair<T, U> map(Function<Pair<K, V>, Pair<T, U>> f) {
33  0 return f.apply(this);
34    }
35   
 
36  0 toggle @Override
37    public String toString() {
38  0 return "(" + fst + "," + snd + ")";
39    }
40   
 
41  0 toggle @Override
42    public boolean equals(Object o) {
43  0 if (this == o) return true;
44  0 if (o == null || getClass() != o.getClass()) return false;
45   
46  0 Pair<?, ?> pair = (Pair<?, ?>) o;
47   
48  0 if (fst != null ? !fst.equals(pair.fst) : pair.fst != null) return false;
49  0 return snd != null ? snd.equals(pair.snd) : pair.snd == null;
50    }
51   
 
52  0 toggle @Override
53    public int hashCode() {
54  0 int result = fst != null ? fst.hashCode() : 0;
55  0 result = 31 * result + (snd != null ? snd.hashCode() : 0);
56  0 return result;
57    }
58    }