Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions vavr/src/main/java/io/vavr/Lazy.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,16 @@ public <U> Lazy<U> map(Function<? super T, ? extends U> mapper) {
return Lazy.of(() -> mapper.apply(get()));
}

@Override
public <U> Lazy<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
public Lazy<Void> mapToVoid() {
return map(ignored -> null);
}

@Override
public Lazy<T> peek(Consumer<? super T> action) {
action.accept(get());
Expand Down
2 changes: 2 additions & 0 deletions vavr/src/main/java/io/vavr/Value.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
* <li>{@link #getOrElseTry(CheckedFunction0)}</li>
* <li>{@link #getOrNull()}</li>
* <li>{@link #map(Function)}</li>
* <li>{@link #mapTo(Object)}</li>
* <li>{@link #mapToVoid()}</li>
* <li>{@link #stringPrefix()}</li>
* </ul>
*
Expand Down
10 changes: 10 additions & 0 deletions vavr/src/main/java/io/vavr/collection/Array.java
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,16 @@ public <U> Array<U> map(Function<? super T, ? extends U> mapper) {
return wrap(arr);
}

@Override
public <U> Array<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
public Array<Void> mapToVoid() {
return map(ignored -> null);
}

@Override
public Array<T> orElse(Iterable<? extends T> other) {
return isEmpty() ? ofAll(other) : this;
Expand Down
10 changes: 10 additions & 0 deletions vavr/src/main/java/io/vavr/collection/BitSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,16 @@ default <U> SortedSet<U> map(Function<? super T, ? extends U> mapper) {
return map(Comparators.naturalComparator(), mapper);
}

@Override
default <U> SortedSet<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
default SortedSet<Void> mapToVoid() {
return map(ignored -> null);
}

@Override
BitSet<T> remove(T element);

Expand Down
10 changes: 10 additions & 0 deletions vavr/src/main/java/io/vavr/collection/CharSeq.java
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,16 @@ public <U> IndexedSeq<U> map(Function<? super Character, ? extends U> mapper) {
return result;
}

@Override
public <U> IndexedSeq<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
public IndexedSeq<Void> mapToVoid() {
return map(ignored -> null);
}

@Override
public String mkString() {
return back;
Expand Down
10 changes: 10 additions & 0 deletions vavr/src/main/java/io/vavr/collection/HashSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,16 @@ public <U> HashSet<U> map(Function<? super T, ? extends U> mapper) {
}
}

@Override
public <U> HashSet<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
public HashSet<Void> mapToVoid() {
return map(ignored -> null);
}

@Override
public String mkString(CharSequence prefix, CharSequence delimiter, CharSequence suffix) {
return iterator().mkString(prefix, delimiter, suffix);
Expand Down
10 changes: 10 additions & 0 deletions vavr/src/main/java/io/vavr/collection/IndexedSeq.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ default int lastIndexWhere(Predicate<? super T> predicate, int end) {
@Override
<U> IndexedSeq<U> map(Function<? super T, ? extends U> mapper);

@Override
default <U> IndexedSeq<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
default IndexedSeq<Void> mapToVoid() {
return map(ignored -> null);
}

@Override
IndexedSeq<T> orElse(Iterable<? extends T> other);

Expand Down
10 changes: 10 additions & 0 deletions vavr/src/main/java/io/vavr/collection/Iterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -1701,6 +1701,16 @@ public U getNext() {
}
}

@Override
default <U> Iterator<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
default Iterator<Void> mapToVoid() {
return map(ignored -> null);
}

@Override
default Iterator<T> orElse(Iterable<? extends T> other) {
return isEmpty() ? ofAll(other) : this;
Expand Down
10 changes: 10 additions & 0 deletions vavr/src/main/java/io/vavr/collection/LinearSeq.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,16 @@ default int lastIndexWhere(Predicate<? super T> predicate, int end) {
@Override
<U> LinearSeq<U> map(Function<? super T, ? extends U> mapper);

@Override
default <U> LinearSeq<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
default LinearSeq<Void> mapToVoid() {
return map(ignored -> null);
}

@Override
LinearSeq<T> orElse(Iterable<? extends T> other);

Expand Down
10 changes: 10 additions & 0 deletions vavr/src/main/java/io/vavr/collection/LinkedHashSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,16 @@ public <U> LinkedHashSet<U> map(Function<? super T, ? extends U> mapper) {
}
}

@Override
public <U> LinkedHashSet<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
public LinkedHashSet<Void> mapToVoid() {
return map(ignored -> null);
}

@Override
public String mkString(CharSequence prefix, CharSequence delimiter, CharSequence suffix) {
return iterator().mkString(prefix, delimiter, suffix);
Expand Down
10 changes: 10 additions & 0 deletions vavr/src/main/java/io/vavr/collection/List.java
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,16 @@ default <U> List<U> map(Function<? super T, ? extends U> mapper) {
return list.reverse();
}

@Override
default <U> List<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
default List<Void> mapToVoid() {
return map(ignored -> null);
}

@Override
default List<T> orElse(Iterable<? extends T> other) {
return isEmpty() ? ofAll(other) : this;
Expand Down
10 changes: 10 additions & 0 deletions vavr/src/main/java/io/vavr/collection/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,16 @@ default <U> Seq<U> map(Function<? super Tuple2<K, V>, ? extends U> mapper) {
return (Seq<U>) iterator().map(mapper).toStream();
}

@Override
default <U> Seq<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
default Seq<Void> mapToVoid() {
return map(ignored -> null);
}

/**
* Maps the entries of this {@code Map} to form a new {@code Map}.
*
Expand Down
10 changes: 10 additions & 0 deletions vavr/src/main/java/io/vavr/collection/Multimap.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,16 @@ default <U> Seq<U> map(Function<? super Tuple2<K, V>, ? extends U> mapper) {
return (Seq<U>) iterator().map(mapper).toStream();
}

@Override
default <U> Seq<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
default Seq<Void> mapToVoid() {
return map(ignored -> null);
}

/**
* Maps the values of this {@code Multimap} while preserving the corresponding keys.
*
Expand Down
10 changes: 10 additions & 0 deletions vavr/src/main/java/io/vavr/collection/PriorityQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,16 @@ public <U> PriorityQueue<U> map(Function<? super T, ? extends U> mapper) {
return map(Comparators.naturalComparator(), mapper);
}

@Override
public <U> PriorityQueue<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
public PriorityQueue<Void> mapToVoid() {
return map(ignored -> null);
}

public <U> PriorityQueue<U> map(Comparator<U> comparator, Function<? super T, ? extends U> mapper) {
Objects.requireNonNull(comparator, "comparator is null");
Objects.requireNonNull(mapper, "mapper is null");
Expand Down
10 changes: 10 additions & 0 deletions vavr/src/main/java/io/vavr/collection/Queue.java
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,16 @@ public <U> Queue<U> map(Function<? super T, ? extends U> mapper) {
return new Queue<>(front.map(mapper), rear.map(mapper));
}

@Override
public <U> Queue<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
public Queue<Void> mapToVoid() {
return map(ignored -> null);
}

@Override
public Queue<T> orElse(Iterable<? extends T> other) {
return isEmpty() ? ofAll(other) : this;
Expand Down
10 changes: 10 additions & 0 deletions vavr/src/main/java/io/vavr/collection/Seq.java
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,16 @@ default <U> U foldRight(U zero, BiFunction<? super T, ? super U, ? extends U> f)
@Override
<U> Seq<U> map(Function<? super T, ? extends U> mapper);

@Override
default <U> Seq<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
default Seq<Void> mapToVoid() {
return map(ignored -> null);
}

@Override
Seq<T> orElse(Iterable<? extends T> other);

Expand Down
10 changes: 10 additions & 0 deletions vavr/src/main/java/io/vavr/collection/Set.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,16 @@ default boolean isDistinct() {
@Override
<U> Set<U> map(Function<? super T, ? extends U> mapper);

@Override
default <U> Set<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
default Set<Void> mapToVoid() {
return map(ignored -> null);
}

@Override
Set<T> orElse(Iterable<? extends T> other);

Expand Down
10 changes: 10 additions & 0 deletions vavr/src/main/java/io/vavr/collection/SortedSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,16 @@ default boolean isOrdered() {
@Override
<U> SortedSet<U> map(Function<? super T, ? extends U> mapper);

@Override
default <U> SortedSet<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
default SortedSet<Void> mapToVoid() {
return map(ignored -> null);
}

@Override
SortedSet<T> orElse(Iterable<? extends T> other);

Expand Down
10 changes: 10 additions & 0 deletions vavr/src/main/java/io/vavr/collection/Stream.java
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,16 @@ default <U> Stream<U> map(Function<? super T, ? extends U> mapper) {
}
}

@Override
default <U> Stream<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
default Stream<Void> mapToVoid() {
return map(ignored -> null);
}

@Override
default Stream<T> padTo(int length, T element) {
if (length <= 0) {
Expand Down
10 changes: 10 additions & 0 deletions vavr/src/main/java/io/vavr/collection/Traversable.java
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,16 @@ default Option<T> lastOption() {
@Override
<U> Traversable<U> map(Function<? super T, ? extends U> mapper);

@Override
default <U> Traversable<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
default Traversable<Void> mapToVoid() {
return map(ignored -> null);
}

/**
* Calculates the maximum of this elements according to their natural order. Especially the underlying
* order of sorted collections is not taken into account.
Expand Down
10 changes: 10 additions & 0 deletions vavr/src/main/java/io/vavr/collection/Tree.java
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,16 @@ default <U> Tree<U> map(Function<? super T, ? extends U> mapper) {
return isEmpty() ? Empty.instance() : TreeModule.map((Node<T>) this, mapper);
}

@Override
default <U> Tree<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
default Tree<Void> mapToVoid() {
return map(ignored -> null);
}

@Override
default Tree<T> orElse(Iterable<? extends T> other) {
return isEmpty() ? ofAll(other) : this;
Expand Down
15 changes: 10 additions & 5 deletions vavr/src/main/java/io/vavr/collection/TreeSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,16 @@ public <U> TreeSet<U> map(Function<? super T, ? extends U> mapper) {
return map(Comparators.naturalComparator(), mapper);
}

@Override
public <U> TreeSet<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
public TreeSet<Void> mapToVoid() {
return map((o1, o2) -> 0, ignored -> null);
}

/**
* Returns this {@code TreeSet} if it is nonempty,
* otherwise {@code TreeSet} created from iterable, using existing comparator.
Expand Down Expand Up @@ -1017,11 +1027,6 @@ public <U> SortedSet<U> zipWithIndex(BiFunction<? super T, ? super Integer, ? ex
return TreeSet.ofAll(Comparators.naturalComparator(), iterator().zipWithIndex(mapper));
}

@Override
public TreeSet<Void> mapToVoid() {
return map((o1, o2) -> 0, ignored -> null);
}

// -- Object

@Override
Expand Down
10 changes: 10 additions & 0 deletions vavr/src/main/java/io/vavr/collection/Vector.java
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,16 @@ public <U> Vector<U> map(Function<? super T, ? extends U> mapper) {
return ofAll(trie.map(mapper));
}

@Override
public <U> Vector<U> mapTo(U value) {
return map(ignored -> value);
}

@Override
public Vector<Void> mapToVoid() {
return map(ignored -> null);
}

@Override
public Vector<T> orElse(Iterable<? extends T> other) {
return isEmpty() ? ofAll(other) : this;
Expand Down
Loading