This is an automated email from the ASF dual-hosted git repository.

mattjuntunen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-geometry.git


The following commit(s) were added to refs/heads/master by this push:
     new a047462  GEOMETRY-139: abstracting GeometryInput and GeometryOutput 
commons fields into GeometryIOMetadata
a047462 is described below

commit a0474622d0ad7b9756ba61568de7f111326e4017
Author: Matt Juntunen <mattjuntu...@apache.org>
AuthorDate: Sat Jul 31 18:44:11 2021 -0400

    GEOMETRY-139: abstracting GeometryInput and GeometryOutput commons fields 
into GeometryIOMetadata
---
 ...yInput.java => AbstractGeometryIOMetadata.java} | 16 +++---
 ...GeometryOutput.java => GeometryIOMetadata.java} | 23 +++-----
 .../geometry/io/core/input/FileGeometryInput.java  |  4 +-
 .../geometry/io/core/input/GeometryInput.java      | 19 ++-----
 .../io/core/input/StreamGeometryInput.java         |  5 +-
 .../geometry/io/core/input/UrlGeometryInput.java   |  4 +-
 .../io/core/output/AbstractGeometryOutput.java     | 63 ----------------------
 .../io/core/output/FileGeometryOutput.java         |  4 +-
 .../geometry/io/core/output/GeometryOutput.java    | 17 ++----
 .../io/core/output/StreamGeometryOutput.java       |  5 +-
 10 files changed, 40 insertions(+), 120 deletions(-)

diff --git 
a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/input/AbstractGeometryInput.java
 
b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/AbstractGeometryIOMetadata.java
similarity index 78%
rename from 
commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/input/AbstractGeometryInput.java
rename to 
commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/AbstractGeometryIOMetadata.java
index 94e3730..89c6e26 100644
--- 
a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/input/AbstractGeometryInput.java
+++ 
b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/AbstractGeometryIOMetadata.java
@@ -14,25 +14,25 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.geometry.io.core.input;
+package org.apache.commons.geometry.io.core;
 
 import java.nio.charset.Charset;
 
-/** Abstract base class for {@link GeometryInput} implementations.
+/** Abstract base class for {@link GeometryIOMetadata} implementations.
  */
