Skip to content

Commit

Permalink
#128: more ctors
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jun 14, 2017
1 parent 6a21178 commit c9ba740
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 9 deletions.
9 changes: 9 additions & 0 deletions src/main/java/org/cactoos/io/BytesAsInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.io.InputStream;
import org.cactoos.Bytes;
import org.cactoos.Input;
import org.cactoos.text.ArrayAsBytes;
import org.cactoos.text.TextAsBytes;

/**
Expand Down Expand Up @@ -55,6 +56,14 @@ public BytesAsInput(final String text) {
this(new TextAsBytes(text));
}

/**
* Ctor.
* @param bytes The bytes
*/
public BytesAsInput(final byte[] bytes) {
this(new ArrayAsBytes(bytes));
}

/**
* Ctor.
* @param bytes The bytes
Expand Down
82 changes: 82 additions & 0 deletions src/main/java/org/cactoos/io/TeeInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
*/
package org.cactoos.io;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import org.cactoos.Input;
import org.cactoos.Output;

Expand All @@ -49,6 +51,86 @@ public final class TeeInput implements Input {
*/
private final Output target;

/**
* Ctor.
* @param input The source
* @param output The output file
* @since 0.5
*/
public TeeInput(final Path input, final Path output) {
this(new PathAsInput(input), new PathAsOutput(output));
}

/**
* Ctor.
* @param input The source
* @param output The output file
* @since 0.5
*/
public TeeInput(final Path input, final File output) {
this(new PathAsInput(input), new FileAsOutput(output));
}

/**
* Ctor.
* @param input The source
* @param output The output file
* @since 0.5
*/
public TeeInput(final File input, final File output) {
this(new FileAsInput(input), new FileAsOutput(output));
}

/**
* Ctor.
* @param input The source
* @param output The output file
* @since 0.5
*/
public TeeInput(final File input, final Path output) {
this(new FileAsInput(input), new PathAsOutput(output));
}

/**
* Ctor.
* @param input The source
* @param file The output file
* @since 0.5
*/
public TeeInput(final String input, final File file) {
this(new BytesAsInput(input), new FileAsOutput(file));
}

/**
* Ctor.
* @param input The source
* @param file The output file
* @since 0.5
*/
public TeeInput(final String input, final Path file) {
this(new BytesAsInput(input), new PathAsOutput(file));
}

/**
* Ctor.
* @param input The source
* @param file The output file
* @since 0.5
*/
public TeeInput(final byte[] input, final Path file) {
this(new BytesAsInput(input), new PathAsOutput(file));
}

/**
* Ctor.
* @param input The source
* @param output The target
* @since 0.5
*/
public TeeInput(final String input, final Output output) {
this(new BytesAsInput(input), output);
}

/**
* Ctor.
* @param input The source
Expand Down
10 changes: 1 addition & 9 deletions src/test/java/org/cactoos/io/TeeInputTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.cactoos.TextHasString;
import org.cactoos.func.FuncAsMatcher;
import org.cactoos.text.BytesAsText;
import org.cactoos.text.StringAsText;
import org.cactoos.text.TextAsBytes;
import org.hamcrest.MatcherAssert;
import org.junit.Test;
Expand Down Expand Up @@ -79,14 +78,7 @@ public void copiesToFile() throws IOException {
"Can't copy Input to File and return content",
new BytesAsText(
new InputAsBytes(
new TeeInput(
new BytesAsInput(
new TextAsBytes(
new StringAsText("Hello, друг!")
)
),
new PathAsOutput(temp)
)
new TeeInput("Hello, друг!", temp)
)
),
new TextHasString(
Expand Down

0 comments on commit c9ba740

Please sign in to comment.