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 552f41a83b2d6f4b1648abc03f778727427ff046
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Thu Oct 2 17:48:56 2025 +0200

    Remove deprecated methods related to metadata.
---
 .../apache/sis/metadata/ModifiableMetadata.java    | 66 ++++------------------
 .../main/org/apache/sis/util/iso/Types.java        | 60 +-------------------
 .../test/org/apache/sis/util/iso/TypesTest.java    | 17 +-----
 .../factory/sql/InstallationScriptProvider.java    | 22 --------
 4 files changed, 16 insertions(+), 149 deletions(-)

diff --git 
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/ModifiableMetadata.java
 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/ModifiableMetadata.java
index 208133fd41..c630f9b273 100644
--- 
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/ModifiableMetadata.java
+++ 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/ModifiableMetadata.java
@@ -31,7 +31,6 @@ import java.nio.charset.Charset;
 import jakarta.xml.bind.annotation.XmlTransient;
 import org.opengis.util.CodeList;
 import org.opengis.metadata.Metadata;               // For javadoc
-import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.collection.Containers;
 import org.apache.sis.util.collection.CodeListSet;
 import org.apache.sis.util.internal.shared.CollectionsExt;
@@ -421,7 +420,7 @@ public abstract class ModifiableMetadata extends 
AbstractMetadata {
     protected final <E> List<E> writeList(Collection<? extends E> source, 
List<E> target, Class<E> elementType)
             throws UnmodifiableMetadataException
     {
-        return (List<E>) write(source, target, elementType, List.class);
+        return (List<E>) write(source, target, elementType, false);
     }
 
     /**
@@ -449,7 +448,7 @@ public abstract class ModifiableMetadata extends 
AbstractMetadata {
     protected final <E> Set<E> writeSet(Collection<? extends E> source, Set<E> 
target, Class<E> elementType)
             throws UnmodifiableMetadataException
     {
-        return (Set<E>) write(source, target, elementType, Set.class);
+        return (Set<E>) write(source, target, elementType, true);
     }
 
     /**
@@ -461,16 +460,14 @@ public abstract class ModifiableMetadata extends 
AbstractMetadata {
      *   <li>If {@code source} is null or empty, returns {@code null}
      *       (meaning that the metadata property is not provided).</li>
      *   <li>If {@code target} is null, creates a new {@link Set} or a new 
{@link List}
-     *       depending on the value returned by {@link 
#collectionType(Class)}.</li>
+     *       depending on {@code elementType}}.</li>
      *   <li>Copies the content of the given {@code source} into the 
target.</li>
      * </ul>
      *
      * <h4>Choosing a collection type</h4>
      * Implementations shall invoke {@link #writeList writeList} or {@link 
#writeSet writeSet} methods
      * instead of this method when the collection type is enforced by ISO 
specification.
-     * When the type is not enforced by the specification, some freedom are 
allowed at
-     * implementer choice. The default implementation invokes {@link 
#collectionType(Class)}
-     * in order to get a hint about whether a {@link List} or a {@link Set} 
should be used.
+     * When the type is not enforced by the specification, some freedom are 
allowed at implementer choice.
      *
      * @param  <E>          the type represented by the {@code Class} argument.
      * @param  source       the source collection, or {@code null}.
@@ -483,18 +480,18 @@ public abstract class ModifiableMetadata extends 
AbstractMetadata {
     protected final <E> Collection<E> writeCollection(Collection<? extends E> 
source, Collection<E> target, Class<E> elementType)
             throws UnmodifiableMetadataException
     {
-        return write(source, target, elementType, null);
+        return write(source, target, elementType, useSet(elementType));
     }
 
     /**
      * Writes the content of the {@code source} collection into the {@code 
target} list or set,
      * creating it if needed.
      *
-     * @param  collectionType  {@code Set.class}, {@code List.class} or null 
for automatic choice.
+     * @param  useSet  {@code true} for creating a {@code Set}, or {@code 
false} for a {@code List}.
      */
     @SuppressWarnings("unchecked")
     private <E> Collection<E> write(final Collection<? extends E> source, 
Collection<E> target,
-            final Class<E> elementType, Class<?> collectionType) throws 
UnmodifiableMetadataException
+            final Class<E> elementType, final boolean useSet) throws 
UnmodifiableMetadataException
     {
         /*
          * It is not worth to copy the content if the current and the new 
instance are the
@@ -508,7 +505,6 @@ public abstract class ModifiableMetadata extends 
AbstractMetadata {
                  * transitionTo(State.FINAL) is under progress. The source 
collection is already
                  * an unmodifiable instance created by StateChanger.
                  */
-                assert (collectionType != null) || 
collectionType(elementType).isInstance(source) : elementType;
                 return (Collection<E>) source;
             }
             checkWritePermission(valueIfDefined(target));
