Skip to content

Commit

Permalink
Do not expose constructors taking classes instead of interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
victornoel authored and Olivier B. OURA committed Jan 8, 2021
1 parent 18556b4 commit d0837ef
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 47 deletions.
12 changes: 1 addition & 11 deletions src/main/java/org/cactoos/iterable/Repeated.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
package org.cactoos.iterable;

import org.cactoos.Scalar;
import org.cactoos.scalar.Unchecked;

/**
* Repeat an element.
Expand All @@ -51,18 +50,9 @@ public Repeated(final int total, final T elm) {
* @param elm The element to repeat
*/
public Repeated(final int total, final Scalar<T> elm) {
this(total, new Unchecked<T>(elm));
}

/**
* Ctor.
* @param total The total number of repetitions
* @param item The element to repeat
*/
public Repeated(final int total, final Unchecked<T> item) {
super(
new IterableOf<>(
() -> new org.cactoos.iterator.Repeated<>(total, item)
() -> new org.cactoos.iterator.Repeated<>(total, elm)
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cactoos/iterator/Repeated.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public Repeated(final int max, final Scalar<T> scalar) {
* @param max How many times to repeat
* @param scalar Scalar to repeat
*/
public Repeated(final int max, final Unchecked<T> scalar) {
private Repeated(final int max, final Unchecked<T> scalar) {
this.elm = scalar;
this.repeat = max;
}
Expand Down
42 changes: 7 additions & 35 deletions src/main/java/org/cactoos/text/Split.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ public final class Split extends IterableEnvelope<Text> {
* @see String#split(String)
*/
public Split(final String text, final String rgx) {
this(
new UncheckedText(new TextOf(text)),
new UncheckedText(new TextOf(rgx))
);
this(new TextOf(text), new TextOf(rgx));
}

/**
Expand All @@ -60,11 +57,7 @@ public Split(final String text, final String rgx) {
* @see String#split(String, int)
*/
public Split(final String text, final String rgx, final int lmt) {
this(
new UncheckedText(new TextOf(text)),
new UncheckedText(new TextOf(rgx)),
lmt
);
this(new TextOf(text), new TextOf(rgx), lmt);
}

/**
Expand All @@ -74,7 +67,7 @@ public Split(final String text, final String rgx, final int lmt) {
* @see String#split(String)
*/
public Split(final String text, final Text rgx) {
this(new UncheckedText(text), new UncheckedText(rgx));
this(new TextOf(text), rgx);
}

/**
Expand All @@ -85,7 +78,7 @@ public Split(final String text, final Text rgx) {
* @see String#split(String, int)
*/
public Split(final String text, final Text rgx, final int lmt) {
this(new UncheckedText(text), new UncheckedText(rgx), lmt);
this(new TextOf(text), rgx, lmt);
}

/**
Expand All @@ -95,7 +88,7 @@ public Split(final String text, final Text rgx, final int lmt) {
* @see String#split(String)
*/
public Split(final Text text, final String rgx) {
this(new UncheckedText(text), new UncheckedText(rgx));
this(text, new TextOf(rgx));
}

/**
Expand All @@ -106,7 +99,7 @@ public Split(final Text text, final String rgx) {
* @see String#split(String, int)
*/
public Split(final Text text, final String rgx, final int lmt) {
this(new UncheckedText(text), new UncheckedText(rgx), lmt);
this(text, new TextOf(rgx), lmt);
}

/**
Expand All @@ -116,27 +109,6 @@ public Split(final Text text, final String rgx, final int lmt) {
* @see String#split(String)
*/
public Split(final Text text, final Text rgx) {
this(new UncheckedText(text), new UncheckedText(rgx));
}

/**
* Ctor.
* @param text The text
* @param rgx The regex
* @param lmt The limit
* @see String#split(String, int)
*/
public Split(final Text text, final Text rgx, final int lmt) {
this(new UncheckedText(text), new UncheckedText(rgx), lmt);
}

/**
* Ctor.
* @param text The text
* @param rgx The regex
* @see String#split(String)
*/
public Split(final UncheckedText text, final UncheckedText rgx) {
this(text, rgx, 0);
}

Expand All @@ -147,7 +119,7 @@ public Split(final UncheckedText text, final UncheckedText rgx) {
* @param lmt The limit
* @see String#split(String, int)
*/
public Split(final UncheckedText text, final UncheckedText rgx, final int lmt) {
public Split(final Text text, final Text rgx, final int lmt) {
super(
new Mapped<>(
TextOf::new,
Expand Down

0 comments on commit d0837ef

Please sign in to comment.