Skip to content

Commit

Permalink
Packages iterator, iterable. Removed Of suffix for mutators. LengthOf.
Browse files Browse the repository at this point in the history
  • Loading branch information
ixmanuel committed Jul 30, 2017
1 parent e3ab47e commit 83342d2
Show file tree
Hide file tree
Showing 101 changed files with 527 additions and 445 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ String text = new TextOf(
To write a text into a file:

```java
new CountOf(
new LengthOf(
new TeeInput(
new InputOf(
"Hello, world!"
Expand Down Expand Up @@ -115,7 +115,7 @@ To filter a collection:

```java
Collection<String> filtered = new ListOf<>(
new FilteredOf<>(
new Filtered<>(
new ArrayOf<>("hello", "world", "dude"),
new FuncOf<String, Boolean>() {
@Override
Expand All @@ -131,7 +131,7 @@ With Lambda:

```java
new ListOf<>(
new FilteredOf<>(
new Filtered<>(
new ArrayOf<>("hello", "world", "dude"),
s -> s.length() > 4
)
Expand All @@ -142,7 +142,7 @@ To iterate a collection:

```java
new And(
new MappedOf<>(
new Mappped<>(
new ArrayOf<>("how", "are", "you"),
new FuncOf<>(
input -> {
Expand All @@ -166,7 +166,7 @@ To sort a list of words in the file:

```java
List<String> sorted = new ListOf<>(
new SortedOf<>(
new Sorted<>(
new SplitText(
new TextOf(
new InputOf(
Expand All @@ -182,7 +182,7 @@ List<String> sorted = new ListOf<>(
To count elements in an iterable:

```java
int total = new CountOf(
int total = new LengthOf(
"how", "are", "you"
).value();
```
Expand Down Expand Up @@ -220,7 +220,7 @@ Here is its object-oriented alternative:

```java
new And(
new EndlessItem<>(ready),
new Endless<>(ready),
ready -> {
System.out.prinln("Still waiting...");
return !ready;
Expand All @@ -235,21 +235,21 @@ Cactoos | Guava | Apache Commons | JDK 8
`FormattedText` | - | - | `String.format()`
`IsBlank` | - | `StringUtils.isBlank()`| -
`JoinedText` | - | - | `String.join()`
`CountOf` | - | - | `String#length()`
`LengthOf` | - | - | `String#length()`
`LowerText` | - | - | `String#toLowerCase()`
`NormalizedText` | - | `StringUtils.normalize()` | -
`RepeatedText` | - | `StringUtils.repeat()` | -
`ReplacedText` | - | - | `String#replace()`
`ReversedText` | - | - | `StringBuilder#reverse()`
`SplitText` | - | - | `String#split()`
`StringAsUrl` | - | - | `URLEncoder.encode()`
`EncodedUrl` | - | - | `URLEncoder.encode()`
`SubText` | - | - | `String#substring()`
`TrimmedText` | - | - | `String#trim()`
`UpperText` | - | - | `String#toUpperCase()`
`UrlAsString` | - | - | `URLDecoder.decode()`
`DecodedUrl` | - | - | `URLDecoder.decode()`
`StickyList` | ? | ? | `Arrays.asList()`
`StickyList` | `Lists.newArrayList()` | ? | -
`FilteredOf` | `Iterables.filter()` | ? | -
`Filtered` | `Iterables.filter()` | ? | -
`TextOf` | ? | `IOUtils.toString()` | -

## How to contribute?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@

import java.util.Iterator;
import org.cactoos.func.UncheckedScalar;
import org.cactoos.io.CountOfInput;
import org.cactoos.list.CountOfIterable;
import org.cactoos.list.CountOfIterator;
import org.cactoos.text.TextOf;

/**
Expand All @@ -39,7 +36,7 @@
* @version $Id$
* @since 0.12
*/
public final class CountOf implements Scalar<Number> {
public final class LengthOf implements Scalar<Number> {

/**
* The underlying scalar number.
Expand All @@ -50,64 +47,64 @@ public final class CountOf implements Scalar<Number> {
* Ctor.
* @param string The string
*/
public CountOf(final String string) {
public LengthOf(final String string) {
this(new TextOf(string));
}

/**
* Ctor.
* @param text The text
*/
public CountOf(final Text text) {
public LengthOf(final Text text) {
this(() -> text.asString().length());
}

/**
* Ctor.
* @param bytes The bytes
*/
public CountOf(final Bytes bytes) {
public LengthOf(final Bytes bytes) {
this(() -> bytes.asBytes().length);
}

/**
* Ctor.
* @param input The input
*/
public CountOf(final Input input) {
this(new CountOfInput(input));
public LengthOf(final Input input) {
this(new LengthOfInput(input));
}

/**
* Ctor.
* @param input The input
* @param max Buffer size
*/
public CountOf(final Input input, final int max) {
this(new CountOfInput(input, max));
public LengthOf(final Input input, final int max) {
this(new LengthOfInput(input, max));
}

/**
* Ctor.
* @param iterable The array of items
*/
public CountOf(final Iterable<?> iterable) {
this(new CountOfIterable(iterable));
public LengthOf(final Iterable<?> iterable) {
this(new org.cactoos.iterable.LengthOf(iterable));
}

/**
* Ctor.
* @param iterator The iterator
*/
public CountOf(final Iterator<?> iterator) {
this(new CountOfIterator(iterator));
public LengthOf(final Iterator<?> iterator) {
this(new org.cactoos.iterator.LengthOf(iterator));
}

/**
* Ctor.
* @param sclr The underlying scalar length
*/
private CountOf(final Scalar<?> sclr) {
private LengthOf(final Scalar<?> sclr) {
this.scalar = new UncheckedScalar<>(sclr);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/cactoos/Output.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* together with {@link Input} in order to modify the content
* of a text file:</p>
*
* <pre> new CountOf(
* <pre> new LengthOf(
* new TeeInput(
* new InputOf(new TextOf("Hello, world!")),
* new OutputTo(new File("/tmp/names.txt"))
Expand All @@ -45,7 +45,7 @@
* <p>Here {@link OutputTo} implements {@link Output} and behaves like
* one, providing write-only access to the encapsulated
* {@link java.io.File}. The {@link TeeInput} copies the content of the
* input to the output. The {@link org.cactoos.io.CountOf}
* input to the output. The {@link org.cactoos.io.LengthOf}
* calculates the size of the copied data.</p>
*
* <p>There is no thread-safety guarantee.
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/cactoos/func/And.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import org.cactoos.Func;
import org.cactoos.Proc;
import org.cactoos.Scalar;
import org.cactoos.list.ArrayOf;
import org.cactoos.list.MappedOf;
import org.cactoos.iterable.ArrayOf;
import org.cactoos.iterable.Mapped;

/**
* Logical conjunction.
Expand Down Expand Up @@ -85,7 +85,7 @@ public <X> And(final Iterable<X> src, final Proc<X> proc) {
*/
public <X> And(final Iterable<X> src, final Func<X, Boolean> func) {
this(
new MappedOf<>(
new Mapped<>(
src,
item -> (Scalar<Boolean>) () -> func.apply(item)
)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cactoos/func/Or.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
package org.cactoos.func;

import org.cactoos.Scalar;
import org.cactoos.list.ArrayOf;
import org.cactoos.iterable.ArrayOf;

/**
* Logical disjunction.
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/cactoos/io/InputAsBytes.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @version $Id$
* @since 0.1
*/
public final class InputAsBytes implements Bytes {
final class InputAsBytes implements Bytes {

/**
* The input.
Expand All @@ -54,7 +54,7 @@ public final class InputAsBytes implements Bytes {
* Ctor.
* @param input The input
*/
public InputAsBytes(final Input input) {
InputAsBytes(final Input input) {
// @checkstyle MagicNumber (1 line)
this(input, 16 << 10);
}
Expand All @@ -64,7 +64,7 @@ public InputAsBytes(final Input input) {
* @param input The input
* @param max Max length of the buffer for reading
*/
public InputAsBytes(final Input input, final int max) {
InputAsBytes(final Input input, final int max) {
this.source = input;
this.size = max;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* @version $Id$
* @since 0.6
*/
public final class InputAsLSInput implements LSInput {
public final class LSInputOf implements LSInput {

/**
* The input.
Expand All @@ -68,7 +68,7 @@ public final class InputAsLSInput implements LSInput {
* Ctor.
* @param inpt Input
*/
public InputAsLSInput(final Input inpt) {
public LSInputOf(final Input inpt) {
this(inpt, "#public", "#system", "#base");
}

Expand All @@ -80,7 +80,7 @@ public InputAsLSInput(final Input inpt) {
* @param sysid SystemID
* @param bse Base
*/
public InputAsLSInput(final Input inpt, final String pubid,
public LSInputOf(final Input inpt, final String pubid,
final String sysid, final String bse) {
this.input = inpt;
this.pid = pubid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.cactoos.io;
package org.cactoos;

import java.io.IOException;
import java.io.InputStream;
import org.cactoos.Input;
import org.cactoos.Scalar;
import org.cactoos.func.UncheckedScalar;

/**
Expand All @@ -38,7 +36,7 @@
* @version $Id$
* @since 0.1
*/
public final class CountOfInput implements Scalar<Long> {
final class LengthOfInput implements Scalar<Long> {

/**
* The input.
Expand All @@ -54,7 +52,7 @@ public final class CountOfInput implements Scalar<Long> {
* Ctor.
* @param input The input
*/
public CountOfInput(final Input input) {
LengthOfInput(final Input input) {
// @checkstyle MagicNumber (1 line)
this(input, 16 << 10);
}
Expand All @@ -64,7 +62,7 @@ public CountOfInput(final Input input) {
* @param input The input
* @param max Buffer size
*/
public CountOfInput(final Input input, final int max) {
LengthOfInput(final Input input, final int max) {
this.source = input;
this.size = max;
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/cactoos/io/ReaderAsBytes.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* @version $Id$
* @since 0.12
*/
public final class ReaderAsBytes implements Bytes {
final class ReaderAsBytes implements Bytes {

/**
* The reader.
Expand All @@ -61,7 +61,7 @@ public final class ReaderAsBytes implements Bytes {
*
* @param rdr Reader
*/
public ReaderAsBytes(final Reader rdr) {
ReaderAsBytes(final Reader rdr) {
this(rdr, StandardCharsets.UTF_8);
}

Expand All @@ -71,7 +71,7 @@ public ReaderAsBytes(final Reader rdr) {
* @param rdr Reader
* @param cset Charset
*/
public ReaderAsBytes(final Reader rdr, final Charset cset) {
ReaderAsBytes(final Reader rdr, final Charset cset) {
// @checkstyle MagicNumber (1 line)
this(rdr, cset, 16 << 10);
}
Expand All @@ -83,7 +83,7 @@ public ReaderAsBytes(final Reader rdr, final Charset cset) {
* @param cset Charset
* @param max Buffer size
*/
public ReaderAsBytes(final Reader rdr, final Charset cset, final int max) {
ReaderAsBytes(final Reader rdr, final Charset cset, final int max) {
this.reader = rdr;
this.charset = cset;
this.size = max;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/cactoos/io/StickyInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.cactoos.CountOf;
import org.cactoos.Input;
import org.cactoos.LengthOf;
import org.cactoos.Scalar;
import org.cactoos.func.IoCheckedScalar;
import org.cactoos.func.StickyScalar;
Expand Down Expand Up @@ -57,7 +57,7 @@ public StickyInput(final Input input) {
this.cache = new StickyScalar<>(
() -> {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
new CountOf(
new LengthOf(
new TeeInput(input, new OutputTo(baos))
).value();
return baos.toByteArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.cactoos.list;
package org.cactoos.iterable;

import java.util.Arrays;
import java.util.Iterator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.cactoos.list;
package org.cactoos.iterable;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down
Loading

0 comments on commit 83342d2

Please sign in to comment.