@@ -522,20 +518,15 @@ public abstract class ModifiableMetadata extends 
AbstractMetadata {
                 if (target != null && state != COMPLETABLE) {
                     target.clear();
                 } else {
-                    if (collectionType == null) {
-                        collectionType = collectionType(elementType);
-                    }
-                    if (collectionType == Set.class) {
+                    if (useSet) {
                         target = createSet(elementType, source);
-                    } else if (collectionType == List.class) {
-                        target = createList(elementType, source);
                     } else {
-                        throw new 
UnsupportedOperationException(Errors.format(Errors.Keys.UnsupportedType_1, 
collectionType));
+                        target = createList(elementType, source);
                     }
                 }
                 target.addAll(source);
                 if (state == COMPLETABLE) {
-                    if (collectionType == Set.class) {
+                    if (useSet) {
                         target = CollectionsExt.unmodifiableOrCopy((Set<E>) 
target);
                     } else {
                         target = CollectionsExt.unmodifiableOrCopy((List<E>) 
target);
@@ -776,8 +767,6 @@ public abstract class ModifiableMetadata extends 
AbstractMetadata {
      * Implementations shall invoke {@link #nonNullList nonNullList(…)} or 
{@link #nonNullSet nonNullSet(…)}
      * instead of this method when the collection type is enforced by ISO 
specification.
      * When the type is not enforced by the specification, some freedom are 
allowed at implementer choice.
-     * The default implementation invokes {@link #collectionType(Class)} in 
order to get a hint about whether
-     * a {@link List} or a {@link Set} should be used.
      *
      * @param  <E>          the type represented by the {@code Class} argument.
      * @param  current      the existing collection, or {@code null} if the 
collection has not yet been created.
@@ -786,28 +775,24 @@ public abstract class ModifiableMetadata extends 
AbstractMetadata {
      */
     protected final <E> Collection<E> nonNullCollection(final Collection<E> 
current, final Class<E> elementType) {
         if (current != null) {
-            assert collectionType(elementType).isInstance(current);
             return current.isEmpty() && emptyCollectionAsNull() ? null : 
current;
         }
         if (emptyCollectionAsNull()) {
             return null;
         }
         final boolean isModifiable = (state < FREEZING);
-        final Class<?> collectionType = collectionType(elementType);
-        if (collectionType == Set.class) {
+        if (useSet(elementType)) {
             if (isModifiable) {
                 return createSet(elementType, current);         // `current` 
given as a matter of principle even if null.
             } else {
                 return Collections.emptySet();
             }
-        } else if (collectionType == List.class) {
+        } else {
             if (isModifiable) {
                 return createList(elementType, current);        // `current` 
given as a matter of principle even if null.
             } else {
                 return Collections.emptyList();
             }
-        } else {
-            throw new 
UnsupportedOperationException(Errors.format(Errors.Keys.UnsupportedType_1, 
collectionType));
         }
     }
 
@@ -911,31 +896,4 @@ public abstract class ModifiableMetadata extends 
AbstractMetadata {
                 ||        Locale.class ==               elementType
                 ||      Currency.class ==               elementType;
     }
-
-    /**
-     * Returns the type of collection to use for the given type. The current 
implementation can
-     * return only two values: <code>{@linkplain Set}.class</code> if the 
property should not
-     * accept duplicated values, or <code>{@linkplain List}.class</code> 
otherwise.
-     * Future SIS versions may accept other types.
-     *
-     * <p>The default implementation returns <code>{@linkplain 
Set}.class</code> if the element
-     * type is assignable to {@link CodeList}, {@link Enum}, {@link String}, 
{@link Charset},
-     * {@link Locale} or {@link Currency}, and <code>{@linkplain 
List}.class</code> otherwise.
-     * Subclasses can override this method for choosing different kind of 
collections.
-     * As a general rule, implementations should return the {@link Set} type
-     * only when the set elements are immutable.
-     * This is needed for {@linkplain Object#hashCode() hash code} 
stability.</p>
-     *
-     * @param  <E>          the type of elements in the collection to be 
created.
-     * @param  elementType  the type of elements in the collection to be 
created.
-     * @return {@code List.class} or {@code Set.class} depending on whether the
-     *         property shall accept duplicated values or not.
-     *
-     * @deprecated This method will be removed because it can cause {@code 
this} to escape at construction time.
-     */
-    @Deprecated(since="1.5", forRemoval=true)
-    @SuppressWarnings({"rawtypes","unchecked"})
-    protected <E> Class<? extends Collection<E>> collectionType(final Class<E> 
elementType) {
-        return (Class) (useSet(elementType) ? Set.class : List.class);
-    }
 }
diff --git 
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/Types.java 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/Types.java
index 9cbce5bd40..f583525d49 100644
--- 
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/Types.java
+++ 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/util/iso/Types.java
@@ -28,7 +28,6 @@ import java.util.logging.Logger;
 import java.util.logging.LogRecord;
 import java.util.function.Function;
 import java.io.IOException;
-import java.lang.reflect.Array;
 import org.opengis.annotation.UML;
 import org.opengis.util.CodeList;
 import org.opengis.util.InternationalString;
@@ -69,7 +68,7 @@ import org.opengis.util.ControlledVocabulary;
  *     <li>{@link #getDescription(ControlledVocabulary)} for a more verbose 
description</li>
  *   </ul></li>
  *   <li>Methods for fetching an instance from a name (converse of above 
{@code get} methods):<ul>
- *     <li>{@link #forCodeName(Class, String, boolean)}</li>
+ *     <li>{@link #forCodeName(Class, String, Function)}</li>
  *     <li>{@link #forEnumName(Class, String)}</li>
  *   </ul></li>
  * </ul>
@@ -215,7 +214,7 @@ public final class Types {
      * @see #getCodeLabel(ControlledVocabulary)
      * @see #getCodeTitle(ControlledVocabulary)
      * @see #getDescription(ControlledVocabulary)
-     * @see #forCodeName(Class, String, boolean)
+     * @see #forCodeName(Class, String, Function)
      */
     public static String getCodeName(final ControlledVocabulary code) {
         if (code == null) {
@@ -456,37 +455,6 @@ public final class Types {
         return type.getName().startsWith("org.opengis.metadata.");
     }
 
-    /**
-     * Returns all known values for the given type of code list or enumeration.
-     * Note that the size of the returned array may growth between different 
invocations of this method,
-     * since users can add their own codes to an existing list.
-     *
-     * <h4>Performance note</h4>
-     * This method works with both {@link Enum} and {@link CodeList}. However 
if the type is known to be
-     * an {@code Enum}, then the standard {@link Class#getEnumConstants()} 
method is more efficient.
-     *
-     * @param  <T>       the compile-time type given as the {@code codeType} 
parameter.
-     * @param  codeType  the type of code list or enumeration.
-     * @return the list of values for the given code list or enumeration, or 
an empty array if none.
-     *
-     * @see Class#getEnumConstants()
-     *
-     * @deprecated This method depends on reflection, which is restricted in 
the context of Java Module System.
-     *             Instead, {@code T.values()} static methods should be 
invoked directly as much as possible.
-     */
-    @SuppressWarnings("unchecked")
-    @Deprecated(since="1.5", forRemoval=true)
-    public static <T extends ControlledVocabulary> T[] getCodeValues(final 
Class<T> codeType) {
-        if (CodeList.class.isAssignableFrom(codeType)) {
-            return (T[]) CodeList.values((Class) codeType);
-        }
-        final T[] codes = codeType.getEnumConstants();
-        if (codes != null) {
-            return codes;
-        }
-        return (T[]) Array.newInstance(codeType, 0);
-    }
-
     /**
      * Returns the Java type (usually a GeoAPI interface) for the given ISO 
name, or {@code null} if none.
      * The identifier argument shall be the value documented in the {@link 
UML#identifier()} annotation on
@@ -649,30 +617,6 @@ public final class Types {
         return code;
     }
 
-    /**
-     * Returns the code of the given type that matches the given name, or 
optionally returns a new one.
-     * If no match is found, then a new code is created only if the {@code 
canCreate} argument is {@code true}.
-     * Otherwise this method returns {@code null}.
-     *
-     * @param  <T>        the compile-time type given as the {@code codeType} 
parameter.
-     * @param  codeType   the type of code list.
-     * @param  name       the name of the code to obtain, or {@code null}.
-     * @param  canCreate  {@code true} if this method is allowed to create new 
code.
-     * @return a code matching the given name, or {@code null} if the name is 
null
-     *         or if no matching code is found and {@code canCreate} is {@code 
false}.
-     *
-     * @deprecated This method depends on reflection, which is restricted in 
the context of Java Module System.
-     *             Replaced by {@link #forCodeName(Class, String, Function)}.
-     */
-    @Deprecated(since="1.5", forRemoval=true)
-    public static <T extends CodeList<T>> T forCodeName(final Class<T> 
codeType, String name, final boolean canCreate) {
-        if (canCreate) {
-            return CodeLists.getOrCreate(codeType, name);
-        } else {
-            return forCodeName(codeType, name, null);
-        }
-    }
-
     /**
      * Returns the code list or enumeration value for the given title, or 
{@code null} if none.
      * The current implementation performs the following choice:
diff --git 
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/util/iso/TypesTest.java
 
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/util/iso/TypesTest.java
index a59e6e0f5d..dbd827f4ee 100644
--- 
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/util/iso/TypesTest.java
+++ 
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/util/iso/TypesTest.java
@@ -17,11 +17,10 @@
 package org.apache.sis.util.iso;
 
 import java.util.Map;
-import java.util.List;
-import java.util.Arrays;
 import java.util.HashMap;
 import java.util.TreeMap;
 import java.util.Locale;
+import java.util.function.Function;
 import java.lang.annotation.ElementType;
 import org.opengis.util.InternationalString;
 import org.opengis.metadata.citation.Address;
@@ -143,7 +142,7 @@ public final class TypesTest extends TestCase {
     }
 
     /**
-     * Tests the {@link Types#forCodeName(Class, String, boolean)} method.
+     * Tests the {@link Types#forCodeName(Class, String, Function)} method.
      */
     @Test
     public void testForCodeName() {
@@ -240,16 +239,4 @@ public final class TypesTest extends TestCase {
         assertEquals("Download",       title.toString(Locale.ENGLISH));
         assertEquals("Téléchargement", title.toString(Locale.FRENCH));
     }
-
-    /**
-     * Tests the {@link Types#getCodeValues(Class)} method.
-     */
-    @Test
-    @SuppressWarnings("removal")
-    public void testGetCodeValues() {
-        final OnLineFunction[] actual = 
Types.getCodeValues(OnLineFunction.class);
-        assertTrue(Arrays.asList(actual).containsAll(List.of(
-                OnLineFunction.INFORMATION, OnLineFunction.SEARCH, 
OnLineFunction.ORDER,
-                OnLineFunction.DOWNLOAD, OnLineFunction.OFFLINE_ACCESS)));
-    }
 }
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java
index 46a1e67a23..eb6606b79b 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java
@@ -60,28 +60,6 @@ import org.apache.sis.util.internal.shared.Constants;
  * @since   0.7
  */
 public abstract class InstallationScriptProvider extends InstallationResources 
{
-    /**
-     * A sentinel value for the content of the script to execute before the 
SQL scripts provided by the authority.
-     * This is an Apache <abbr>SIS</abbr> build-in script for replacing the 
{@code VARCHAR} type of some columns
-     * by enumeration types, in order to constraint the values to the codes 
recognized by {@link EPSGDataAccess}.
-     * Those enumerations are not mandatory for allowing {@link EPSGFactory} 
to work, but improve data integrity.
-     *
-     * @deprecated Ignored since the upgrade to version 10+ of 
<abbr>EPSG</abbr> because too dependent of the database schema.
-     */
-    @Deprecated(since = "1.5", forRemoval = true)
-    protected static final String PREPARE = "Prepare";
-
-    /**
-     * A sentinel value for the content of the script to execute after the SQL 
scripts provided by the authority.
-     * This is an Apache <abbr>SIS</abbr> build-in script for creating indexes 
or performing other manipulations
-     * that help <abbr>SIS</abbr> to use the dataset. Those indexes are not 
mandatory for allowing
-     * {@link EPSGFactory} to work, but improve performances.
-     *
-     * @deprecated Ignored since the upgrade to version 10+ of 
<abbr>EPSG</abbr> because too dependent of the database schema.
-     */
-    @Deprecated(since = "1.5", forRemoval = true)
-    protected static final String FINISH = "Finish";
-
     /**
      * The authorities to be returned by {@link #getAuthorities()}.
      */

Reply via email to