From 457e647e0c6a63047dc7ee76b0620ea2e7d7a72f Mon Sep 17 00:00:00 2001 From: "Olivier B. OURA" Date: Sun, 14 Mar 2021 17:48:02 +0000 Subject: [PATCH] Replace prefix Safe by CloseShield #1449 --- .../io/{SafeInput.java => CloseShieldInput.java} | 6 +++--- ...afeInputStream.java => CloseShieldInputStream.java} | 4 ++-- .../io/{SafeOutput.java => CloseShieldOutput.java} | 6 +++--- ...eOutputStream.java => CloseShieldOutputStream.java} | 4 ++-- src/main/java/org/cactoos/io/package-info.java | 2 +- ...StreamTest.java => CloseShieldInputStreamTest.java} | 10 +++++----- .../{SafeInputTest.java => CloseShieldInputTest.java} | 8 ++++---- ...treamTest.java => CloseShieldOutputStreamTest.java} | 8 ++++---- ...{SafeOutputTest.java => CloseShieldOutputTest.java} | 6 +++--- 9 files changed, 27 insertions(+), 27 deletions(-) rename src/main/java/org/cactoos/io/{SafeInput.java => CloseShieldInput.java} (90%) rename src/main/java/org/cactoos/io/{SafeInputStream.java => CloseShieldInputStream.java} (95%) rename src/main/java/org/cactoos/io/{SafeOutput.java => CloseShieldOutput.java} (90%) rename src/main/java/org/cactoos/io/{SafeOutputStream.java => CloseShieldOutputStream.java} (94%) rename src/test/java/org/cactoos/io/{SafeInputStreamTest.java => CloseShieldInputStreamTest.java} (90%) rename src/test/java/org/cactoos/io/{SafeInputTest.java => CloseShieldInputTest.java} (91%) rename src/test/java/org/cactoos/io/{SafeOutputStreamTest.java => CloseShieldOutputStreamTest.java} (91%) rename src/test/java/org/cactoos/io/{SafeOutputTest.java => CloseShieldOutputTest.java} (91%) diff --git a/src/main/java/org/cactoos/io/SafeInput.java b/src/main/java/org/cactoos/io/CloseShieldInput.java similarity index 90% rename from src/main/java/org/cactoos/io/SafeInput.java rename to src/main/java/org/cactoos/io/CloseShieldInput.java index d95697e19..a1846503e 100644 --- a/src/main/java/org/cactoos/io/SafeInput.java +++ b/src/main/java/org/cactoos/io/CloseShieldInput.java @@ -34,7 +34,7 @@ * * @since 1.0.0 */ -public final class SafeInput implements Input { +public final class CloseShieldInput implements Input { /** * Origin. @@ -45,13 +45,13 @@ public final class SafeInput implements Input { * Ctor. * @param origin Origin */ - public SafeInput(final Input origin) { + public CloseShieldInput(final Input origin) { this.origin = origin; } @Override public InputStream stream() throws Exception { - return new SafeInputStream(this.origin.stream()); + return new CloseShieldInputStream(this.origin.stream()); } } diff --git a/src/main/java/org/cactoos/io/SafeInputStream.java b/src/main/java/org/cactoos/io/CloseShieldInputStream.java similarity index 95% rename from src/main/java/org/cactoos/io/SafeInputStream.java rename to src/main/java/org/cactoos/io/CloseShieldInputStream.java index 13058203b..95aca9a8f 100644 --- a/src/main/java/org/cactoos/io/SafeInputStream.java +++ b/src/main/java/org/cactoos/io/CloseShieldInputStream.java @@ -35,7 +35,7 @@ * * @since 1.0.0 */ -public final class SafeInputStream extends InputStream { +public final class CloseShieldInputStream extends InputStream { /** * Inner {@link InputStream}. @@ -46,7 +46,7 @@ public final class SafeInputStream extends InputStream { * Ctor. * @param origin Origin */ - public SafeInputStream(final InputStream origin) { + public CloseShieldInputStream(final InputStream origin) { super(); this.inner = new AtomicReference<>(origin); } diff --git a/src/main/java/org/cactoos/io/SafeOutput.java b/src/main/java/org/cactoos/io/CloseShieldOutput.java similarity index 90% rename from src/main/java/org/cactoos/io/SafeOutput.java rename to src/main/java/org/cactoos/io/CloseShieldOutput.java index e93a957f0..ea52331b5 100644 --- a/src/main/java/org/cactoos/io/SafeOutput.java +++ b/src/main/java/org/cactoos/io/CloseShieldOutput.java @@ -34,7 +34,7 @@ * * @since 1.0.0 */ -public final class SafeOutput implements Output { +public final class CloseShieldOutput implements Output { /** * Output to preserve. @@ -45,12 +45,12 @@ public final class SafeOutput implements Output { * Ctor. * @param origin Output to preserve. */ - public SafeOutput(final Output origin) { + public CloseShieldOutput(final Output origin) { this.origin = origin; } @Override public OutputStream stream() throws Exception { - return new SafeOutputStream(this.origin.stream()); + return new CloseShieldOutputStream(this.origin.stream()); } } diff --git a/src/main/java/org/cactoos/io/SafeOutputStream.java b/src/main/java/org/cactoos/io/CloseShieldOutputStream.java similarity index 94% rename from src/main/java/org/cactoos/io/SafeOutputStream.java rename to src/main/java/org/cactoos/io/CloseShieldOutputStream.java index 58a1f9836..0532221c3 100644 --- a/src/main/java/org/cactoos/io/SafeOutputStream.java +++ b/src/main/java/org/cactoos/io/CloseShieldOutputStream.java @@ -35,7 +35,7 @@ * * @since 1.0.0 */ -public final class SafeOutputStream extends OutputStream { +public final class CloseShieldOutputStream extends OutputStream { /** * Inner {@link OutputStream}. @@ -46,7 +46,7 @@ public final class SafeOutputStream extends OutputStream { * Ctor. * @param origin Origin */ - public SafeOutputStream(final OutputStream origin) { + public CloseShieldOutputStream(final OutputStream origin) { super(); this.inner = new AtomicReference<>(origin); } diff --git a/src/main/java/org/cactoos/io/package-info.java b/src/main/java/org/cactoos/io/package-info.java index 60d52a4f6..e6ae492a8 100644 --- a/src/main/java/org/cactoos/io/package-info.java +++ b/src/main/java/org/cactoos/io/package-info.java @@ -29,7 +29,7 @@ * @todo #1449:30min We must find all the classes that closes stream of * {@link org.cactoos.Input} or {@link org.cactoos.Output} that have been passed * to them and document them about this behaviour and refer them to the existence - * of {@link org.cactoos.io.SafeInput} and {@link org.cactoos.io.SafeOutput} + * of {@link org.cactoos.io.CloseShieldInput} and {@link org.cactoos.io.CloseShieldOutput} * and how to use them. */ package org.cactoos.io; diff --git a/src/test/java/org/cactoos/io/SafeInputStreamTest.java b/src/test/java/org/cactoos/io/CloseShieldInputStreamTest.java similarity index 90% rename from src/test/java/org/cactoos/io/SafeInputStreamTest.java rename to src/test/java/org/cactoos/io/CloseShieldInputStreamTest.java index 3c5643454..64ac0ba13 100644 --- a/src/test/java/org/cactoos/io/SafeInputStreamTest.java +++ b/src/test/java/org/cactoos/io/CloseShieldInputStreamTest.java @@ -33,18 +33,18 @@ import org.llorllale.cactoos.matchers.Verifies; /** - * Test case for {@link SafeInputStream}. + * Test case for {@link CloseShieldInputStream}. * @since 1.0.0 * @checkstyle ClassDataAbstractionCouplingCheck (500 lines) */ -final class SafeInputStreamTest { +final class CloseShieldInputStreamTest { @Test @SuppressWarnings("try") void preventsOriginalStreamToBeClosed() throws Exception { try (FakeInputStream origin = new FakeInputStream()) { // @checkstyle EmptyBlockCheck (2 lines) - try (InputStream stream = new SafeInputStream(origin)) { + try (InputStream stream = new CloseShieldInputStream(origin)) { } new Assertion<>( "Must not close origin stream", @@ -60,7 +60,7 @@ void readsContent() throws Exception { try (InputStream in = new InputStreamOf(content)) { new Assertion<>( "Must read from text", - new TextOf(new SafeInputStream(in)), + new TextOf(new CloseShieldInputStream(in)), new IsText(content) ).affirm(); } @@ -72,7 +72,7 @@ void makesDataAvailable() throws IOException { try (InputStream in = new InputStreamOf(content)) { new Assertion<>( "Must show that data is available", - new SafeInputStream(in).available(), + new CloseShieldInputStream(in).available(), new Verifies<>(l -> l > 0) ).affirm(); } diff --git a/src/test/java/org/cactoos/io/SafeInputTest.java b/src/test/java/org/cactoos/io/CloseShieldInputTest.java similarity index 91% rename from src/test/java/org/cactoos/io/SafeInputTest.java rename to src/test/java/org/cactoos/io/CloseShieldInputTest.java index d426a5a92..058eb747d 100644 --- a/src/test/java/org/cactoos/io/SafeInputTest.java +++ b/src/test/java/org/cactoos/io/CloseShieldInputTest.java @@ -31,11 +31,11 @@ import org.llorllale.cactoos.matchers.IsText; /** - * Test case for {@link SafeInput}. + * Test case for {@link CloseShieldInput}. * @since 1.0.0 * @checkstyle ClassDataAbstractionCouplingCheck (500 lines) */ -final class SafeInputTest { +final class CloseShieldInputTest { @Test @SuppressWarnings("try") @@ -44,7 +44,7 @@ void preventsOriginalStreamToBeClosed() throws Exception { // @checkstyle EmptyBlockCheck (5 lines) try ( InputStream stream = - new SafeInput(new InputOf(origin)).stream() + new CloseShieldInput(new InputOf(origin)).stream() ) { } new Assertion<>( @@ -63,7 +63,7 @@ void readsContent() throws Exception { ) { new Assertion<>( "Must read text", - new TextOf(new SafeInput(new InputOf(in))), + new TextOf(new CloseShieldInput(new InputOf(in))), new IsText(content) ).affirm(); } diff --git a/src/test/java/org/cactoos/io/SafeOutputStreamTest.java b/src/test/java/org/cactoos/io/CloseShieldOutputStreamTest.java similarity index 91% rename from src/test/java/org/cactoos/io/SafeOutputStreamTest.java rename to src/test/java/org/cactoos/io/CloseShieldOutputStreamTest.java index 4cda1d33a..6888b6b96 100644 --- a/src/test/java/org/cactoos/io/SafeOutputStreamTest.java +++ b/src/test/java/org/cactoos/io/CloseShieldOutputStreamTest.java @@ -35,11 +35,11 @@ import org.llorllale.cactoos.matchers.IsText; /** - * Test case for {@link SafeOutputStream}. + * Test case for {@link CloseShieldOutputStream}. * @since 1.0.0 * @checkstyle ClassDataAbstractionCouplingCheck (500 lines) */ -final class SafeOutputStreamTest { +final class CloseShieldOutputStreamTest { @Test void writesContentToFile(@TempDir final Path tempdir) throws IOException { @@ -53,7 +53,7 @@ void writesContentToFile(@TempDir final Path tempdir) throws IOException { new Sticky( new TeeInput( new ResourceOf("org/cactoos/small-text.txt"), - new OutputTo(new SafeOutputStream(out)) + new OutputTo(new CloseShieldOutputStream(out)) ) ) ), @@ -69,7 +69,7 @@ void writesContentToFile(@TempDir final Path tempdir) throws IOException { void preventsOriginalStreamToBeClosed() throws Exception { try (FakeOutputStream origin = new FakeOutputStream()) { // @checkstyle EmptyBlockCheck (2 lines) - try (OutputStream stream = new SafeOutputStream(origin)) { + try (OutputStream stream = new CloseShieldOutputStream(origin)) { } new Assertion<>( "Must not close origin stream", diff --git a/src/test/java/org/cactoos/io/SafeOutputTest.java b/src/test/java/org/cactoos/io/CloseShieldOutputTest.java similarity index 91% rename from src/test/java/org/cactoos/io/SafeOutputTest.java rename to src/test/java/org/cactoos/io/CloseShieldOutputTest.java index 71339b544..e388ad255 100644 --- a/src/test/java/org/cactoos/io/SafeOutputTest.java +++ b/src/test/java/org/cactoos/io/CloseShieldOutputTest.java @@ -29,10 +29,10 @@ import org.llorllale.cactoos.matchers.Assertion; /** - * Test case for {@link SafeOutput}. + * Test case for {@link CloseShieldOutput}. * @since 1.0.0 */ -final class SafeOutputTest { +final class CloseShieldOutputTest { @Test @SuppressWarnings("try") @@ -40,7 +40,7 @@ void preventsOriginalStreamToBeClosed() throws Exception { try (FakeOutputStream origin = new FakeOutputStream()) { // @checkstyle EmptyBlockCheck (5 lines) try ( - OutputStream stream = new SafeOutput(() -> origin).stream() + OutputStream stream = new CloseShieldOutput(() -> origin).stream() ) { } new Assertion<>(