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

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 8fdc1e93a339a46ee38983ce9941fa504c04dd1a
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Fri Dec 27 11:31:21 2024 +0100

    Rename `SampleModelFactory` as `SampleModelBuilder` (internal class).
---
 .../apache/sis/coverage/privy/RangeArgument.java   |  4 +--
 ...leModelFactory.java => SampleModelBuilder.java} | 18 +++++-----
 ...actoryTest.java => SampleModelBuilderTest.java} | 40 +++++++++++-----------
 .../sis/storage/geotiff/ImageFileDirectory.java    |  4 +--
 .../storage/geotiff/writer/ReformattedImage.java   |  4 +--
 5 files changed, 35 insertions(+), 35 deletions(-)

diff --git 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/privy/RangeArgument.java
 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/privy/RangeArgument.java
index a43d48c286..a2ad7bd54b 100644
--- 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/privy/RangeArgument.java
+++ 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/privy/RangeArgument.java
@@ -345,7 +345,7 @@ public final class RangeArgument {
      * @throws IllegalArgumentException if an error occurred when constructing 
the new sample model.
      *
      * @see SampleModel#createSubsetSampleModel(int[])
-     * @see SampleModelFactory#subsetAndCompress(int[])
+     * @see SampleModelBuilder#subsetAndCompress(int[])
      */
     public SampleModel select(final SampleModel model, final boolean view) {
         if (model == null || isIdentity()) {
@@ -355,7 +355,7 @@ public final class RangeArgument {
         if (view) {
             return model.createSubsetSampleModel(bands);
         } else {
-            final var factory = new SampleModelFactory(model);
+            final var factory = new SampleModelBuilder(model);
             factory.subsetAndCompress(bands);
             return factory.build();
         }
diff --git 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/privy/SampleModelFactory.java
 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/privy/SampleModelBuilder.java
similarity index 96%
rename from 
endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/privy/SampleModelFactory.java
rename to 
endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/privy/SampleModelBuilder.java
index ce47dee9e2..dc08be7e9d 100644
--- 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/privy/SampleModelFactory.java
+++ 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/privy/SampleModelBuilder.java
@@ -28,13 +28,13 @@ import java.awt.image.SinglePixelPackedSampleModel;
 import java.awt.image.RasterFormatException;
 import org.apache.sis.util.ArraysExt;
 import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.image.DataType;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.image.DataType;
 import org.apache.sis.pending.jdk.JDK18;
 
 
 /**
- * A factory for {@link SampleModel} instances. This class provides a 
convenient way to get the properties
+ * A builder for {@link SampleModel} instances. This class provides a 
convenient way to get the properties
  * of an existing sample model, modify them, then create a new sample model 
with the modified properties.
  *
  * @author  Martin Desruisseaux (Geomatys)
@@ -42,7 +42,7 @@ import org.apache.sis.pending.jdk.JDK18;
  * @see SampleModel#createCompatibleSampleModel(int, int)
  * @see SampleModel#createSubsetSampleModel(int[])
  */
-public final class SampleModelFactory {
+public final class SampleModelBuilder {
     /**
      * Type of sample values as one of the {@link DataBuffer} constants.
      */
@@ -113,7 +113,7 @@ public final class SampleModelFactory {
      * @param  isBanded       {@code true} if each band is stored in a 
separated bank.
      * @throws RasterFormatException if the arguments imply a sample model of 
unsupported type.
      */
-    public SampleModelFactory(final DataType type, final Dimension size,
+    public SampleModelBuilder(final DataType type, final Dimension size,
             final int numBands, final int bitsPerSample, final boolean 
isBanded)
     {
         this.dataType  = type.toDataBufferType();
@@ -152,12 +152,12 @@ public final class SampleModelFactory {
     }
 
     /**
-     * Creates a new factory initialized to the value of given sample model.
+     * Creates a new builder initialized to the value of given sample model.
      *
      * @param  model  the sample model from which to copy values.
      * @throws RasterFormatException if the type of the given sample model is 
not supported.
      */
-    public SampleModelFactory(final SampleModel model) {
+    public SampleModelBuilder(final SampleModel model) {
         width    = model.getWidth();
         height   = model.getHeight();
         numBands = model.getNumBands();
@@ -321,10 +321,10 @@ public final class SampleModelFactory {
     }
 
     /**
-     * Builds a sample model based on current factory configuration.
-     * The factory is still valid after this method call.
+     * Builds a sample model based on current builder configuration.
+     * The builder is still valid after this method call.
      *
-     * @return the sample model built from current factory configuration.
+     * @return the sample model built from current builder configuration.
      * @throws IllegalArgumentException if an error occurred while building a 
sample model.
      */
     public SampleModel build() {
diff --git 
a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/privy/SampleModelFactoryTest.java
 
b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/privy/SampleModelBuilderTest.java
similarity index 83%
rename from 
endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/privy/SampleModelFactoryTest.java
rename to 
endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/privy/SampleModelBuilderTest.java
index 421485a15b..3619d6157a 100644
--- 
a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/privy/SampleModelFactoryTest.java
+++ 
b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/privy/SampleModelBuilderTest.java
@@ -32,11 +32,11 @@ import org.apache.sis.test.TestCase;
 
 
 /**
- * Tests {@link SampleModelFactory}.
+ * Tests {@link SampleModelBuilder}.
  *
  * @author  Martin Desruisseaux (Geomatys)
  */
-public final class SampleModelFactoryTest extends TestCase {
+public final class SampleModelBuilderTest extends TestCase {
     /**
      * Arbitrary width, height and number of bands for the sample models to 
create.
      * Size does not matter because we will not create data buffer.
@@ -46,7 +46,7 @@ public final class SampleModelFactoryTest extends TestCase {
     /**
      * Creates a new test case.
      */
-    public SampleModelFactoryTest() {
+    public SampleModelBuilderTest() {
     }
 
     /**
@@ -62,7 +62,7 @@ public final class SampleModelFactoryTest extends TestCase {
     @Test
     public void testBanded() {
         final BandedSampleModel model = test(BandedSampleModel.class,
-                new SampleModelFactory(DataType.FLOAT, size(), NUM_BANDS, 
Float.SIZE, true));
+                new SampleModelBuilder(DataType.FLOAT, size(), NUM_BANDS, 
Float.SIZE, true));
 
         assertArrayEquals(new int[] {1, 0, 2}, model.getBankIndices());
         assertArrayEquals(new int[] {0, 0, 0}, model.getBandOffsets());
@@ -77,7 +77,7 @@ public final class SampleModelFactoryTest extends TestCase {
     @Test
     public void testPixelInterleaved() {
         final PixelInterleavedSampleModel model = 
test(PixelInterleavedSampleModel.class,
-                new SampleModelFactory(DataType.BYTE, size(), NUM_BANDS, 
Byte.SIZE, false));
+                new SampleModelBuilder(DataType.BYTE, size(), NUM_BANDS, 
Byte.SIZE, false));
 
         assertArrayEquals(new int[] {0, 0, 0}, model.getBankIndices());
         assertArrayEquals(new int[] {1, 0, 2}, model.getBandOffsets());
@@ -94,7 +94,7 @@ public final class SampleModelFactoryTest extends TestCase {
     @Test
     public void testSinglePixelPacked() {
         final SinglePixelPackedSampleModel model = 
test(SinglePixelPackedSampleModel.class,
-                new SampleModelFactory(DataType.INT, size(), NUM_BANDS, 5, 
false));
+                new SampleModelBuilder(DataType.INT, size(), NUM_BANDS, 5, 
false));
 
         final int[] expected = {
             0b1111100000,           // Band 2 specified, 1 after compression.
@@ -114,23 +114,23 @@ public final class SampleModelFactoryTest extends 
TestCase {
     @Test
     public void testPixelMultiPixelPacked() {
         final int bitsPerSample = 4;
-        var factory = new SampleModelFactory(DataType.INT, size(), 1, 
bitsPerSample, false);
-        final var model = (MultiPixelPackedSampleModel) factory.build();
+        var builder = new SampleModelBuilder(DataType.INT, size(), 1, 
bitsPerSample, false);
+        final var model = (MultiPixelPackedSampleModel) builder.build();
 
         assertEquals(bitsPerSample, model.getPixelBitStride());
         assertEquals(WIDTH / (Integer.SIZE / bitsPerSample), 
model.getScanlineStride());
         assertEquals(DataBuffer.TYPE_INT, model.getDataType());
 
-        factory = new SampleModelFactory(model);
-        assertEquals(model, factory.build());
+        builder = new SampleModelBuilder(model);
+        assertEquals(model, builder.build());
     }
 
     /**
-     * Builds a sample model using the given factory, tests basic properties, 
then applies a band subset.
+     * Builds a sample model using the given builder, tests basic properties, 
then applies a band subset.
      * The band subset is exactly: {2, 1, 4}.
      */
-    private static <T extends SampleModel> T test(final Class<T> modelType, 
SampleModelFactory factory) {
-        final SampleModel model = factory.build();
+    private static <T extends SampleModel> T test(final Class<T> modelType, 
SampleModelBuilder builder) {
+        final SampleModel model = builder.build();
         assertEquals(WIDTH,     model.getWidth());
         assertEquals(HEIGHT,    model.getHeight());
         assertEquals(NUM_BANDS, model.getNumBands());
@@ -140,20 +140,20 @@ public final class SampleModelFactoryTest extends 
TestCase {
          * The subset is fixed by this method's contract.
          */
         final int[] bands = {2, 1, 4};
-        factory.subsetAndCompress(bands);
-        final SampleModel subset = factory.build();
+        builder.subsetAndCompress(bands);
+        final SampleModel subset = builder.build();
         assertEquals(WIDTH,  subset.getWidth());
         assertEquals(HEIGHT, subset.getHeight());
         assertEquals(3,      subset.getNumBands());
         assertInstanceOf(modelType, subset);
         /*
-         * Repeat the same operations on a factory created using a sample
+         * Repeat the same operations on a builder created using a sample
          * model as a template, and verify that we get the same results.
          */
-        factory = new SampleModelFactory(model);
-        assertEquals(model, factory.build());
-        factory.subsetAndCompress(bands);
-        assertEquals(subset, factory.build());
+        builder = new SampleModelBuilder(model);
+        assertEquals(model, builder.build());
+        builder.subsetAndCompress(bands);
+        assertEquals(subset, builder.build());
         return modelType.cast(subset);
     }
 }
diff --git 
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/ImageFileDirectory.java
 
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/ImageFileDirectory.java
index 7c4fc0e5cf..6136be8c22 100644
--- 
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/ImageFileDirectory.java
+++ 
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/ImageFileDirectory.java
@@ -55,7 +55,7 @@ import org.apache.sis.coverage.grid.GridGeometry;
 import org.apache.sis.coverage.grid.GridExtent;
 import org.apache.sis.coverage.privy.ColorModelBuilder;
 import org.apache.sis.coverage.privy.ColorModelFactory;
-import org.apache.sis.coverage.privy.SampleModelFactory;
+import org.apache.sis.coverage.privy.SampleModelBuilder;
 import org.apache.sis.util.Numbers;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.resources.Vocabulary;
@@ -1611,7 +1611,7 @@ final class ImageFileDirectory extends DataCube {
             final DataType type = getDataType();
             if (type != null) try {
                 var size = new Dimension(tileWidth, tileHeight);
-                sampleModel = new SampleModelFactory(type, size, 
samplesPerPixel, bitsPerSample, isPlanar).build();
+                sampleModel = new SampleModelBuilder(type, size, 
samplesPerPixel, bitsPerSample, isPlanar).build();
             } catch (IllegalArgumentException | RasterFormatException e) {
                 error = e;
             }
diff --git 
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/writer/ReformattedImage.java
 
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/writer/ReformattedImage.java
index d698893567..5e073e170d 100644
--- 
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/writer/ReformattedImage.java
+++ 
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/writer/ReformattedImage.java
@@ -31,7 +31,7 @@ import org.apache.sis.image.ImageLayout;
 import org.apache.sis.image.PlanarImage;
 import org.apache.sis.image.ImageProcessor;
 import org.apache.sis.coverage.privy.ImageUtilities;
-import org.apache.sis.coverage.privy.SampleModelFactory;
+import org.apache.sis.coverage.privy.SampleModelBuilder;
 import org.apache.sis.io.stream.HyperRectangleWriter;
 
 
@@ -143,7 +143,7 @@ public final class ReformattedImage {
         boolean reformat = false;
         SampleModel sm = image.getSampleModel();
         if (!HyperRectangleWriter.Builder.isSupported(sm)) {
-            final var factory = new SampleModelFactory(sm);
+            final var factory = new SampleModelBuilder(sm);
             if (factory.unpack(banded)) {
                 sm = factory.build();
                 reformat = true;

Reply via email to