Skip to content

Commit 4b053ca

Browse files
committed
Make use of type inference
1 parent a93c54c commit 4b053ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1074
-1075
lines changed

core/src/main/java/fj/Class.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public static Tree<Type> typeParameterTree(final Type t) {
101101
}
102102
types = Tree.node(pt.getRawType(), typeArgs);
103103
} else {
104-
types = Tree.node(t, List.<Tree<Type>>nil());
104+
types = Tree.node(t, List.nil());
105105
}
106106
return types;
107107
}
@@ -122,6 +122,6 @@ public java.lang.Class<T> clas() {
122122
* @return A class from the given argument.
123123
*/
124124
public static <T> Class<T> clas(final java.lang.Class<T> c) {
125-
return new Class<T>(c);
125+
return new Class<>(c);
126126
}
127127
}

core/src/main/java/fj/Equal.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public F<A, Boolean> eq(final A a) {
7575
* @return A new equal.
7676
*/
7777
public <B> Equal<B> contramap(final F<B, A> f) {
78-
return equal(F1Functions.o(F1Functions.o(F1Functions.<B, A, Boolean>andThen(f), this.f), f));
78+
return equal(F1Functions.o(F1Functions.o(F1Functions.andThen(f), this.f), f));
7979
}
8080

8181
/**
@@ -85,7 +85,7 @@ public <B> Equal<B> contramap(final F<B, A> f) {
8585
* @return An equal instance from the given function.
8686
*/
8787
public static <A> Equal<A> equal(final F<A, F<A, Boolean>> f) {
88-
return new Equal<A>(f);
88+
return new Equal<>(f);
8989
}
9090

9191
/**
@@ -202,7 +202,7 @@ public static <A, B> Equal<Either<A, B>> eitherEqual(final Equal<A> ea, final Eq
202202
* @return An equal instance for the {@link Validation} type.
203203
*/
204204
public static <A, B> Equal<Validation<A, B>> validationEqual(final Equal<A> ea, final Equal<B> eb) {
205-
return eitherEqual(ea, eb).contramap(Validation.<A, B>either());
205+
return eitherEqual(ea, eb).contramap(Validation.either());
206206
}
207207

208208
/**
@@ -235,7 +235,7 @@ public static <A> Equal<List<A>> listEqual(final Equal<A> ea) {
235235
* @return An equal instance for the {@link NonEmptyList} type.
236236
*/
237237
public static <A> Equal<NonEmptyList<A>> nonEmptyListEqual(final Equal<A> ea) {
238-
return listEqual(ea).contramap(NonEmptyList.<A>toList_());
238+
return listEqual(ea).contramap(NonEmptyList.toList_());
239239
}
240240

241241
/**
@@ -302,7 +302,7 @@ public static <A> Equal<Array<A>> arrayEqual(final Equal<A> ea) {
302302
* @return An equal instance for the {@link Tree} type.
303303
*/
304304
public static <A> Equal<Tree<A>> treeEqual(final Equal<A> ea) {
305-
return Equal.<Tree<A>>equal(curry((t1, t2) -> ea.eq(t1.root(), t2.root()) && p1Equal(streamEqual(Equal.<A>treeEqual(ea))).eq(t2.subForest(), t1.subForest())));
305+
return Equal.equal(curry((t1, t2) -> ea.eq(t1.root(), t2.root()) && p1Equal(streamEqual(Equal.treeEqual(ea))).eq(t2.subForest(), t1.subForest())));
306306
}
307307

308308
/**
@@ -443,7 +443,7 @@ public static <A, B, C, D, E> Equal<P5<A, B, C, D, E>> p5Equal(final Equal<A> ea
443443
* @return An equal instance for a vector-2.
444444
*/
445445
public static <A> Equal<V2<A>> v2Equal(final Equal<A> ea) {
446-
return streamEqual(ea).contramap(V2.<A>toStream_());
446+
return streamEqual(ea).contramap(V2.toStream_());
447447
}
448448

449449
/**
@@ -453,7 +453,7 @@ public static <A> Equal<V2<A>> v2Equal(final Equal<A> ea) {
453453
* @return An equal instance for a vector-3.
454454
*/
455455
public static <A> Equal<V3<A>> v3Equal(final Equal<A> ea) {
456-
return streamEqual(ea).contramap(V3.<A>toStream_());
456+
return streamEqual(ea).contramap(V3.toStream_());
457457
}
458458

459459
/**
@@ -463,7 +463,7 @@ public static <A> Equal<V3<A>> v3Equal(final Equal<A> ea) {
463463
* @return An equal instance for a vector-4.
464464
*/
465465
public static <A> Equal<V4<A>> v4Equal(final Equal<A> ea) {
466-
return streamEqual(ea).contramap(V4.<A>toStream_());
466+
return streamEqual(ea).contramap(V4.toStream_());
467467
}
468468

469469
/**
@@ -473,7 +473,7 @@ public static <A> Equal<V4<A>> v4Equal(final Equal<A> ea) {
473473
* @return An equal instance for a vector-5.
474474
*/
475475
public static <A> Equal<V5<A>> v5Equal(final Equal<A> ea) {
476-
return streamEqual(ea).contramap(V5.<A>toStream_());
476+
return streamEqual(ea).contramap(V5.toStream_());
477477
}
478478

479479
/**
@@ -483,7 +483,7 @@ public static <A> Equal<V5<A>> v5Equal(final Equal<A> ea) {
483483
* @return An equal instance for a vector-6.
484484
*/
485485
public static <A> Equal<V6<A>> v6Equal(final Equal<A> ea) {
486-
return streamEqual(ea).contramap(V6.<A>toStream_());
486+
return streamEqual(ea).contramap(V6.toStream_());
487487
}
488488

489489
/**
@@ -493,7 +493,7 @@ public static <A> Equal<V6<A>> v6Equal(final Equal<A> ea) {
493493
* @return An equal instance for a vector-7.
494494
*/
495495
public static <A> Equal<V7<A>> v7Equal(final Equal<A> ea) {
496-
return streamEqual(ea).contramap(V7.<A>toStream_());
496+
return streamEqual(ea).contramap(V7.toStream_());
497497
}
498498

499499
/**
@@ -503,7 +503,7 @@ public static <A> Equal<V7<A>> v7Equal(final Equal<A> ea) {
503503
* @return An equal instance for a vector-8.
504504
*/
505505
public static <A> Equal<V8<A>> v8Equal(final Equal<A> ea) {
506-
return streamEqual(ea).contramap(V8.<A>toStream_());
506+
return streamEqual(ea).contramap(V8.toStream_());
507507
}
508508

509509
/**

core/src/main/java/fj/F1Functions.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public static <A, B> F<Promise<A>, Promise<B>> mapPromise(final F<A, B> f) {
261261
*/
262262
@SuppressWarnings("unchecked")
263263
public static <A, B, C> F<A, Either<B, C>> eitherLeftK(final F<A, B> f) {
264-
return o(Either.<B, C>left_(), f);
264+
return o(Either.left_(), f);
265265
}
266266

267267
/**
@@ -272,7 +272,7 @@ public static <A, B, C> F<A, Either<B, C>> eitherLeftK(final F<A, B> f) {
272272
*/
273273
@SuppressWarnings("unchecked")
274274
public static <A, B, C> F<A, Either<C, B>> eitherRightK(final F<A, B> f) {
275-
return o(Either.<C, B>right_(), f);
275+
return o(Either.right_(), f);
276276
}
277277

278278
/**
@@ -330,7 +330,7 @@ public static <A, B> F<A, IterableW<B>> iterableK(final F<A, B> f) {
330330
*/
331331
@SuppressWarnings("unchecked")
332332
public static <A, B> F<Iterable<A>, IterableW<B>> mapIterable(final F<A, B> f) {
333-
return o(IterableW.<A, B>map().f(f), IterableW.<A, Iterable<A>>wrap());
333+
return o(IterableW.<A, B>map().f(f), IterableW.wrap());
334334
}
335335

336336
/**
@@ -340,7 +340,7 @@ public static <A, B> F<Iterable<A>, IterableW<B>> mapIterable(final F<A, B> f) {
340340
*/
341341
@SuppressWarnings("unchecked")
342342
public static <A, B> F<A, NonEmptyList<B>> nelK(final F<A, B> f) {
343-
return o(NonEmptyList.<B>nel(), f);
343+
return o(NonEmptyList.nel(), f);
344344
}
345345

346346
/**
@@ -408,7 +408,7 @@ public static <A, B> F<Tree<A>, B> foldMapTree(final F<A, B> f, final Monoid<B>
408408
* @return This function promoted to return its value in a TreeZipper.
409409
*/
410410
public static <A, B> F<A, TreeZipper<B>> treeZipperK(final F<A, B> f) {
411-
return andThen(treeK(f), TreeZipper.<B>fromTree());
411+
return andThen(treeK(f), TreeZipper.fromTree());
412412
}
413413

414414
/**
@@ -560,7 +560,7 @@ public static <A, B> F<P2<A, A>, P2<B, B>> mapBoth(final F<A, B> f) {
560560
* @return A new SynchronousQueue with this function applied to each element.
561561
*/
562562
public static <A, B> SynchronousQueue<B> mapJ(final F<A, B> f, final SynchronousQueue<A> as) {
563-
final SynchronousQueue<B> bs = new SynchronousQueue<B>();
563+
final SynchronousQueue<B> bs = new SynchronousQueue<>();
564564
bs.addAll(iterableStream(as).map(f).toCollection());
565565
return bs;
566566
}
@@ -573,7 +573,7 @@ public static <A, B> SynchronousQueue<B> mapJ(final F<A, B> f, final Synchronous
573573
* @return A new PriorityBlockingQueue with this function applied to each element.
574574
*/
575575
public static <A, B> PriorityBlockingQueue<B> mapJ(final F<A, B> f, final PriorityBlockingQueue<A> as) {
576-
return new PriorityBlockingQueue<B>(iterableStream(as).map(f).toCollection());
576+
return new PriorityBlockingQueue<>(iterableStream(as).map(f).toCollection());
577577
}
578578

579579
/**
@@ -583,7 +583,7 @@ public static <A, B> PriorityBlockingQueue<B> mapJ(final F<A, B> f, final Priori
583583
* @return A new LinkedBlockingQueue with this function applied to each element.
584584
*/
585585
public static <A, B> LinkedBlockingQueue<B> mapJ(final F<A, B> f, final LinkedBlockingQueue<A> as) {
586-
return new LinkedBlockingQueue<B>(iterableStream(as).map(f).toCollection());
586+
return new LinkedBlockingQueue<>(iterableStream(as).map(f).toCollection());
587587
}
588588

589589
/**
@@ -593,7 +593,7 @@ public static <A, B> LinkedBlockingQueue<B> mapJ(final F<A, B> f, final LinkedBl
593593
* @return A new CopyOnWriteArraySet with this function applied to each element.
594594
*/
595595
public static <A, B> CopyOnWriteArraySet<B> mapJ(final F<A, B> f, final CopyOnWriteArraySet<A> as) {
596-
return new CopyOnWriteArraySet<B>(iterableStream(as).map(f).toCollection());
596+
return new CopyOnWriteArraySet<>(iterableStream(as).map(f).toCollection());
597597
}
598598

599599
/**
@@ -603,7 +603,7 @@ public static <A, B> CopyOnWriteArraySet<B> mapJ(final F<A, B> f, final CopyOnWr
603603
* @return A new CopyOnWriteArrayList with this function applied to each element.
604604
*/
605605
public static <A, B> CopyOnWriteArrayList<B> mapJ(final F<A, B> f, final CopyOnWriteArrayList<A> as) {
606-
return new CopyOnWriteArrayList<B>(iterableStream(as).map(f).toCollection());
606+
return new CopyOnWriteArrayList<>(iterableStream(as).map(f).toCollection());
607607
}
608608

609609
/**
@@ -613,7 +613,7 @@ public static <A, B> CopyOnWriteArrayList<B> mapJ(final F<A, B> f, final CopyOnW
613613
* @return A new ConcurrentLinkedQueue with this function applied to each element.
614614
*/
615615
public static <A, B> ConcurrentLinkedQueue<B> mapJ(final F<A, B> f, final ConcurrentLinkedQueue<A> as) {
616-
return new ConcurrentLinkedQueue<B>(iterableStream(as).map(f).toCollection());
616+
return new ConcurrentLinkedQueue<>(iterableStream(as).map(f).toCollection());
617617
}
618618

619619
/**
@@ -623,7 +623,7 @@ public static <A, B> ConcurrentLinkedQueue<B> mapJ(final F<A, B> f, final Concur
623623
* @return A new ArrayBlockingQueue with this function applied to each element.
624624
*/
625625
public static <A, B> ArrayBlockingQueue<B> mapJ(final F<A, B> f, final ArrayBlockingQueue<A> as) {
626-
final ArrayBlockingQueue<B> bs = new ArrayBlockingQueue<B>(as.size());
626+
final ArrayBlockingQueue<B> bs = new ArrayBlockingQueue<>(as.size());
627627
bs.addAll(iterableStream(as).map(f).toCollection());
628628
return bs;
629629
}
@@ -636,7 +636,7 @@ public static <A, B> ArrayBlockingQueue<B> mapJ(final F<A, B> f, final ArrayBloc
636636
* @return A new TreeSet with this function applied to each element.
637637
*/
638638
public static <A, B> TreeSet<B> mapJ(final F<A, B> f, final TreeSet<A> as) {
639-
return new TreeSet<B>(iterableStream(as).map(f).toCollection());
639+
return new TreeSet<>(iterableStream(as).map(f).toCollection());
640640
}
641641

642642
/**
@@ -646,7 +646,7 @@ public static <A, B> TreeSet<B> mapJ(final F<A, B> f, final TreeSet<A> as) {
646646
* @return A new PriorityQueue with this function applied to each element.
647647
*/
648648
public static <A, B> PriorityQueue<B> mapJ(final F<A, B> f, final PriorityQueue<A> as) {
649-
return new PriorityQueue<B>(iterableStream(as).map(f).toCollection());
649+
return new PriorityQueue<>(iterableStream(as).map(f).toCollection());
650650
}
651651

652652
/**
@@ -656,7 +656,7 @@ public static <A, B> PriorityQueue<B> mapJ(final F<A, B> f, final PriorityQueue<
656656
* @return A new LinkedList with this function applied to each element.
657657
*/
658658
public static <A, B> LinkedList<B> mapJ(final F<A, B> f, final LinkedList<A> as) {
659-
return new LinkedList<B>(iterableStream(as).map(f).toCollection());
659+
return new LinkedList<>(iterableStream(as).map(f).toCollection());
660660
}
661661

662662
/**
@@ -666,7 +666,7 @@ public static <A, B> LinkedList<B> mapJ(final F<A, B> f, final LinkedList<A> as)
666666
* @return A new ArrayList with this function applied to each element.
667667
*/
668668
public static <A, B> ArrayList<B> mapJ(final F<A, B> f, final ArrayList<A> as) {
669-
return new ArrayList<B>(iterableStream(as).map(f).toCollection());
669+
return new ArrayList<>(iterableStream(as).map(f).toCollection());
670670
}
671671

672672
public static <A, B, C> F<A, C> map(F<A, B> target, F<B, C> f) {

core/src/main/java/fj/F1W.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,6 @@ public B f(A a) {
682682
* Lifts the function into the fully featured function wrapper
683683
*/
684684
public static <A, B> F1W<A, B> lift(final F<A, B> f) {
685-
return new F1WFunc<A, B>(f);
685+
return new F1WFunc<>(f);
686686
}
687687
}

core/src/main/java/fj/Function.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public static <A, B, C> F<F2<A, B, C>, F2<B, A, C>> flip2() {
168168
* not apply the value, instead returning an empty optional value.
169169
*/
170170
public static <A, B> F<A, Option<B>> nullable(final F<A, B> f) {
171-
return a -> a == null ? Option.<B>none() : Option.some(f.f(a));
171+
return a -> a == null ? Option.none() : Option.some(f.f(a));
172172
}
173173

174174
/**
@@ -761,7 +761,7 @@ public static <A, B, C, D> F<F<D, A>, F<F<D, B>, F<D, C>>> lift(final F<A, F<B,
761761
* @return A function of arity-1 whose argument is substituted for both parameters of <em>f</em>.
762762
*/
763763
public static <A, B> F<B, A> join(final F<B, F<B, A>> f) {
764-
return bind(f, Function.<F<B, A>>identity());
764+
return bind(f, Function.identity());
765765
}
766766

767767

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public static <A, B> Hash<Either<A, B>> eitherHash(final Hash<A> ha, final Hash<
165165
* @return A hash instance for the {@link Validation} type.
166166
*/
167167
public static <A, B> Hash<Validation<A, B>> validationHash(final Hash<A> ha, final Hash<B> hb) {
168-
return eitherHash(ha, hb).contramap(Validation.<A, B>either());
168+
return eitherHash(ha, hb).contramap(Validation.either());
169169
}
170170

171171
/**
@@ -196,7 +196,7 @@ public static <A> Hash<List<A>> listHash(final Hash<A> ha) {
196196
* @return A hash instance for the {@link NonEmptyList} type.
197197
*/
198198
public static <A> Hash<NonEmptyList<A>> nonEmptyListHash(final Hash<A> ha) {
199-
return listHash(ha).contramap(NonEmptyList.<A>toList_());
199+
return listHash(ha).contramap(NonEmptyList.toList_());
200200
}
201201

202202
/**
@@ -264,7 +264,7 @@ public static <A> Hash<Array<A>> arrayHash(final Hash<A> ha) {
264264
* @return A hash instance for the {@link Tree} type.
265265
*/
266266
public static <A> Hash<Tree<A>> treeHash(final Hash<A> ha) {
267-
return streamHash(ha).contramap(Tree.<A>flatten_());
267+
return streamHash(ha).contramap(Tree.flatten_());
268268
}
269269

270270
public static <K, V> Hash<TreeMap<K, V>> treeMapHash(final Hash<K> h, final Hash<V> v) {
@@ -278,7 +278,7 @@ public static <K, V> Hash<TreeMap<K, V>> treeMapHash(final Hash<K> h, final Hash
278278
* @return A hash instance for a product-1.
279279
*/
280280
public static <A> Hash<P1<A>> p1Hash(final Hash<A> ha) {
281-
return ha.contramap(P1.<A>__1());
281+
return ha.contramap(P1.__1());
282282
}
283283

284284
/**
@@ -473,7 +473,7 @@ public static <A, B, C, D, E> Hash<P5<A, B, C, D, E>> p5Hash(final Hash<A> ha, f
473473
* @return A hash instance for a vector-2.
474474
*/
475475
public static <A> Hash<V2<A>> v2Hash(final Hash<A> ea) {
476-
return streamHash(ea).contramap(V2.<A>toStream_());
476+
return streamHash(ea).contramap(V2.toStream_());
477477
}
478478

479479
/**
@@ -483,7 +483,7 @@ public static <A> Hash<V2<A>> v2Hash(final Hash<A> ea) {
483483
* @return A hash instance for a vector-3.
484484
*/
485485
public static <A> Hash<V3<A>> v3Hash(final Hash<A> ea) {
486-
return streamHash(ea).contramap(V3.<A>toStream_());
486+
return streamHash(ea).contramap(V3.toStream_());
487487
}
488488

489489
/**
@@ -493,7 +493,7 @@ public static <A> Hash<V3<A>> v3Hash(final Hash<A> ea) {
493493
* @return A hash instance for a vector-4.
494494
*/
495495
public static <A> Hash<V4<A>> v4Hash(final Hash<A> ea) {
496-
return streamHash(ea).contramap(V4.<A>toStream_());
496+
return streamHash(ea).contramap(V4.toStream_());
497497
}
498498

499499
/**
@@ -503,7 +503,7 @@ public static <A> Hash<V4<A>> v4Hash(final Hash<A> ea) {
503503
* @return A hash instance for a vector-5.
504504
*/
505505
public static <A> Hash<V5<A>> v5Hash(final Hash<A> ea) {
506-
return streamHash(ea).contramap(V5.<A>toStream_());
506+
return streamHash(ea).contramap(V5.toStream_());
507507
}
508508

509509
/**
@@ -513,7 +513,7 @@ public static <A> Hash<V5<A>> v5Hash(final Hash<A> ea) {
513513
* @return A hash instance for a vector-6.
514514
*/
515515
public static <A> Hash<V6<A>> v6Hash(final Hash<A> ea) {
516-
return streamHash(ea).contramap(V6.<A>toStream_());
516+
return streamHash(ea).contramap(V6.toStream_());
517517
}
518518

519519
/**
@@ -523,7 +523,7 @@ public static <A> Hash<V6<A>> v6Hash(final Hash<A> ea) {
523523
* @return A hash instance for a vector-7.
524524
*/
525525
public static <A> Hash<V7<A>> v7Hash(final Hash<A> ea) {
526-
return streamHash(ea).contramap(V7.<A>toStream_());
526+
return streamHash(ea).contramap(V7.toStream_());
527527
}
528528

529529
/**
@@ -533,6 +533,6 @@ public static <A> Hash<V7<A>> v7Hash(final Hash<A> ea) {
533533
* @return A hash instance for a vector-8.
534534
*/
535535
public static <A> Hash<V8<A>> v8Hash(final Hash<A> ea) {
536-
return streamHash(ea).contramap(V8.<A>toStream_());
536+
return streamHash(ea).contramap(V8.toStream_());
537537
}
538538
}

0 commit comments

Comments
 (0)