Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit187ac4e

Browse files
committed
Making Over/Set/View use singleton instances; adding test for TypeSafeKey
1 parentc478604 commit187ac4e

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed

‎src/main/java/com/jnape/palatable/lambda/adt/hmap/TypeSafeKey.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
*
1111
* @param <T> The type of the value that this key maps to inside an HMap
1212
*/
13-
@SuppressWarnings("unused")
1413
publicinterfaceTypeSafeKey<T> {
1514

1615
/**

‎src/main/java/com/jnape/palatable/lambda/lens/functions/Over.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*/
2626
publicfinalclassOver<S,T,A,B>implementsFn3<Lens<S,T,A,B>,Function<?superA, ?extendsB>,S,T> {
2727

28+
privatestaticfinalOverINSTANCE =newOver();
29+
2830
privateOver() {
2931
}
3032

@@ -35,8 +37,9 @@ public T apply(Lens<S, T, A, B> lens, Function<? super A, ? extends B> fn, S s)
3537
.runIdentity();
3638
}
3739

40+
@SuppressWarnings("unchecked")
3841
publicstatic <S,T,A,B>Over<S,T,A,B>over() {
39-
returnnewOver<>();
42+
return(Over<S,T,A,B>)INSTANCE;
4043
}
4144

4245
publicstatic <S,T,A,B>Fn2<Function<?superA, ?extendsB>,S,T>over(

‎src/main/java/com/jnape/palatable/lambda/lens/functions/Set.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*/
2626
publicfinalclassSet<S,T,A,B>implementsFn3<Lens<S,T,A,B>,B,S,T> {
2727

28+
privatestaticfinalSetINSTANCE =newSet();
29+
2830
privateSet() {
2931
}
3032

@@ -33,8 +35,9 @@ public T apply(Lens<S, T, A, B> lens, B b, S s) {
3335
returnover(lens,constantly(b),s);
3436
}
3537

38+
@SuppressWarnings("unchecked")
3639
publicstatic <S,T,A,B>Set<S,T,A,B>set() {
37-
returnnewSet<>();
40+
returnINSTANCE;
3841
}
3942

4043
publicstatic <S,T,A,B>Fn2<B,S,T>set(Lens<S,T,A,B>lens) {

‎src/main/java/com/jnape/palatable/lambda/lens/functions/View.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
*/
2121
publicfinalclassView<S,T,A,B>implementsFn2<Lens<S,T,A,B>,S,A> {
2222

23+
privatestaticfinalViewINSTANCE =newView();
24+
2325
privateView() {
2426
}
2527

@@ -28,8 +30,9 @@ public A apply(Lens<S, T, A, B> lens, S s) {
2830
returnlens.<Const<A,T>,Const<A,B>>fix().apply(Const::new,s).runConst();
2931
}
3032

33+
@SuppressWarnings("unchecked")
3134
publicstatic <S,T,A,B>View<S,T,A,B>view() {
32-
returnnewView<>();
35+
returnINSTANCE;
3336
}
3437

3538
publicstatic <S,T,A,B>Fn1<S,A>view(Lens<S,T,A,B>lens) {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
packagecom.jnape.palatable.lambda.adt.hmap;
2+
3+
importorg.junit.Test;
4+
5+
importstaticcom.jnape.palatable.lambda.adt.hmap.TypeSafeKey.typeSafeKey;
6+
importstaticorg.junit.Assert.assertFalse;
7+
8+
publicclassTypeSafeKeyTest {
9+
10+
@Test
11+
publicvoidusesReferenceEquality() {
12+
assertFalse(typeSafeKey().equals(typeSafeKey()));
13+
}
14+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp