Skip to content

Commit

Permalink
(yegor256#1252) Reverted After review refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
fanifieiev committed Dec 7, 2019
1 parent d68a61f commit 6158edd
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 52 deletions.
18 changes: 10 additions & 8 deletions src/main/java/org/cactoos/collection/Reversed.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.cactoos.func.StickyFunc;
import org.cactoos.func.FuncOf;
import org.cactoos.func.UncheckedFunc;
import org.cactoos.iterable.IterableOf;

Expand Down Expand Up @@ -58,13 +58,15 @@ public Reversed(final X... src) {
public Reversed(final Iterable<X> src) {
super(
new UncheckedFunc<>(
new StickyFunc<Iterable<X>, Collection<X>>(
input -> {
final List<X> items = new LinkedList<>();
input.forEach(items::add);
Collections.reverse(items);
return items;
}
new FuncOf<Iterable<X>, Collection<X>>(
new org.cactoos.scalar.Sticky<>(
() -> {
final List<X> items = new LinkedList<>();
src.forEach(items::add);
Collections.reverse(items);
return items;
}
)
)
).apply(src)
);
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/org/cactoos/collection/Shuffled.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.cactoos.func.StickyFunc;
import org.cactoos.func.FuncOf;
import org.cactoos.func.UncheckedFunc;
import org.cactoos.iterable.IterableOf;

Expand Down Expand Up @@ -57,13 +57,15 @@ public Shuffled(final T... src) {
public Shuffled(final Iterable<T> src) {
super(
new UncheckedFunc<>(
new StickyFunc<Iterable<T>, Collection<T>>(
input -> {
final List<T> items = new LinkedList<>();
input.forEach(items::add);
Collections.shuffle(items);
return items;
}
new FuncOf<Iterable<T>, Collection<T>>(
new org.cactoos.scalar.Sticky<>(
() -> {
final List<T> items = new LinkedList<>();
src.forEach(items::add);
Collections.shuffle(items);
return items;
}
)
)
).apply(src)
);
Expand Down
20 changes: 12 additions & 8 deletions src/main/java/org/cactoos/collection/Solid.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.cactoos.func.SolidFunc;
import org.cactoos.func.FuncOf;
import org.cactoos.func.UncheckedFunc;
import org.cactoos.iterable.IterableOf;

Expand Down Expand Up @@ -58,13 +58,17 @@ public Solid(final T... array) {
public Solid(final Iterable<T> src) {
super(
new UncheckedFunc<>(
new SolidFunc<Iterable<T>, Collection<T>>(
input -> {
final List<T> items = new LinkedList<>();
input.forEach(items::add);
Collections.shuffle(items);
return items;
}
new FuncOf<Iterable<T>, Collection<T>>(
new org.cactoos.scalar.Solid<>(
new org.cactoos.scalar.Sticky<>(
() -> {
final List<T> items = new LinkedList<>();
src.forEach(items::add);
Collections.shuffle(items);
return items;
}
)
)
)
).apply(src)
);
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/org/cactoos/collection/Sorted.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import org.cactoos.func.StickyFunc;
import org.cactoos.func.FuncOf;
import org.cactoos.func.UncheckedFunc;
import org.cactoos.iterable.IterableOf;
import org.cactoos.list.ListOf;
Expand Down Expand Up @@ -83,13 +83,15 @@ public Sorted(final Comparator<T> cmp, final T... src) {
public Sorted(final Comparator<T> cmp, final Iterable<T> src) {
super(
new UncheckedFunc<>(
new StickyFunc<Iterable<T>, Collection<T>>(
input -> {
final List<T> items = new LinkedList<>();
input.forEach(items::add);
items.sort(cmp);
return items;
}
new FuncOf<Iterable<T>, Collection<T>>(
new org.cactoos.scalar.Sticky<>(
() -> {
final List<T> items = new LinkedList<>();
src.forEach(items::add);
items.sort(cmp);
return items;
}
)
)
).apply(src)
);
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/org/cactoos/collection/Sticky.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import java.util.Collection;
import java.util.LinkedList;
import org.cactoos.func.StickyFunc;
import org.cactoos.func.FuncOf;
import org.cactoos.func.UncheckedFunc;
import org.cactoos.iterable.IterableOf;

Expand Down Expand Up @@ -55,12 +55,14 @@ public Sticky(final E... src) {
public Sticky(final Iterable<E> src) {
super(
new UncheckedFunc<>(
new StickyFunc<Iterable<E>, Collection<E>>(
input -> {
final Collection<E> temp = new LinkedList<>();
input.forEach(temp::add);
return temp;
}
new FuncOf<Iterable<E>, Collection<E>>(
new org.cactoos.scalar.Sticky<>(
() -> {
final Collection<E> temp = new LinkedList<>();
src.forEach(temp::add);
return temp;
}
)
)
).apply(src)
);
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/org/cactoos/collection/Synced.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import org.cactoos.func.SyncFunc;
import org.cactoos.func.FuncOf;
import org.cactoos.func.UncheckedFunc;
import org.cactoos.iterable.IterableOf;

Expand Down Expand Up @@ -64,12 +64,14 @@ public Synced(final T... array) {
public Synced(final Iterable<T> src) {
super(
new UncheckedFunc<>(
new SyncFunc<Iterable<T>, Collection<T>>(
input -> {
final Collection<T> temp = new LinkedList<>();
input.forEach(temp::add);
return Collections.synchronizedCollection(temp);
}
new FuncOf<Iterable<T>, Collection<T>>(
new org.cactoos.scalar.Synced<>(
() -> {
final Collection<T> temp = new LinkedList<>();
src.forEach(temp::add);
return Collections.synchronizedCollection(temp);
}
)
)
).apply(src)
);
Expand Down
18 changes: 12 additions & 6 deletions src/main/java/org/cactoos/set/SetOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
import java.util.HashSet;
import java.util.Set;
import org.cactoos.collection.CollectionEnvelope;
import org.cactoos.func.FuncOf;
import org.cactoos.func.UncheckedFunc;
import org.cactoos.iterable.IterableOf;
import org.cactoos.scalar.Unchecked;

/**
* Iterable as {@link Set}.
Expand Down Expand Up @@ -60,12 +62,16 @@ public SetOf(final T... array) {
*/
public SetOf(final Iterable<T> src) {
super(
new UncheckedFunc<Iterable<T>, Set<T>>(
input -> {
final Set<T> tmp = new HashSet<>();
input.forEach(tmp::add);
return Collections.unmodifiableSet(tmp);
}
new UncheckedFunc<>(
new FuncOf<Iterable<T>, Set<T>>(
new Unchecked<>(
() -> {
final Set<T> tmp = new HashSet<>();
src.forEach(tmp::add);
return Collections.unmodifiableSet(tmp);
}
)
)
).apply(src)
);
}
Expand Down

0 comments on commit 6158edd

Please sign in to comment.