Skip to content

Commit c2a126a

Browse files
committed
Added NonEmptyList.hashCode(), Hash.bigintHash, Hash.bigdecimalHash
1 parent 69b3865 commit c2a126a

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

core/src/main/java/fj/Hash.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
import fj.data.vector.V7;
1212
import fj.data.vector.V8;
1313

14+
import java.math.BigDecimal;
15+
import java.math.BigInteger;
16+
1417
/**
1518
* Produces a hash code for an object which should attempt uniqueness.
1619
*
@@ -102,6 +105,16 @@ public static <A> Hash<A> anyHash() {
102105
*/
103106
public static final Hash<Short> shortHash = anyHash();
104107

108+
/**
109+
* A hash instance for the <code>BigInteger</code> type.
110+
*/
111+
public static final Hash<BigInteger> bigintHash = anyHash();
112+
113+
/**
114+
* A hash instance for the <code>BigDecimal</code> type.
115+
*/
116+
public static final Hash<BigDecimal> bigdecimalHash = anyHash();
117+
105118
/**
106119
* A hash instance for the <code>String</code> type.
107120
*/

core/src/main/java/fj/data/NonEmptyList.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package fj.data;
22

3-
import fj.Equal;
4-
import fj.F;
5-
import fj.F1Functions;
6-
import fj.Show;
3+
import fj.*;
74
import fj.function.Effect1;
85

96
import java.util.Collection;
@@ -226,5 +223,9 @@ public static <A> Option<NonEmptyList<A>> fromList(final List<A> as) {
226223
return Equal.equals0(NonEmptyList.class, this, obj, () -> Equal.nonEmptyListEqual(Equal.<A>anyEqual()));
227224
}
228225

226+
@Override public int hashCode() {
227+
return Hash.nonEmptyListHash(Hash.<A>anyHash()).hash(this);
228+
}
229+
229230
@Override public String toString() { return Show.nonEmptyListShow(Show.<A>anyShow()).showS(this); }
230231
}

0 commit comments

Comments
 (0)