Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Sep 4, 2020
2 parents 02f7902 + 072fdcb commit 82a1422
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/cactoos/iterable/Matched.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
*/
package org.cactoos.iterable;

import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.cactoos.BiFunc;
import org.cactoos.Scalar;
import org.cactoos.list.Immutable;
import org.cactoos.scalar.Unchecked;
import org.cactoos.text.FormattedText;

Expand Down Expand Up @@ -92,7 +92,7 @@ public Matched(
);
}
}
return Collections.unmodifiableList(rslt).iterator();
return new Immutable<>(rslt).iterator();
}
);
}
Expand Down
11 changes: 3 additions & 8 deletions src/main/java/org/cactoos/iterator/Partitioned.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
*/
package org.cactoos.iterator;

import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.NoSuchElementException;
import org.cactoos.list.Immutable;
import org.cactoos.list.ListOf;

/**
Expand Down Expand Up @@ -72,12 +71,8 @@ public List<T> next() {
if (this.size < 1) {
throw new IllegalArgumentException("Partition size < 1");
}
return Collections.unmodifiableList(
new LinkedList<>(
new ListOf<>(
new Sliced<>(0, this.size, this.decorated)
)
)
return new Immutable<>(
new ListOf<>(new Sliced<>(0, this.size, this.decorated))
);
}

Expand Down
5 changes: 1 addition & 4 deletions src/main/java/org/cactoos/list/Immutable.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
* @param <T> Element type
* @since 1.16
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
* @todo #898:30min Replace all the Collections.unmodifiableList
* with the {@link org.cactoos.list.Immutable} from the cactoos codebase.
* That should be done because Elegant Object principles are against static methods.
*/
@SuppressWarnings(
{
Expand Down Expand Up @@ -79,7 +76,7 @@ public boolean contains(final Object item) {

@Override
public Iterator<T> iterator() {
return this.list.iterator();
return new org.cactoos.iterator.Immutable<>(this.list.iterator());
}

@Override
Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/forbidden-apis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ org.hamcrest.MatcherAssert#assertThat(java.lang.Object, org.hamcrest.Matcher)

@defaultMessage Please specify failure reason
org.junit.Assert#assertThat(java.lang.Object, org.hamcrest.Matcher)

@defaultMessage Please avoid using static methods.
java.util.Collections#unmodifiableList(java.util.List)

1 comment on commit 82a1422

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 82a1422 Sep 4, 2020

Choose a reason for hiding this comment

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

Puzzle 898-457dcf37 disappeared from src/main/java/org/cactoos/list/Immutable.java, that's why I closed #1220. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

Please sign in to comment.