-abstract class AbstractGeometryInput implements GeometryInput {
+public class AbstractGeometryIOMetadata implements GeometryIOMetadata {
 
-    /** Input file name. */
+    /** File name; may be null. */
     private final String fileName;
 
-    /** Input charset; may be null. */
+    /** Charset; may be null. */
     private final Charset charset;
 
     /** Construct a new instance with the given file name and charset.
-     * @param fileName file name
-     * @param charset charset to use when reading input; may be null
+     * @param fileName file name; may be null
+     * @param charset charset; may be null
      */
-    AbstractGeometryInput(final String fileName, final Charset charset) {
+    protected AbstractGeometryIOMetadata(final String fileName, final Charset 
charset) {
         this.fileName = fileName;
         this.charset = charset;
     }
diff --git 
a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/output/GeometryOutput.java
 
b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/GeometryIOMetadata.java
similarity index 60%
copy from 
commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/output/GeometryOutput.java
copy to 
commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/GeometryIOMetadata.java
index 99f70e3..0c32f85 100644
--- 
a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/output/GeometryOutput.java
+++ 
b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/GeometryIOMetadata.java
@@ -14,30 +14,23 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.geometry.io.core.output;
+package org.apache.commons.geometry.io.core;
 
-import java.io.OutputStream;
 import java.nio.charset.Charset;
 
-/** Interface representing the output of a geometric IO operation.
+/** Interface containing basic metadata fields for use in I/O operations.
  */
-public interface GeometryOutput {
+public interface GeometryIOMetadata {
 
-    /** Get the output file name.
-     * @return output file name
+    /** Get the file name associated with the operation, if any.
+     * @return file name associated with the operation or null
+     *      if unknown or not applicable
      */
     String getFileName();
 
-    /** Get the charset of the output or null if the charset
-     * is unknown or not applicable.
-     * @return charset of the input or null if unknown or
+    /** Get the charset for the operation, if any.
+     * @return charset for the operation or null if unknown or
      *      not applicable
      */
     Charset getCharset();
-
-    /** Get the output stream for writing to the output.
-     * @return output stream for writing to the output
-     * @throws java.io.UncheckedIOException if an I/O error occurs
-     */
-    OutputStream getOutputStream();
 }
diff --git 
a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/input/FileGeometryInput.java
 
b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/input/FileGeometryInput.java
index 2e9071a..b3ffdc4 100644
--- 
a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/input/FileGeometryInput.java
+++ 
b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/input/FileGeometryInput.java
@@ -22,11 +22,13 @@ import java.nio.charset.Charset;
 import java.nio.file.Files;
 import java.nio.file.Path;
 
+import org.apache.commons.geometry.io.core.AbstractGeometryIOMetadata;
 import org.apache.commons.geometry.io.core.internal.GeometryIOUtils;
 
 /** {@link GeometryInput} implementation for reading content from a file.
  */
-public class FileGeometryInput extends AbstractGeometryInput {
+public class FileGeometryInput extends AbstractGeometryIOMetadata
+    implements GeometryInput {
 
     /** Input file. */
     private final Path file;
diff --git 
a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/input/GeometryInput.java
 
b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/input/GeometryInput.java
index 92ad0f0..63a0e58 100644
--- 
a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/input/GeometryInput.java
+++ 
b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/input/GeometryInput.java
@@ -17,23 +17,12 @@
 package org.apache.commons.geometry.io.core.input;
 
 import java.io.InputStream;
-import java.nio.charset.Charset;
 
-/** Interface representing input to a geometric IO operation.
- */
-public interface GeometryInput {
-
-    /** Get the file name of the input.
-     * @return file name of the input
-     */
-    String getFileName();
+import org.apache.commons.geometry.io.core.GeometryIOMetadata;
 
-    /** Get the charset of the input or null if the charset
-     * is unknown or not applicable.
-     * @return charset of the input or null if unknown or
-     *      not applicable
-     */
-    Charset getCharset();
+/** Interface representing input to a geometric I/O operation.
+ */
+public interface GeometryInput extends GeometryIOMetadata {
 
     /** Get the input stream for reading from the input.
      * @return input stream for reading from the input
diff --git 
a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/input/StreamGeometryInput.java
 
b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/input/StreamGeometryInput.java
index b1f7664..c32db00 100644
--- 
a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/input/StreamGeometryInput.java
+++ 
b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/input/StreamGeometryInput.java
@@ -19,9 +19,12 @@ package org.apache.commons.geometry.io.core.input;
 import java.io.InputStream;
 import java.nio.charset.Charset;
 
+import org.apache.commons.geometry.io.core.AbstractGeometryIOMetadata;
+
 /** {@link GeometryInput} implementation that wraps an {@link InputStream}.
  */
-public class StreamGeometryInput extends AbstractGeometryInput {
+public class StreamGeometryInput extends AbstractGeometryIOMetadata
+    implements GeometryInput {
 
     /** Input stream. */
     private final InputStream in;
diff --git 
a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/input/UrlGeometryInput.java
 
b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/input/UrlGeometryInput.java
index 15fba7a..1677644 100644
--- 
a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/input/UrlGeometryInput.java
+++ 
b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/input/UrlGeometryInput.java
@@ -21,11 +21,13 @@ import java.io.InputStream;
 import java.net.URL;
 import java.nio.charset.Charset;
 
+import org.apache.commons.geometry.io.core.AbstractGeometryIOMetadata;
 import org.apache.commons.geometry.io.core.internal.GeometryIOUtils;
 
 /** {@link GeometryInput} implementation for reading content from a URL.
  */
-public class UrlGeometryInput extends AbstractGeometryInput {
+public class UrlGeometryInput extends AbstractGeometryIOMetadata
+    implements GeometryInput {
 
     /** Input URL. */
     private final URL url;
diff --git 
a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/output/AbstractGeometryOutput.java
 
b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/output/AbstractGeometryOutput.java
deleted file mode 100644
index 76be3f0..0000000
--- 
a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/output/AbstractGeometryOutput.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.geometry.io.core.output;
-
-import java.nio.charset.Charset;
-
-/** Abstract base class for {@link GeometryOutput} implementations.
- */
-abstract class AbstractGeometryOutput implements GeometryOutput {
-
-    /** Output file name. */
-    private final String fileName;
-
-    /** Output charset; may be null. */
-    private final Charset charset;
-
-    /** Construct a new instance with the given file name and charset.
-     * @param fileName file name
-     * @param charset charset to use when writing output; may be null
-     */
-    protected AbstractGeometryOutput(final String fileName, final Charset 
charset) {
-        this.fileName = fileName;
-        this.charset = charset;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String getFileName() {
-        return fileName;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public Charset getCharset() {
-        return charset;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String toString() {
-        final StringBuilder sb = new StringBuilder();
-        sb.append(getClass().getSimpleName())
-            .append("[fileName= ")
-            .append(getFileName())
-            .append(']');
-
-        return sb.toString();
-    }
-}
diff --git 
a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/output/FileGeometryOutput.java
 
b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/output/FileGeometryOutput.java
index 5ea9531..de67cce 100644
--- 
a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/output/FileGeometryOutput.java
+++ 
b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/output/FileGeometryOutput.java
@@ -22,11 +22,13 @@ import java.nio.charset.Charset;
 import java.nio.file.Files;
 import java.nio.file.Path;
 
+import org.apache.commons.geometry.io.core.AbstractGeometryIOMetadata;
 import org.apache.commons.geometry.io.core.internal.GeometryIOUtils;
 
 /** {@link GeometryOutput} implementation for writing content to a file.
  */
-public class FileGeometryOutput extends AbstractGeometryOutput {
+public class FileGeometryOutput extends AbstractGeometryIOMetadata
+    implements GeometryOutput {
 
     /** File to write to. */
     private final Path file;
diff --git 
a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/output/GeometryOutput.java
 
b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/output/GeometryOutput.java
index 99f70e3..11945ab 100644
--- 
a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/output/GeometryOutput.java
+++ 
b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/output/GeometryOutput.java
@@ -17,23 +17,12 @@
 package org.apache.commons.geometry.io.core.output;
 
 import java.io.OutputStream;
-import java.nio.charset.Charset;
+
+import org.apache.commons.geometry.io.core.GeometryIOMetadata;
 
 /** Interface representing the output of a geometric IO operation.
  */
-public interface GeometryOutput {
-
-    /** Get the output file name.
-     * @return output file name
-     */
-    String getFileName();
-
-    /** Get the charset of the output or null if the charset
-     * is unknown or not applicable.
-     * @return charset of the input or null if unknown or
-     *      not applicable
-     */
-    Charset getCharset();
+public interface GeometryOutput extends GeometryIOMetadata {
 
     /** Get the output stream for writing to the output.
      * @return output stream for writing to the output
diff --git 
a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/output/StreamGeometryOutput.java
 
b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/output/StreamGeometryOutput.java
index 2726fe7..3d71abf 100644
--- 
a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/output/StreamGeometryOutput.java
+++ 
b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/output/StreamGeometryOutput.java
@@ -19,9 +19,12 @@ package org.apache.commons.geometry.io.core.output;
 import java.io.OutputStream;
 import java.nio.charset.Charset;
 
+import org.apache.commons.geometry.io.core.AbstractGeometryIOMetadata;
+
 /** {@link GeometryOutput} implementation that wraps an {@link OutputStream}.
  */
-public class StreamGeometryOutput extends AbstractGeometryOutput {
+public class StreamGeometryOutput extends AbstractGeometryIOMetadata
+    implements GeometryOutput {
 
     /** Output stream. */
     private final OutputStream out;

Reply via email to