Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Feb 11, 2020
2 parents 51ea389 + eed03c1 commit 2a62719
Show file tree
Hide file tree
Showing 30 changed files with 97 additions and 779 deletions.
5 changes: 5 additions & 0 deletions src/main/java/org/cactoos/collection/Filtered.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
* @param <X> Type of source item
* @since 1.16
* @todo #1242:30min Remove this class and replace it everywhere
* it was needed by the appropriate usage of Filtered from iterable
* (composed with ListOf or SetOf in case a copy is needed)
* or any other relevant concrete collection implementation.
* See #1242 for the rationale about this.
*/
public final class Filtered<X> extends CollectionEnvelope<X> {

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/cactoos/collection/HeadOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
*
* @param <T> Type of source item
* @since 0.29
* @todo #1242:30min Remove this class and replace it everywhere
* it was needed by the appropriate usage of HeadOf from iterable
* (composed with ListOf or SetOf in case a copy is needed)
* or any other relevant concrete collection implementation.
* See #1242 for the rationale about this.
*/
public final class HeadOf<T> extends CollectionEnvelope<T> {

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/cactoos/collection/Joined.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
*
* @param <X> Type of source item
* @since 1.16
* @todo #1242:30min Remove this class and replace it everywhere
* it was needed by the appropriate usage of Joined from iterable
* (composed with ListOf or SetOf in case a copy is needed)
* or any other relevant concrete collection implementation.
* See #1242 for the rationale about this.
*/
public final class Joined<X> extends CollectionEnvelope<X> {

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/cactoos/collection/Mapped.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
* @param <X> Type of source item
* @param <Y> Type of target item
* @since 0.14
* @todo #1242:30min Remove this class and replace it everywhere
* it was needed by the appropriate usage of Mapped from iterable
* (composed with ListOf or SetOf in case a copy is needed)
* or any other relevant concrete collection implementation.
* See #1242 for the rationale about this.
*/
public final class Mapped<X, Y> extends CollectionEnvelope<Y> {

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/cactoos/collection/Reversed.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
*
* @param <X> Type of source item
* @since 1.16
* @todo #1242:30min Remove this class and replace it everywhere
* it was needed by the appropriate usage of Reversed from iterable
* (composed with ListOf or SetOf in case a copy is needed)
* or any other relevant concrete collection implementation.
* See #1242 for the rationale about this.
*/
public final class Reversed<X> extends CollectionEnvelope<X> {

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/cactoos/collection/Shuffled.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
*
* @param <T> Element type
* @since 0.23
* @todo #1242:30min Remove this class and replace it everywhere
* it was needed by the appropriate usage of Shuffled from iterable
* (composed with ListOf or SetOf in case a copy is needed)
* or any other relevant concrete collection implementation.
* See #1242 for the rationale about this.
*/
public final class Shuffled<T> extends CollectionEnvelope<T> {

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/cactoos/collection/Skipped.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
*
* @param <T> Type of source item
* @since 0.34
* @todo #1242:30min Remove this class and replace it everywhere
* it was needed by the appropriate usage of Skipped from iterable
* (composed with ListOf or SetOf in case a copy is needed)
* or any other relevant concrete collection implementation.
* See #1242 for the rationale about this.
*/
public final class Skipped<T> extends CollectionEnvelope<T> {

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/cactoos/collection/Sliced.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
*
* @param <T> Element type
* @since 1.0.0
* @todo #1242:30min Remove this class and replace it everywhere
* it was needed by the appropriate usage of Sliced from iterable
* (composed with ListOf or SetOf in case a copy is needed)
* or any other relevant concrete collection implementation.
* See #1242 for the rationale about this.
*/
public final class Sliced<T> extends CollectionEnvelope<T> {

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/cactoos/collection/Solid.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
* @param <T> List type
* @see Sticky
* @since 0.24
* @todo #1242:30min Remove this class and replace it everywhere
* it was needed by the appropriate usage of Synced (since Solid
* is based on Synced and Sticky, which was removed) from list,
* set, iterable, iterator or any other relevant concrete
* collection implementation. See #1242 for the rationale about this.
*/
public final class Solid<T> extends CollectionEnvelope<T> {

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/cactoos/collection/Sorted.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
*
* @param <T> Element type
* @since 0.19
* @todo #1242:30min Remove this class and replace it everywhere
* it was needed by the appropriate usage of Sorted from iterable
* (composed with ListOf or SetOf in case a copy is needed)
* or any other relevant concrete collection implementation.
* See #1242 for the rationale about this.
*/
public final class Sorted<T> extends CollectionEnvelope<T> {

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/cactoos/collection/Sticky.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
*
* @param <E> Type of item
* @since 0.16
* @todo #1242:30min Remove this class and replace it everywhere
* it was needed by the appropriate usage of ListOf, SetOf or
* any other collection concrete implementation. See #1242
* for the rationale about this.
*/
public final class Sticky<E> extends CollectionEnvelope<E> {

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/cactoos/collection/Synced.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
* @param <T> List type
* @see Sticky
* @since 0.24
* @todo #1242:30min Remove this class and replace it everywhere
* it was needed by the appropriate usage of Synced from list,
* set, iterable, iterator or any other relevant concrete
* collection implementation. See #1242 for the rationale about this.
*/
public final class Synced<T> extends CollectionEnvelope<T> {

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/cactoos/collection/TailOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
*
* @param <T> Element type
* @since 0.31
* @todo #1242:30min Remove this class and replace it everywhere
* it was needed by the appropriate usage of TailOf from list,
* set, iterable, iterator or any other relevant concrete
* collection implementation. See #1242 for the rationale about this.
*/
public final class TailOf<T> extends CollectionEnvelope<T> {

Expand Down
15 changes: 0 additions & 15 deletions src/main/java/org/cactoos/collection/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,5 @@
* Collections, tests.
*
* @since 0.14
* @todo #1184:30min The behaviours of the classes of this package
* are akward because CollectionOf is based on a Scalar while some
* of the tests of the other classes are expecting mutable collections,
* except for Sticky itself.
* This resulted in the use of Sticky in most of the classes of this package
* during the resolution of #1184 to preserve the actual behaviour. Some
* tests of Sticky were also ignored because of this.
* It is as if CollectionOf was once made to be immutable but
* now there is Immutable for that: ask ARC what direction to take and
* apply it to make this whole package consistent. Keep in mind that
* Collection is particular in the way that it is an Iterable and that
* there are no direct implementation of Collection in Java, but only
* sub-interfaces (Set, List, etc) with their own implementation.
* Also don't forget to unignore or modify the tests of Sticky and improve
* the other tests to be clear about the expected behaviour.
*/
package org.cactoos.collection;
167 changes: 4 additions & 163 deletions src/main/java/org/cactoos/list/ListOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,20 @@
*/
package org.cactoos.list;

import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import org.cactoos.Scalar;
import org.cactoos.iterable.IterableOf;
import org.cactoos.scalar.Unchecked;

/**
* Iterable as {@link List}.
*
* <p>This class should be used very carefully. You must understand that
* it will fetch the entire content of the encapsulated {@link List} on each
* method call. It doesn't cache the data anyhow. If you don't
* need this {@link List} to re-fresh its content on every call,
* by doing round-trips to the encapsulated iterable, decorate it with
* {@link Sticky}.</p>
* Implementation of {@link List}.
*
* <p>There is no thread-safety guarantee.
*
* @param <T> List type
* @see Sticky
* @since 0.1
*/
public final class ListOf<T> implements List<T> {
/**
* List.
*/
private final Unchecked<List<T>> list;

public final class ListOf<T> extends ListEnvelope<T> {
/**
* Ctor.
*
Expand All @@ -79,148 +61,7 @@ public ListOf(final Iterator<T> src) {
* @param src An {@link Iterable}
*/
public ListOf(final Iterable<T> src) {
this(() -> {
final List<T> temp = new LinkedList<>();
src.forEach(temp::add);
return Collections.unmodifiableList(temp);
});
}

/**
* Ctor.
* @param slr The scalar
*/
public ListOf(final Scalar<List<T>> slr) {
this.list = new Unchecked<>(slr);
}

@Override
public Iterator<T> iterator() {
return this.list.value().iterator();
}

@Override
public boolean equals(final Object other) {
return this.list.value().equals(other);
}

@Override
public int hashCode() {
return this.list.value().hashCode();
}

@Override
public String toString() {
return this.list.value().toString();
}

@Override
public int size() {
return this.list.value().size();
}

@Override
public boolean isEmpty() {
return this.list.value().isEmpty();
}

@Override
public boolean contains(final Object object) {
return this.list.value().contains(object);
}

@Override
public Object[] toArray() {
return this.list.value().toArray();
}

@Override
public <X> X[] toArray(final X[] array) {
return this.list.value().toArray(array);
}

@Override
public boolean add(final T item) {
return this.list.value().add(item);
}

@Override
public boolean remove(final Object object) {
return this.list.value().remove(object);
}

@Override
public boolean containsAll(final Collection<?> col) {
return this.list.value().containsAll(col);
}

@Override
public boolean addAll(final Collection<? extends T> col) {
return this.list.value().addAll(col);
}

@Override
public boolean removeAll(final Collection<?> col) {
return this.list.value().removeAll(col);
}

@Override
public boolean retainAll(final Collection<?> col) {
return this.list.value().retainAll(col);
}

@Override
public void clear() {
this.list.value().clear();
}

@Override
public boolean addAll(final int index, final Collection<? extends T> col) {
return this.list.value().addAll(index, col);
}

@Override
public T get(final int index) {
return this.list.value().get(index);
}

@Override
public T set(final int index, final T element) {
return this.list.value().set(index, element);
}

@Override
public void add(final int index, final T element) {
this.list.value().add(index, element);
}

@Override
public T remove(final int index) {
return this.list.value().remove(index);
}

@Override
public int indexOf(final Object element) {
return this.list.value().indexOf(element);
}

@Override
public int lastIndexOf(final Object element) {
return this.list.value().lastIndexOf(element);
}

@Override
public ListIterator<T> listIterator() {
return this.list.value().listIterator();
}

@Override
public ListIterator<T> listIterator(final int index) {
return this.list.value().listIterator(index);
}

@Override
public List<T> subList(final int start, final int end) {
return this.list.value().subList(start, end);
super(new LinkedList<>());
src.forEach(super::add);
}
}
Loading

17 comments on commit 2a62719

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 2a62719 Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1230-147999cb disappeared from src/main/java/org/cactoos/list/package-info.java, that's why I closed #1233. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 2a62719 Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1184-56133cf3 disappeared from src/main/java/org/cactoos/collection/package-info.java, that's why I closed #1242. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 2a62719 Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1230-21258e4c discovered in src/main/java/org/cactoos/list/package-info.java and submitted as #1291. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 2a62719 Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1242-a8a7ac97 discovered in src/main/java/org/cactoos/set/package-info.java and submitted as #1292. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 2a62719 Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1242-bb66641c discovered in src/main/java/org/cactoos/collection/Mapped.java and submitted as #1293. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 2a62719 Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1242-3e1cce64 discovered in src/main/java/org/cactoos/collection/HeadOf.java and submitted as #1294. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 2a62719 Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1242-40f4f782 discovered in src/main/java/org/cactoos/collection/Sticky.java and submitted as #1295. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 2a62719 Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1242-fc7e8653 discovered in src/main/java/org/cactoos/collection/Synced.java and submitted as #1296. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 2a62719 Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1242-f1a7bfc6 discovered in src/main/java/org/cactoos/collection/Sliced.java and submitted as #1297. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 2a62719 Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1242-8f74e00b discovered in src/main/java/org/cactoos/collection/Shuffled.java and submitted as #1298. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 2a62719 Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1242-d08d3037 discovered in src/main/java/org/cactoos/collection/Filtered.java and submitted as #1299. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 2a62719 Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1242-011c38db discovered in src/main/java/org/cactoos/collection/Reversed.java and submitted as #1300. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 2a62719 Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1242-652af3fd discovered in src/main/java/org/cactoos/collection/Joined.java and submitted as #1301. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 2a62719 Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1242-f28dfbc0 discovered in src/main/java/org/cactoos/collection/Solid.java and submitted as #1302. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 2a62719 Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1242-15741ade discovered in src/main/java/org/cactoos/collection/Skipped.java and submitted as #1303. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 2a62719 Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1242-1b85f1d7 discovered in src/main/java/org/cactoos/collection/TailOf.java and submitted as #1304. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 2a62719 Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1242-99c90a27 discovered in src/main/java/org/cactoos/collection/Sorted.java and submitted as #1305. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.